User API reference of the USB Device Core. More...
Functions | |
uint32_t | USBD_GetVersion (void) |
Get version of USB Device stack. | |
usbStatus | USBD_Initialize (uint8_t device) |
Initialize USB Device stack and controller. | |
usbStatus | USBD_Uninitialize (uint8_t device) |
De-initialize USB Device stack and controller. | |
usbStatus | USBD_Connect (uint8_t device) |
Activate pull-up on D+ or D- line to signal USB Device connection on USB Bus. | |
usbStatus | USBD_Disconnect (uint8_t device) |
Disconnect USB Device from USB Bus. | |
bool | USBD_Configured (uint8_t device) |
Retrieve USB Device configuration status. | |
USBD_STATE | USBD_GetState (uint8_t device) |
Retrieve USB Device state. | |
usbStatus | USBD_SetSerialNumber (uint8_t device, const char *string) |
Set USB Device serial number string. | |
void | USBD_Devicen_Initialize (void) |
Callback function called during USBD_Initialize to initialize the USB Device. | |
void | USBD_Devicen_Uninitialize (void) |
Callback function called during USBD_Uninitialize to de-initialize the USB Device. | |
void | USBD_Devicen_VbusChanged (bool level) |
Callback function called when VBUS level changes. | |
void | USBD_Devicen_Reset (void) |
Callback function called upon USB Bus Reset signaling. | |
void | USBD_Devicen_HighSpeedActivated (void) |
Callback function called when USB Bus speed has changed to high-speed. | |
void | USBD_Devicen_Suspended (void) |
Callback function called when USB Bus goes into suspend mode (no bus activity for 3 ms) | |
void | USBD_Devicen_Resumed (void) |
Callback function called when USB Bus activity has resumed. | |
void | USBD_Devicen_ConfigurationChanged (uint8_t val) |
Callback function called when Device configuration has changed. | |
void | USBD_Devicen_EnableRemoteWakeup (void) |
Callback function called when Set Feature for Remote Wakeup was requested over Control Endpoint 0. | |
void | USBD_Devicen_DisableRemoteWakeup (void) |
Callback function called when Clear Feature for Remote Wakeup was requested over Control Endpoint 0. | |
usbdRequestStatus | USBD_Devicen_Endpoint0_SetupPacketReceived (const USB_SETUP_PACKET *setup_packet, uint8_t **buf, uint32_t *len) |
Callback function called when Device received SETUP PACKET on Control Endpoint 0. | |
void | USBD_Devicen_Endpoint0_SetupPacketProcessed (const USB_SETUP_PACKET *setup_packet) |
Callback function called when SETUP PACKET was processed by USB library. | |
usbdRequestStatus | USBD_Devicen_Endpoint0_OutDataReceived (uint32_t len) |
Callback function called when Device received OUT DATA on Control Endpoint 0. | |
usbdRequestStatus | USBD_Devicen_Endpoint0_InDataSent (uint32_t len) |
Callback function called when Device sent IN DATA on Control Endpoint 0. | |
User API reference of the USB Device Core.
For a general function overview refer to the section Core.
bool USBD_Configured | ( | uint8_t | device | ) |
Retrieve USB Device configuration status.
[in] | device | index of USB Device. |
The function USBD_Configured retrieves the configuration status of the USB Device. It determines whether the USB Device has been configured and is ready to communicate.
The argument device specifies the instance of the USB Device.
usbStatus USBD_Connect | ( | uint8_t | device | ) |
Activate pull-up on D+ or D- line to signal USB Device connection on USB Bus.
[in] | device | index of USB Device. |
The function USBD_Connect connects the USB Device to the USB Bus. This typically initiates the enumeration on the USB Host side for the USB Device.
The argument device specifies the instance of the USB Device.
Code Example
void USBD_Devicen_ConfigurationChanged | ( | uint8_t | val | ) |
Callback function called when Device configuration has changed.
[in] | val | current configuration value :
|
The callback function USBD_Devicen_ConfigurationChanged is called when the USB Device Instance n was requested by the USB Host to change the configuration.
The argument val specifies the activated configuration.
This function can be modified in the user code template file USBD_User_Device_n.c.
void USBD_Devicen_DisableRemoteWakeup | ( | void | ) |
Callback function called when Clear Feature for Remote Wakeup was requested over Control Endpoint 0.
The callback function USBD_Devicen_DisableRemoteWakeup is called when the USB Device Instance n receives Clear Feature request on the Control Endpoint 0 to disable remote wakeup feature on the device.
This function can be modified in the user code template file USBD_User_Device_n.c.
void USBD_Devicen_EnableRemoteWakeup | ( | void | ) |
Callback function called when Set Feature for Remote Wakeup was requested over Control Endpoint 0.
The callback function USBD_Devicen_EnableRemoteWakeup is called when the USB Device Instance n receives Set Feature request on the Control Endpoint 0 to enable remote wakeup feature on the device.
This function can be modified in the user code template file USBD_User_Device_n.c.
usbdRequestStatus USBD_Devicen_Endpoint0_InDataSent | ( | uint32_t | len | ) |
Callback function called when Device sent IN DATA on Control Endpoint 0.
[in] | len | number of sent data bytes. |
The callback function USBD_Devicen_Endpoint0_InDataSent is called when the USB Device sent IN DATA on Control Endpoint 0.
The argument len specifies the number of sent data bytes.
This function can be modified in the user code template file USBD_User_Device_n.c.
usbdRequestStatus USBD_Devicen_Endpoint0_OutDataReceived | ( | uint32_t | len | ) |
Callback function called when Device received OUT DATA on Control Endpoint 0.
[in] | len | number of received data bytes. |
The callback function USBD_Devicen_Endpoint0_OutDataReceived is called when the USB Device received an OUT DATA on Control Endpoint 0.
The argument len specifies the number of received data bytes.
This function can be modified in the user code template file USBD_User_Device_n.c.
void USBD_Devicen_Endpoint0_SetupPacketProcessed | ( | const USB_SETUP_PACKET * | setup_packet | ) |
Callback function called when SETUP PACKET was processed by USB library.
[in] | setup_packet | pointer to processed setup packet. |
The callback function USBD_Devicen_Endpoint0_SetupPacketProcessed is called when a SETUP PACKET was processed by the USB Component.
The argument setup_packet is a pointer to the processed setup packet.
This function can be modified in the user code template file USBD_User_Device_n.c.
Code Example
usbdRequestStatus USBD_Devicen_Endpoint0_SetupPacketReceived | ( | const USB_SETUP_PACKET * | setup_packet, |
uint8_t ** | buf, | ||
uint32_t * | len | ||
) |
Callback function called when Device received SETUP PACKET on Control Endpoint 0.
[in] | setup_packet | pointer to received setup packet. |
[in,out] | buf | pointer to data buffer used for data stage requested by setup packet. |
[in,out] | len | pointer to number of data bytes in data stage requested by setup packet. |
The callback function USBD_Devicen_Endpoint0_SetupPacketReceived is called when the USB Device Instance n received a SETUP PACKET on Control Endpoint 0.
The argument setup_packet is a pointer to the received setup packet.
The argument buf is a pointer to the data buffer that is used for data stage requested by setup packet.
The argument len is a pointer to the number of data bytes in the data stage requested by setup packet.
This function can be modified in the user code template file USBD_User_Device_n.c.
Code Example
void USBD_Devicen_HighSpeedActivated | ( | void | ) |
Callback function called when USB Bus speed has changed to high-speed.
The callback function USBD_Devicen_HighSpeedActivated is called when the bus speed of the USB Device Instance n changes to high speed.
This function can be modified in the user code template file USBD_User_Device_n.c.
void USBD_Devicen_Initialize | ( | void | ) |
Callback function called during USBD_Initialize to initialize the USB Device.
If available, the function USBD_Devicen_Initialize is called automatically upon initialization of the USB Device and needs no invocation in the user code. Modify this function for custom USB Device handling. This function can be modified in the user code template file USBD_User_Device_n.c.
Code Example
void USBD_Devicen_Reset | ( | void | ) |
Callback function called upon USB Bus Reset signaling.
The callback function USBD_Devicen_Reset is called when reset signaling was detected by the USB Device Instance n.
This function can be modified in the user code template file USBD_User_Device_n.c.
void USBD_Devicen_Resumed | ( | void | ) |
Callback function called when USB Bus activity has resumed.
The callback function USBD_Devicen_Resumed is called when bus activity has been resumed by the USB Device Instance n.
This function can be modified in the user code template file USBD_User_Device_n.c.
void USBD_Devicen_Suspended | ( | void | ) |
Callback function called when USB Bus goes into suspend mode (no bus activity for 3 ms)
The callback function USBD_Devicen_Suspended is called when bus of the USB Device Instance n was suspended (no SOFs for 3 ms).
This function can be modified in the user code template file USBD_User_Device_n.c.
void USBD_Devicen_Uninitialize | ( | void | ) |
Callback function called during USBD_Uninitialize to de-initialize the USB Device.
If available, the function USBD_Devicen_Uninitialize is called automatically upon un-initialization of the USB Device and needs no invocation in the user code. Modify this function for custom USB Device handling. This function can be found in the user code template file USBD_User_Device_n.c.
Code Example
void USBD_Devicen_VbusChanged | ( | bool | level | ) |
Callback function called when VBUS level changes.
[in] | level | current VBUS level :
|
The callback function USBD_Devicen_VbusChanged is called when the state of the VBUS pin of the USB Device Instance n changes level.
This function can be modified in the user code template file USBD_User_Device_n.c.
usbStatus USBD_Disconnect | ( | uint8_t | device | ) |
Disconnect USB Device from USB Bus.
[in] | device | index of USB Device. |
The function USBD_Disconnect disconnects the USB Device from the USB Bus. After executing this function the USB Device can no longer be accessed from the USB Host.
The argument device specifies the instance of the USB Device.
USBD_STATE USBD_GetState | ( | uint8_t | device | ) |
Retrieve USB Device state.
[in] | device | index of USB Device. |
The function USBD_GetState retrieves the bus state of the USB Device. It determines whether the USB Device has valid VBUS, on which speed it was enumerated and if it is active on the bus.
The argument device specifies the instance of the USB Device.
uint32_t USBD_GetVersion | ( | void | ) |
Get version of USB Device stack.
The function USBD_GetVersion retrieves version of the USB Device Component.
Version is encoded as follows:
usbStatus USBD_Initialize | ( | uint8_t | device | ) |
Initialize USB Device stack and controller.
[in] | device | index of USB Device. |
The function USBD_Initialize initializes the USB Device Controller Core and Hardware Driver (such as the USB clock and pins). It starts all the tasks and sets up the main USB interrupt service routine. In any application, the USBD_Initialize function must be called before invoking any other USB Device function. The function does not initialize any non-USB hardware features.
The argument device specifies the instance of the USB Device.
Code Example
usbStatus USBD_SetSerialNumber | ( | uint8_t | device, |
const char * | string | ||
) |
Set USB Device serial number string.
[in] | device | index of USB Device. |
[in] | string | serial number string. |
The function USBD_SetSerialNumber is used to set Serial Number String of the USB Device during run-time. This function should be called before USBD_Connect function.
The argument device specifies the instance of the USB Device.
The argument string is a pointer to the new string to be used for Serial Number.
Code Example
usbStatus USBD_Uninitialize | ( | uint8_t | device | ) |
De-initialize USB Device stack and controller.
[in] | device | index of USB Device. |
De-initialize the USB Device Controller Core and Hardware Driver. Invoke this function when USB is not to be used any more.
The argument device specifies the instance of the USB Device.