Content originally posted in LPCWare by lpetersen on Fri Dec 11 14:14:47 MST 2015
Thanks Mike. That was helpful in pointing me in the right direction.
I found a status bit in USB0's PORTSC1_D register for CCS which sounded promising. Upon further investigation though, that status bit does not change even when physically disconnecting USB. According to the user manual -
"A zero indicates that the device did not attach successfully or was forcibly disconnected by the software writing a zero to the Run bit in the USBCMD register. It does not state the device being disconnected or suspended."
Which I found to be true. There is another bit in that same register, SUSP, which indicates when the device is in a suspended mode. It looks like I can use this to determine when USB has been physically disconnected (SUSP goes high, indicating that the device is suspended), but the status remains 'Not Suspended' even when I 'Eject' from Windows.
Does anyone know if I am going about this the right way? Is there a way to detect that windows 'ejected' the device even if it is still physically connected? Does the USBD ROM stack provide any handles into this?
Thanks!