/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / USB cable detect

Username:     
Password:     
             

Forum

# 1   2008-11-09 05:46:15 USB cable detect

coconnor55
New member
Registered: 2008-11-08
Posts: 6

USB cable detect

I'm new and I'm finding the wide variety of conf files to be overwhelming.  However, that's just a nit I'll learn to get over.  I searched the forums for my question and couldn't really find an answer.

For the ST32 Primer, is it possible (and how?) to detect whether the USB cable is actually connected to a PC?  I want to log the times of connection and disconnection.

Thanks, Clint

Offline

 

# 2   2008-11-09 16:34:58 USB cable detect

coconnor55
New member
Registered: 2008-11-08
Posts: 6

Re: USB cable detect

Answered my own question - PrimerJoystick shows how to detect USB through the presence of interrupts.  Not quite the same as detecting power to the USB port (connecting a cable) but it may do.

Offline

 

# 3   2008-11-10 05:12:37 USB cable detect

coconnor55
New member
Registered: 2008-11-08
Posts: 6

Re: USB cable detect

Well, PrimerJoystick shows how to detect USB activity and I've got that working.  Now I really need to know how to tell if there is a cable connected.  Due to the pullups, it seems there should be some way to check the USB_DM and USB_DP pins on the ST32Primer or use the USB_NCON pin.  Has anyone tried this?  I haven't figured out yet the correct way to address the pins - doesn't seem to be in the examples or USBLib.

Offline

 

# 4   2008-11-11 01:18:02 USB cable detect

coconnor55
New member
Registered: 2008-11-08
Posts: 6

Re: USB cable detect

Talking to myself again.  Turns out there is a utility function to detect USB connection in Circle OS.  Attached is the snippet I used in application.c which turns on and off the green LED with the cable connection.

   u16 usbval;
   usbval = UTIL_GetUsb();
   if (usbval)
    {
        LED_Set(LED_GREEN, LED_ON);
        UsbConnect = evt_USBCONNECTED;
    }
    else
    {
        LED_Set(LED_GREEN, LED_OFF);
        UsbConnect = evt_USBDISCONNECTED;
    }

Offline

 

# 5   2008-11-13 08:57:49 USB cable detect

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: USB cable detect

Note that on Primer2, the cable can be connected/disconnected by software.

Offline

 

Board footer