I am using a SD Card Module that has no pin for checking existence of SD Card, So i should do the check using fatfs libs. The micro-controller is STM32F103RB and i'am using SPI protocol to communicate with SD Card. Up to now i can detect a removal state with this code:
bool check_SdCard()
{
FATFS check_fatfs;
if(f_mount(&check_fatfs,"",1)==FR_OK)
{
f_mount(NULL,"",1);
return true;
}
else return false;
}
The problem is that i can't check insertion of SD Card (or i cant re init the SD Card properly) to Read/Write to it after removing it from a previous initialization.
the above code returns true if the SD Card is inserted to the module from first startup of the device but always returns false if SD Card removed/reinserted after startup. so f_mount could not reinitialize SD Card after reinsertion. I've also tried
disk_initialize(0)
with no success. Does anyone know how to solve the problem of re initialization of SD Card using fatfs?