I am developing my application on a K60 cpu with KDS 2.0.0 and MQX 4.1.1. I have to handle an SD card with the SPI peripheral.
The MFS demo for SD card with SPI interface is based only on an available GPIO pin for the SD presence detection.
What about when no hardware signal is available to detect the SD card presence?
Well, I think first my firmware starts in the SD_NOT_PRESENT state and every 1 sec checks if fopen("sdcard:", 0) has success.
But what can I do when an SD card is detected and the file system is mounted on it to check the SD presence?
I could try every 1 sec to check the SD card status with:
_io_sdcard_spi_command(sdcard_ptr, SDCARD_SPI_CMD13_SEND_STATUS, 0, &r1, &r2, 1);
Unfortunatelly, that function is local for the sdcard_spi driver...
Is there a better way to check if the SD card was removed?
Also, in my application there could be one or more tasks that may want to access the SD card with the file system: I think a semaphore is needed in file system to perform the SD presence check.