void USBDeviceAttach();
This function indicates to the USB host that the USB device has been attached to the bus. This function needs to be called in order for the device to start to enumerate on the bus.
Should only be called when USB_INTERRUPT is defined. Also, should only be called from the main() loop context. Do not call USBDeviceAttach() from within an interrupt handler, as the USBDeviceAttach() function may modify global interrupt enable bits and settings.
For normal USB devices: Make sure that if the module was previously on, that it has been turned off for a long time (ex: 100ms+) before calling this function to re-enable the module. If the device turns off the D+ (for full speed) or D- (for low speed) ~1.5k ohm pull up resistor, and then turns it back on very quickly, common hosts will sometimes reject this event, since no human could ever unplug and re-attach a USB device in a microseconds (or nanoseconds) timescale. The host could simply treat this as some kind of glitch and ignore the event altogether.
See also the USBDeviceDetach() API function documentation.
MLA - USB Library Help Version : 2.16
![]() |