Modules | |
USB device API return codes | |
USB device states | |
Classes | |
struct | _USBDDmaDescriptor |
Struct used for USBD DMA Link List Transfer Descriptor, must be 16-bytes aligned. More... | |
struct | _USBDDriver |
struct | _USBDDriverDescriptors |
struct | _USBDTransferBuffer |
Buffer struct used for multi-buffer-listed transfer. More... | |
Typedefs | |
typedef void(* | MblTransferCallback) (void *pArg, uint8_t status) |
typedef void(* | TransferCallback) (void *pArg, uint8_t status, uint32_t transferred, uint32_t remaining) |
typedef struct _USBDDriver | USBDDriver |
USB device driver structure, holding a list of descriptors identifying the device as well as the driver current state. More... | |
typedef struct _USBDDriverDescriptors | USBDDriverDescriptors |
List of all descriptors used by a USB device driver. Each descriptor can be provided in two versions: full-speed and high-speed. Devices which are not high-speed capable do not need to provided high-speed descriptors and the full-speed qualifier & other speed descriptors. More... | |
typedef struct _USBDTransferBuffer | USBDTransferBuffer |
Buffer struct used for multi-buffer-listed transfer. More... | |
Functions | |
struct _USBDDmaDescriptor | __attribute__ ((aligned(16))) USBDDmaDescriptor |
Struct used for USBD DMA Link List Transfer Descriptor, must be 16-bytes aligned. More... | |
static void | GetConfiguration (const USBDDriver *pDriver) |
static void | GetDescriptor (const USBDDriver *pDriver, uint8_t type, uint8_t indexRDesc, uint32_t length) |
static void | GetDeviceStatus (const USBDDriver *pDriver) |
static void | GetEndpointStatus (uint8_t bEndpoint) |
static void | GetInterface (const USBDDriver *pDriver, uint8_t infnum) |
static void | SetConfiguration (USBDDriver *pDriver, uint8_t cfgnum) |
static void | SetInterface (USBDDriver *pDriver, uint8_t infnum, uint8_t setting) |
static void | TerminateCtrlInWithNull (void *pArg, uint8_t status, uint32_t transferred, uint32_t remaining) |
void | USBD_ConfigureEndpoint (const USBEndpointDescriptor *pDescriptor) |
void | USBD_Connect (void) |
void | USBD_Disconnect (void) |
void | USBD_ForceFullSpeed (void) |
USBDDriver * | USBD_GetDriver (void) |
uint8_t | USBD_GetState (void) |
void | USBD_Halt (uint8_t bEndpoint) |
void | USBD_Init (void) |
uint8_t | USBD_IsHalted (uint8_t bEndpoint) |
uint8_t | USBD_IsHighSpeed (void) |
uint8_t | USBD_Read (uint8_t bEndpoint, void *pData, uint32_t dLength, TransferCallback fCallback, void *pArgument) |
void | USBD_RemoteWakeUp (void) |
void | USBD_RequestHandler (uint8_t bEndpoint, const USBGenericRequest *pRequest) |
void | USBD_ResetHandler () |
void | USBD_ResumeHandler (void) |
void | USBD_SetAddress (uint8_t address) |
void | USBD_SetConfiguration (uint8_t cfgnum) |
uint8_t | USBD_Stall (uint8_t bEndpoint) |
void | USBD_SuspendHandler (void) |
void | USBD_Test (uint8_t bIndex) |
void | USBD_Unhalt (uint8_t bEndpoint) |
uint8_t | USBD_Write (uint8_t bEndpoint, const void *pData, uint32_t dLength, TransferCallback fCallback, void *pArgument) |
WEAK void | USBDCallbacks_Initialized (void) |
WEAK void | USBDCallbacks_RequestReceived (const USBGenericRequest *request) |
WEAK void | USBDCallbacks_Reset (void) |
WEAK void | USBDCallbacks_Resumed (void) |
WEAK void | USBDCallbacks_Suspended (void) |
void | USBDDriver_clearOTGFeatures (USBDDriver *pDriver) |
USBConfigurationDescriptor * | USBDDriver_GetCfgDescriptors (USBDDriver *pDriver, uint8_t cfgNum) |
void | USBDDriver_Initialize (USBDDriver *pDriver, const USBDDriverDescriptors *pDescriptors, uint8_t *pInterfaces) |
uint8_t | USBDDriver_IsRemoteWakeUpEnabled (const USBDDriver *pDriver) |
void | USBDDriver_RequestHandler (USBDDriver *pDriver, const USBGenericRequest *pRequest) |
uint8_t | USBDDriver_returnOTGFeatures (const USBDDriver *pDriver) |
static void | USBDDriver_Test (const USBDDriver *pDriver, uint8_t test) |
WEAK void | USBDDriverCallbacks_ConfigurationChanged (uint8_t cfgnum) |
WEAK void | USBDDriverCallbacks_InterfaceSettingChanged (uint8_t interface, uint8_t setting) |
Variables | |
static uint8_t | deviceState |
uint8_t | ForceFS = 0 |
static uint8_t | previousDeviceState |
static USBDDriver | usbdDriver |
typedef void(* MblTransferCallback) (void *pArg, uint8_t status) |
typedef void(* TransferCallback) (void *pArg, uint8_t status, uint32_t transferred, uint32_t remaining) |
USB device driver structure, holding a list of descriptors identifying the device as well as the driver current state.
List of all descriptors used by a USB device driver. Each descriptor can be provided in two versions: full-speed and high-speed. Devices which are not high-speed capable do not need to provided high-speed descriptors and the full-speed qualifier & other speed descriptors.
typedef struct _USBDTransferBuffer USBDTransferBuffer |
Buffer struct used for multi-buffer-listed transfer.
The driver can process 255 bytes of buffers or buffer list window.
struct _USBDDmaDescriptor __attribute__ | ( | (aligned(16)) | ) |
Struct used for USBD DMA Link List Transfer Descriptor, must be 16-bytes aligned.
(For USB, DMA transfer is linked to EPs and FIFO address is EP defined)
|
static |
Sends the current configuration number to the host.
pDriver | Pointer to a USBDDriver instance. |
Definition at line 134 of file USBDDriver.c.
|
static |
Sends the requested USB descriptor to the host if available, or STALLs the request.
pDriver | Pointer to a USBDDriver instance. |
type | Type of the requested descriptor |
index | Index of the requested descriptor. |
length | Maximum number of bytes to return. |
Definition at line 220 of file USBDDriver.c.
|
static |
Sends the current status of the device to the host.
pDriver | Pointer to a USBDDriver instance. |
Definition at line 151 of file USBDDriver.c.
|
static |
Sends the current status of an endpoints to the USB host.
bEndpoint | Endpoint number. |
Definition at line 190 of file USBDDriver.c.
|
static |
Sends the currently active setting of the given interface to the USB host. If alternate settings are not supported, this function STALLs the control pipe.
pDriver | Pointer to a USBDDriver instance. |
infnum | Interface number. |
Definition at line 427 of file USBDDriver.c.
|
static |
Configures the device by setting it into the Configured state and initializing all endpoints.
pDriver | Pointer to a USBDDriver instance. |
cfgnum | Configuration number to set. |
Definition at line 81 of file USBDDriver.c.
|
static |
Sets the active setting of the given interface if the configuration supports it; otherwise, the control pipe is STALLed. If the setting of an interface changes. pDriver Pointer to a USBDDriver instance. infnum Interface number. setting New active setting for the interface.
Definition at line 390 of file USBDDriver.c.
|
static |
Send a NULL packet
Definition at line 61 of file USBDDriver.c.
void USBD_ConfigureEndpoint | ( | const USBEndpointDescriptor * | pDescriptor | ) |
void USBD_Connect | ( | void | ) |
void USBD_Disconnect | ( | void | ) |
USBDDriver * USBD_GetDriver | ( | void | ) |
Return USBDDriver instance pointer for global usage.
Definition at line 549 of file USBDDriver.c.
uint8_t USBD_GetState | ( | void | ) |
void USBD_Halt | ( | uint8_t | bEndpoint | ) |
uint8_t USBD_IsHalted | ( | uint8_t | bEndpoint | ) |
uint8_t USBD_IsHighSpeed | ( | void | ) |
uint8_t USBD_Read | ( | uint8_t | bEndpoint, |
void * | pData, | ||
uint32_t | dLength, | ||
TransferCallback | fCallback, | ||
void * | pArgument | ||
) |
Reads incoming data on an USB endpoint This methods sets the transfer descriptor and activate the endpoint interrupt. The actual transfer is then carried out by the endpoint interrupt handler. The Read operation finishes either when the buffer is full, or a short packet (inferior to endpoint maximum size) is received.
The buffer must be kept allocated until the transfer is finished.
bEndpoint | Endpoint number. |
pData | Pointer to a data buffer. |
dLength | Size of the data buffer in bytes. |
fCallback | Optional end-of-transfer callback function. |
pArgument | Optional argument to the callback function. |
void USBD_RemoteWakeUp | ( | void | ) |
void USBD_RequestHandler | ( | uint8_t | bEndpoint, |
const USBGenericRequest * | pRequest | ||
) |
void USBD_ResetHandler | ( | void | ) |
void USBD_ResumeHandler | ( | void | ) |
void USBD_SetAddress | ( | uint8_t | address | ) |
void USBD_SetConfiguration | ( | uint8_t | cfgnum | ) |
uint8_t USBD_Stall | ( | uint8_t | bEndpoint | ) |
void USBD_SuspendHandler | ( | void | ) |
void USBD_Test | ( | uint8_t | bIndex | ) |
void USBD_Unhalt | ( | uint8_t | bEndpoint | ) |
uint8_t USBD_Write | ( | uint8_t | bEndpoint, |
const void * | pData, | ||
uint32_t | dLength, | ||
TransferCallback | fCallback, | ||
void * | pArgument | ||
) |
Sends data through a USB endpoint. Sets up the transfer descriptor, writes one or two data payloads (depending on the number of FIFO bank for the endpoint) and then starts the actual transfer. The operation is complete when all the data has been sent.
If the size of the buffer is greater than the size of the endpoint (or twice the size if the endpoint has two FIFO banks), then the buffer must be kept allocated until the transfer is finished. This means that it is not possible to declare it on the stack (i.e. as a local variable of a function which returns after starting a transfer).
bEndpoint | Endpoint number. |
pData | Pointer to a buffer with the data to send. |
dLength | Size of the data buffer. |
fCallback | Optional callback function to invoke when the transfer is complete. |
pArgument | Optional argument to the callback function. |
WEAK void USBDCallbacks_Initialized | ( | void | ) |
Invoked after the USB driver has been initialized. By default, do nothing.
Definition at line 54 of file USBDCallbacks.c.
WEAK void USBDCallbacks_RequestReceived | ( | const USBGenericRequest * | request | ) |
USBDCallbacks_RequestReceived - Invoked when a new SETUP request is received. Does nothing by default.
request | Pointer to the request to handle. |
Definition at line 83 of file USBDCallbacks.c.
WEAK void USBDCallbacks_Reset | ( | void | ) |
Invoked when the USB driver is reset. Does nothing by default.
Definition at line 62 of file USBDCallbacks.c.
WEAK void USBDCallbacks_Resumed | ( | void | ) |
Invoked when the USB device leaves the Suspended state. By default, Do nothing.
Definition at line 76 of file USBDCallbacks.c.
WEAK void USBDCallbacks_Suspended | ( | void | ) |
Invoked when the USB device gets suspended. By default, do nothing.
Definition at line 70 of file USBDCallbacks.c.
void USBDDriver_clearOTGFeatures | ( | USBDDriver * | pDriver | ) |
Clear OTG features supported
pDriver | Pointer to an USBDDriver instance. |
Definition at line 841 of file USBDDriver.c.
USBConfigurationDescriptor * USBDDriver_GetCfgDescriptors | ( | USBDDriver * | pDriver, |
uint8_t | cfgNum | ||
) |
Returns configuration descriptor list.
pDriver | Pointer to a USBDDriver instance. |
cfgNum | Reserved. |
Definition at line 587 of file USBDDriver.c.
void USBDDriver_Initialize | ( | USBDDriver * | pDriver, |
const USBDDriverDescriptors * | pDescriptors, | ||
uint8_t * | pInterfaces | ||
) |
Initializes a USBDDriver instance with a list of descriptors. If interfaces can have multiple alternate settings, an array to store the current setting for each interface must be provided.
pDriver | Pointer to a USBDDriver instance. |
pDescriptors | Pointer to a USBDDriverDescriptors instance. |
pInterfaces | Pointer to an array for storing the current alternate setting of each interface (optional). |
Definition at line 563 of file USBDDriver.c.
uint8_t USBDDriver_IsRemoteWakeUpEnabled | ( | const USBDDriver * | pDriver | ) |
Test if RemoteWakeUP feature is enabled
pDriver | Pointer to an USBDDriver instance. |
Definition at line 821 of file USBDDriver.c.
void USBDDriver_RequestHandler | ( | USBDDriver * | pDriver, |
const USBGenericRequest * | pRequest | ||
) |
Handles the given request if it is standard, otherwise STALLs it.
pDriver | Pointer to a USBDDriver instance. |
pRequest | Pointer to a USBGenericRequest instance. |
Definition at line 609 of file USBDDriver.c.
uint8_t USBDDriver_returnOTGFeatures | ( | const USBDDriver * | pDriver | ) |
Return OTG features supported
pDriver | Pointer to an USBDDriver instance. |
Definition at line 831 of file USBDDriver.c.
|
static |
Performs the selected test on the USB device (high-speed only).
test | Test selector value. |
Definition at line 448 of file USBDDriver.c.
void USBDDriverCallbacks_ConfigurationChanged | ( | uint8_t | cfgnum | ) |
Indicates that the current configuration of the device has changed.
cfgnum | New device configuration index. |
Definition at line 65 of file USBDDriverCallbacks.c.
void USBDDriverCallbacks_InterfaceSettingChanged | ( | uint8_t | interface, |
uint8_t | setting | ||
) |
Notifies of a change in the currently active setting of an interface.
interface | Number of the interface whose setting has changed. |
setting | New interface setting. |
Definition at line 76 of file USBDDriverCallbacks.c.
|
static |
|
static |
Default device driver instance, for all class drivers in USB Lib.
Definition at line 52 of file USBDDriver.c.