Hello,
we use the RTX RTOS and USB MSD function to get access to an internal eMMC/SD card that is connected to a Corex M7 CPU.
When the user does a "Safely remove hardware" on the PC: is it possible to detect this event in the microcontroller firmware?
When I do this for a standard USB-Stick, the device is removed and is not visible as a drive anymore.
If I do this for the drive of my embedded eMMC, Windows tells me that I can now safely remove the device, but the drive is still present and I can access it. So I assume that windows sends something like a "stop" command to the drive, and I need to do something in the firmware when I receive this. Is there a function that I can use to check that status?
Regards
Hello Milorad,
I think the changes are very generic and backwards compatible. Not sure if it covers all possible cases...Changes in usbd_lib_msc.c
Changes in USBD_User_MSC_0.c
Usage: once USB MSD is initialized and ownership is set to USB, the firmware checks cyclic:
for(;;) { uint32_t mediastatus; osDelay(100); mediastatus=USBD_MSC0_CheckMedia(); // blockierende funktion!!! if(mediastatus==0) { printf("media status: %d\n",mediastatus); USBD_Disconnect(0); osDelay(20); USBD_Uninitialize(0U); }
The function USB_MSC_Medium_Is_Stopped()==1 I use to switch off some LEDs in case the device is stopped.
Gunnar BohlenHMS-Networks
Hi Gunnar,
thanks for the information.
It might be useful for someone if they require the same feature.
Thank you.
Best regards,Milorad