Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何检测已移除的 SD 卡,之后如何检测插入并重新安装?我正在用 C 语言和 fatfs 在 STM32-F401 工作。检测不正确的安装或移除卡相对容易:
fresult1 = f_mount(&myFATAFS, SDPath, 1) while(FR_OK != fresult1){ /*Watch out for sd-card and if you find one try to mount*/ ... }
现在?
你不能从这个层面做到这一点。SD接口有线CD-CardDetect。您应该将它连接到 GPIO 并在定时器中断中对其进行测试(EXTI 中断对此不好,因为需要去抖动)