# 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
…
- 55
- 56
- 57
- 58
- 59
…
- 311
- 312

Return Values
Return Values Description
uint16_t length of the current buffer that the input handle points to. If
the transfer is complete then this is the length of the data
transmitted or the length of data actually received.
Function
uint16_t USBHandleGetLength( USB_HANDLE handle)
1.4.1.1.1.24 USBINDataStageDeferred Function
Returns true if a control transfer with IN data stage is pending, and the firmware has called USBDeferINDataStage(), but has
not yet called USBCtrlEPAllowDataStage(). Returns false if a control transfer with IN data stage is either not pending, or the
firmware did not call USBDeferINDataStage() 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 IN 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
IN 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 USBDeferINDataStage().
5. Meanwhile, in the main loop context, a polling handler may be periodically checking if(USBINDataStageDeferred() ==
true). Ordinarily, it would evaluate false, but when a control transfer becomes pending, and after the
USBDeferINDataStage() 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 sending the data (when ready), by calling USBEP0SendRAMPtr() or
USBEP0SendROMPtr() and USBCtrlEPAllowDataStage().
File
usb_device.h
Syntax
bool USBINDataStageDeferred();
Function
bool USBINDataStageDeferred(void);
1.4.1.1.1.25 USBIsBusSuspended Function
This function indicates if the USB bus is in suspend mode.
File
usb_device.h
Syntax
bool USBIsBusSuspended();
1.4 Library Interface MLA - USB Library Help Device/Peripheral
57

- 1
- 2
…
- 55
- 56
- 57
- 58
- 59
…
- 311
- 312