USB_DEVICE_STATE USBGetDeviceState();
This function returns the current state of the device on the USB. This function is used to determine when the device is ready to communicate on the bus. Applications should not try to send or receive data until this function returns CONFIGURED_STATE.
It is also important that applications yield as much time as possible to the USBDeviceTasks() function as possible while the this function returns any value between ATTACHED_STATE through CONFIGURED_STATE.
For more information about the various device states, please refer to the USB specification section 9.1 available from www.usb.org.
Typical usage:
void main(void) { USBDeviceInit() while(1) { USBDeviceTasks(); if((USBGetDeviceState() < CONFIGURED_STATE) || (USBIsDeviceSuspended() == true)) { //Either the device is not configured or we are suspended // so we don't want to do execute any application code continue; //go back to the top of the while loop } else { //Otherwise we are free to run user application code. UserApplication(); } } }
None
Return Values |
Description |
the current state of the device on the bus |
None
MLA - USB Library Help Version : 2.16
![]() |