This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USB device connect/disconnect detection on AM335x

Hi,

      I have a usb device who act as a mass storage device for my sd card on a BeagleBone with Starterware and I want to be able to know when the USB cable is plugged/unplugged to start/stop some services depending on state of usb. First, I'm calling USBDMSCInit when sd card is present and USBDMSCTerm when sd card is removed to remove it from windows. But now, I want to enable USB MSC device only if usb is connected AND sd card is present and disable USB MSC device when usb cable in disconnected or sd card is removed. I was thinking I can check with USBModeGet and mask with USB_DEVCTL_VBUS_M to know if cable is connected to host, but after a disconnect/reconnect, I can't detect cable, I see always the same thing USB_DEVCTL_DEV. How to detect usb cable connect/disconnect to host with USB_VBUS tied directly to USB0_VBUS.

Thank you

Jim

  • H Jim,

    Could you please check the values of  

    1. POWER register [SOFTCONN] bit - needs to be 1

    2. USBx Mode Register IDDIG bit field  - needs to be set to ‘1’ ( this is  the software option but lets try this first)

    If there is valid VBUS then the  DEVCTL[SESSION] bit will be set. You can check for this condition.



  • Hi Vineeth,

                         After calling USBDMSCTerm, SOFTCONN is cleared.

    I have found a solution by calling UsbPhyOn after power-up, and checking VBus detection with USBModeGet & USB_DEVCTL_VBUS_M. When VBus is detected, I call UsbPhyOff before calling USBDMSCInit and when cable is disconnected, I'm calling USBDMSCTerm following by UsbPhyOn. I have modified UsbPhyOn and UsbPhyOff to be able to call it without reading uiPHYConfigRegAddr from g_USBInstance.

    Thank you for your help!

    Jim