AnsweredAssumed Answered

Using SDIO for both USB Mass Storage Device and FATFS

Question asked by Kok.Henk on Apr 5, 2017
Latest reply on Apr 5, 2017 by Clive One



Over the past ~18 months we have made an stm32F405 based logging device. Data is gathered and stored to SD card, when USB is plugged in, the SD card is "owned" by the Mass Storage Device implementation that we got from the Cube.


After we detect enumeration, we still have to fiddle with FATFS to finish the current log file correctly, and to prevent USB from coming in between (which it does; mass storage is completely handled from USB interrupt context) I simply disable the USB interrupt, do my thing with FATFS and enable the interrupts again. I actually consider this a poor man's solution and I am wondering if there is not a better way to do this. I have seen it lose the enumerated state while the interrupts were turned off, only to regain it immediately after interrupts are turned on again.


Does anyone know if there is a way to keep USB active, but restrict it from accessing SDIO and tell the host "not now, try again in a few milliseconds" (possibly by sending STALL packets?)