# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# MLA -- USB Library

20 December, 2013

- 1
- 2
…
- 57
- 58
- 59
- 60
- 61
…
- 311
- 312

Function
bool USBIsDeviceSuspended(void)
1.4.1.1.1.27 USBOUTDataStageDeferred Function
Returns true if a control transfer with OUT data stage is pending, and the firmware has called USBDeferOUTDataStage(),
but has not yet called USBCtrlEPAllowDataStage(). Returns false if a control transfer with OUT data stage is either not
pending, or the firmware did not call USBDeferOUTDataStage() at the start of the control transfer.
This function (macro) would typically be used in the case where the USBDeviceTasks() function executes in the interrupt
context (ex: USB_INTERRUPT option selected in usb_config.h), but the firmware wishes to take care of handling the data
stage of the control transfer in the main loop context.
In this scenario, typical usage would be:
1. Host starts a control transfer with OUT data stage.
2. USBDeviceTasks() (in this scenario, interrupt context) executes.
3. USBDeviceTasks() calls USBCBCheckOtherReq(), which in turn determines that the control transfer is class specific, with
OUT data stage.
4. The user code in USBCBCheckOtherReq() (also in interrupt context, since it is called from USBDeviceTasks(), and
therefore executes at the same priority/context) calls USBDeferOUTDataStage().
5. Meanwhile, in the main loop context, a polling handler may be periodically checking if(USBOUTDataStageDeferred() ==
true). Ordinarily, it would evaluate false, but when a control transfer becomes pending, and after the
USBDeferOUTDataStage() macro has been called (ex: in the interrupt context), the if() statement will evaluate true. In this
case, the main loop context can then take care of receiving the data, by calling USBEP0Receive() and
USBCtrlEPAllowDataStage().
File
usb_device.h
Syntax
bool USBOUTDataStageDeferred();
Function
bool USBOUTDataStageDeferred(void);
1.4.1.1.1.28 USBRxOnePacket Function
Receives the specified data out the specified endpoint
File
usb_device.h
Syntax
USB_HANDLE USBRxOnePacket(uint8_t ep, uint8_t* data, uint16_t len);
Remarks
None
Preconditions
None
1.4 Library Interface MLA - USB Library Help Device/Peripheral
59

- 1
- 2
…
- 57
- 58
- 59
- 60
- 61
…
- 311
- 312