Is there an event for USB disconnection?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Is there an event for USB disconnection?

      Hello,


      I'm using emUSB Driver with embOS.
      My application mount an MSD device to storage some files.
      I'd like to know if is possible or there is any callback event the emUSB-Device provide when a disconnection occurs from USB.

      Thank you!
    • Dear Yan,

      I've tried to use the return after call the USBD_MSD_Task(), but I don't know why, sometimes the function don't return after disconnect the USB cable.


      I think that some reason the function blocks.
      I have some debug logs that prove it.

      Have you ever seen this before?

      Thanks.
    • Yan,

      The log I mentioned is from my application.
      It just print on a log.txt file saved on SD Card:
      • "USB Connected" when run the task USBD_MSD_Task()
      • "USB Disconnected" when the function USBD_MSD_Task() returns.

      Sometimes the message "USB Disconnected" does not happens.

      Is there some DEBUG flag that I'm able to show more useful messages for you?

      Thanks.
    • Yes, with the define DEBUG=1
      you can use

      C Source Code

      1. USBD_SetLogFunc(USB_X_Log);
      2. USBD_SetWarnFunc(USB_X_Warn);
      3. USBD_SetLogFilter(0
      4. | USB_MTYPE_INIT
      5. | USB_MTYPE_CORE
      6. | USB_MTYPE_CONFIG
      7. // | USB_MTYPE_DRIVER
      8. // | USB_MTYPE_ENUMERATION
      9. // | USB_MTYPE_TRANSFER
      10. // | USB_MTYPE_IAD
      11. // | USB_MTYPE_CDC
      12. // | USB_MTYPE_HID
      13. | USB_MTYPE_MSD
      14. // | USB_MTYPE_MSD_CDROM
      15. // | USB_MTYPE_MSD_PHY
      16. // | USB_MTYPE_MTP
      17. // | USB_MTYPE_PRINTER
      18. // | USB_MTYPE_RNDIS
      19. // | USB_MTYPE_RNDIS_INTERN
      20. // | USB_MTYPE_SMART_MSD
      21. // | USB_MTYPE_UVC
      22. // | USB_MTYPE_ECM_INTERN
      23. );
      Display All


      The USB_X_Log/USB_X_Warn are located in the USB_ConfigIO.c file, if possible you should use RTT as it influences the timing the least of all possible I/O methods.