2020-07-31 04:57 AM
I have meanwhile a running uSD card. I have the need to reinitialize the card.
In FatFS I do an unmount (it is a mount with certain parameters).
It looks like the following is missing:
void MX_FATFS_DeInit(void)
{
/*## FatFS: UnLink the SD driver ###########################*/
retSD = FATFS_UnLinkDriver(SDPath);
/* USER CODE BEGIN Init */
/* additional user code for init */
/* USER CODE END Init */
}
But now when I reinit the SDIO, it looks like there is a hen-and-egg-problem:
SD_WideBus_Enable / SD_WideBus_Disable
uses SD_FindSCR to get supported bus wide modes.
SD_FindSCR calls
SDMMC_CmdSendSCR
which configures how to transfers data over DAT0 or DAT0 to DAT3 lines (depending on the previous configuration of SDIO bus width). I am not completely sure, if I am correct.
I know or I can store if I was at 4 bit wide mode, but if SDIO bus wide does not fit uSD bus wide, I cannot switch to be able to communicate again.
I don't know yet how to solve it.
Is there perhaps something like
SD_deinitialize
needed in
const Diskio_drvTypeDef SD_Driver = { ... };
?
Going one step back it is perhaps a bad idea to use a command to read supported bus width,
with a command which is dependant on the bus width. Is there perhaps some command to get actual bus width without using any DATx lines? Or can I force card to 1 bit bus width, some "force initialisation" using only CMD communication when I can't control power of the uSD card?
Some special cases:
1) User takes card out and reinserts it. I don't want to power cycle the device. I want to (re-)access the uSD after inserting.
( uSD was without power and resetted all previous configuration settings )
2) uC is doing a SW reset (e.g. firmware update with a reset to restart, hard fault with restart, ...)
( uSD has still power, remains at current settings, but uC is doing a new startup)