# 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
…
- 60
- 61
- 62
- 63
- 64
…
- 311
- 312

USBInHandle =
USBTransferOnePacket(EP_NUM,IN_TO_HOST,(uint8_t*)&INPacket[0],sizeof(INPacket));
}
}
Remarks
If calling the USBTransferOnePacket() function from within the USBCBInitEP() callback function, the set configuration is still
being processed and the USBDeviceState may not be == CONFIGURED_STATE yet. In this special case, the
USBTransferOnePacket() may still be called, but make sure that the endpoint has been enabled and initialized by the
USBEnableEndpoint() function first.
Preconditions
Before calling USBTransferOnePacket(), the following should be true.
1. The USB stack has already been initialized (USBDeviceInit() was called).
2. A transaction is not already pending on the specified endpoint. This is done by checking the previous request using the
USBHandleBusy() macro (see the typical usage example).
3. The host has already sent a set configuration request and the enumeration process is complete. This can be checked by
verifying that the USBGetDeviceState() macro returns "CONFIGURED_STATE", prior to calling USBTransferOnePacket().
Parameters
Parameters Description
uint8_t ep The endpoint number that the data will be transmitted or
received on
uint8_t dir The direction of the transfer This value is either
OUT_FROM_HOST or IN_TO_HOST
uint8_t* data For IN transactions: pointer to the RAM buffer containing
the data to be sent to the host. For OUT transactions pointer to the RAM buffer that the received data should get
written to.
uint8_t len Length of the data needing to be sent (for IN transactions).
For OUT transactions, the len parameter should normally be
set to the endpoint size specified in the endpoint descriptor.
Return Values
Return Values Description
USB_HANDLE handle to the transfer. The handle is a pointer to the BDT
entry associated with this transaction. The
status of the transaction (ex if it is complete or still pending) can be checked using the
USBHandleBusy() macro and supplying the USB_HANDLE
provided by USBTransferOnePacket().
Function
USB_HANDLE USBTransferOnePacket(uint8_t ep, uint8_t dir, uint8_t* data, uint8_t len)
1.4.1.1.1.32 USBTxOnePacket Function
Sends the specified data out the specified endpoint
File
usb_device.h
Syntax
USB_HANDLE USBTxOnePacket(uint8_t ep, uint8_t* data, uint16_t len);
Remarks
None
1.4 Library Interface MLA - USB Library Help Device/Peripheral
62

- 1
- 2
…
- 60
- 61
- 62
- 63
- 64
…
- 311
- 312