# 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
…
- 35
- 36
- 37
- 38
- 39
…
- 311
- 312

USBCtrlEPAllowDataStage This function allows the data stage of either a host-to-device or
device-to-host control transfer (with data stage) to complete. This
function is meant to be used in conjunction with either the
USBDeferOUTDataStage() or USBDeferINDataStage(). If the
firmware does not call either USBDeferOUTDataStage() or
USBDeferINDataStage(), then the firmware does not need to
manually call USBCtrlEPAllowDataStage(), as the USB stack will
call this function instead.
USBCtrlEPAllowStatusStage This function prepares the proper endpoint 0 IN or endpoint 0 OUT
(based on the controlTransferState) to allow the status stage packet
of a control transfer to complete. This function gets used internally
by the USB stack itself, but it may also be called from the application
firmware, IF the application firmware called the
USBDeferStatusStage() function during the initial processing of the
control transfer request. In this case, the application must call the
USBCtrlEPAllowStatusStage() once, after it has fully completed
processing and handling the data stage portion of the request.
If the application firmware has no need for delaying... more
USBDeferINDataStage This function will cause the USB hardware to continuously NAK the
IN token packets sent from the host, during the data stage of a
device to host control transfer. This allows the firmware more time to
process and prepare the IN data packets that will eventually be sent
to the host. This is also useful, if the firmware needs to
process/prepare the IN data in a different context than what the
USBDeviceTasks() function executes at.
Calling this function (macro) will assert ownership of the currently
pending control transfer. Therefore, the USB stack will not STALL
when it reaches the... more
USBDeferOUTDataStage This function will cause the USB hardware to continuously NAK the
OUT data packets sent from the host, during the data stage of a
device to host control transfer. This allows the firmware more time to
prepare the RAM buffer that will eventually be used to receive the
data from the host. This is also useful, if the firmware wishes to
receive the OUT data in a different context than what the
USBDeviceTasks() function executes at.
Calling this function (macro) will assert ownership of the currently
pending control transfer. Therefore, the USB stack will not STALL
when it reaches... more
USBDeferStatusStage Calling this function will prevent the USB stack from automatically
enabling the status stage for the currently pending control transfer
from completing immediately after all data bytes have been sent or
received. This is useful if a class handler or USB application
firmware project uses control transfers for sending/receiving data
over EP0, but requires time in order to finish processing and/or to
consume the data.
For example: Consider an application which receives OUT data from
the USB host, through EP0 using control transfers. Now assume
that this application wishes to do something time consuming with
this data (ex: transmit it... more
USBDeviceAttach Checks if VBUS is present, and that the USB module is not already
initalized, and if so, enables the USB module so as to signal device
attachment to the USB host.
USBDeviceDetach This function configures the USB module to "soft detach" itself from
the USB host.
USBDeviceInit This function initializes the device stack it in the default state. The
USB module will be completely reset including all of the internal
variables, registers, and interrupt flags.
1.4 Library Interface MLA - USB Library Help Device/Peripheral
37

- 1
- 2
…
- 35
- 36
- 37
- 38
- 39
…
- 311
- 312