Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
while(1)
{
USBDeviceTasks(); //Takes care of enumeration and other USB events
if((USBGetDeviceState() < CONFIGURED_STATE) ||
(USBIsDeviceSuspended() == true))
{
//Either the device is not configured or we are suspended,
// so we don't want to execute any USB related application code
continue; //go back to the top of the while loop
}
else
{
//Otherwise we are free to run USB and non-USB related user
//application code.
UserApplication();
}
}
}
Remarks
USBDeviceTasks() does not need to be called while in the USB suspend mode, if the user application firmware in the
USBCBSuspend() callback function enables the ACTVIF USB interrupt source and put the microcontroller into sleep mode. If
the application firmware decides not to sleep the microcontroller core during USB suspend (ex: continues running at full
frequency, or clock switches to a lower frequency), then the USBDeviceTasks() function must still be called periodically, at a
rate frequent enough to ensure the 10ms resume recovery interval USB specification is met. Assuming a worst case primary
oscillator and PLL start up time of <5ms, then USBDeviceTasks() should be called once every 5ms in this scenario.
When the USB cable is detached, or the USB host is not actively powering the VBUS line to +5V nominal, the application
firmware does not always have to call USBDeviceTasks() frequently, as no USB activity will be taking place. However, if
USBDeviceTasks() is not called regularly, some alternative means of promptly detecting when VBUS is powered (indicating
host attachment), or not powered (host powered down or USB cable unplugged) is still needed. For self or dual self/bus
powered USB applications, see the USBDeviceAttach() and USBDeviceDetach() API documentation for additional
considerations.
Preconditions
Make sure the USBDeviceInit() function has been called prior to calling USBDeviceTasks() for the first time.
Function
void USBDeviceTasks(void)
1.4.1.1.1.12 USBEnableEndpoint Function
This function will enable the specified endpoint with the specified options
File
usb_device.h
Syntax
void USBEnableEndpoint(uint8_t ep, uint8_t options);
Returns
None
Description
This function will enable the specified endpoint with the specified options.
Typical Usage:
void USBCBInitEP(void)
{
USBEnableEndpoint(MSD_DATA_IN_EP,USB_IN_ENABLED|USB_OUT_ENABLED|USB_HANDSHAKE_ENABLED|US
B_DISALLOW_SETUP);
1.4 Library Interface MLA - USB Library Help Device/Peripheral
47
Protego_Release_01_05-Related-OEM-Documentation-MLA_v2013_12_20-help_mla_usb.pdf