USB0 connection status

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by DT1 on Fri Apr 25 07:44:37 MST 2014

I'm using the NXP LPC43xx USB stack. I'm implementing a DEV-MSC. I need to know if I have an active connection or not to restrict/allow specific parts of the application. So far in my research I haven't found a clean way to do it. I was thinking on checking the SUSP bit because the behavior I observed was in line with what I wanted to do, but I'm getting strange results, probably due to setup time. Here is what I'm doing:

UINT32 reg = 0;

*** delay of 5ms***
reg = LPC_USB0->PORTSC1_D;

reg value doesn't always reflect the register value when I break, which tells me I'm racing against hardware. It also tells me that's not a good way to do things.

How can I know what is the current USB connection status? By the way, I can't check the VBUS cause we could be powered by there without USB data.