Reinitialize SD CARD once disconnected from the system
Hi to all!
Does anyone know how to reinitialize SD CARD communication after removing it during write/read operations?
The communication is implemented using SPI.
These are the commands I’m using:
Mount drive:
tmpFileResult = f_mount(argFatFs, “”, 1); // 1 = mount now
Open file for writing:
tmpFileResult = f_open(argFileId, argFileName, FA_WRITE | FA_OPEN_ALWAYS | FA_CREATE_ALWAYS);
Write record:
tmpFileResult = f_write(argFileId, argString, strlen(argString), &tmpBytesWrote);
Close file:
tmpFileResult = f_close(argFileId);
Un-mount drive:
f_mount(NULL, “”, 0);
If I extract the CARD during the operation I get an error (I check tmpFileResult variable) then I call the following to reinitialize the CARD access:
f_mount(NULL, “”, 0);
But it seems not enough...
Thanks in advance!