I use usb module of STM32F103C8T6 to be a mass storage device, which allows user to edit some config files in the project.

I want to exit mass storage mode as soon as the user eject the disk, I tried to inquire bDeviceState but its value only changes when I replug the device(it still remains "CONFIGURED" after I safe eject the device).

I want a reliable method to detect the safe eject event from computer.Thanks.

  • \$\begingroup\$ Is there an EE question here? \$\endgroup\$ – Andy aka Sep 26 '16 at 9:06
  • 4
    \$\begingroup\$ @AndyAka how is this question not related to electronics engineering? Interfacing with the USB peripheral and associated libraries sounds like low level embedded software to the. \$\endgroup\$ – jms Sep 26 '16 at 10:27
  • 2
    \$\begingroup\$ @jms hold on there - I asked a question and I neither down voted nor voted to close. \$\endgroup\$ – Andy aka Sep 26 '16 at 10:33
  • \$\begingroup\$ @jms Keep calm, it was just a review audit ;) \$\endgroup\$ – Dmitry Grigoryev Sep 26 '16 at 12:07

"Safe to eject" is strictly a host-side software change of state. It simply means that the host has finished writing any pending changes to the device and won't initiate any more.

There is no reason to provide any signaling to the device itself once this has happened, so there's no way to detect it there when you are emulating storage. You'll have to provide a side channel (i.e., a separate USB endpoint) and a custom host-side driver if you want to do this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.