USB Component
Version 6.17.0
MDK Middleware for USB Device and Host Communication
|
User API reference of the USB Host Core. More...
Functions | |
uint32_t | USBH_GetVersion (void) |
Get version of USB Host stack. More... | |
usbStatus | USBH_Initialize (uint8_t ctrl) |
Initialize USB Host stack and controller. More... | |
usbStatus | USBH_Uninitialize (uint8_t ctrl) |
De-initialize USB Host stack and controller. More... | |
usbStatus | USBH_Port_Suspend (uint8_t ctrl, uint8_t port) |
Suspend a root HUB port on specified controller. More... | |
usbStatus | USBH_Port_Resume (uint8_t ctrl, uint8_t port) |
Resume a root HUB port on specified controller. More... | |
uint8_t | USBH_Device_GetController (uint8_t device) |
Get index of USB Host controller to which USB Device is connected. More... | |
uint8_t | USBH_Device_GetPort (uint8_t device) |
Get index of USB Host Root HUB port to which USB Device is connected. More... | |
usbStatus | USBH_Device_GetStatus (uint8_t device) |
Get status of USB Device. More... | |
int32_t | USBH_Device_GetSpeed (uint8_t device) |
Get communication speed of USB Device. More... | |
uint8_t | USBH_Device_GetAddress (uint8_t device) |
Get communication address of USB Device. More... | |
uint16_t | USBH_Device_GetVID (uint8_t device) |
Get Vendor ID (VID) of USB Device. More... | |
uint16_t | USBH_Device_GetPID (uint8_t device) |
Get Product ID (PID) of USB Device. More... | |
usbStatus | USBH_Device_GetStringDescriptor (uint8_t device, uint8_t index, uint16_t language_id, uint8_t *descriptor_data, uint16_t descriptor_length) |
Get String Descriptor of USB Device. More... | |
void | USBH_Notify (uint8_t ctrl, uint8_t port, uint8_t device, USBH_NOTIFY notify) |
Callback function called when some event has happened on corresponding controller and port. More... | |
User API reference of the USB Host Core.
uint32_t USBH_GetVersion | ( | void | ) |
Get version of USB Host stack.
The function USBH_GetVersion retrieves version of the USB Host library.
Version is encoded as follows:
usbStatus USBH_Initialize | ( | uint8_t | ctrl | ) |
Initialize USB Host stack and controller.
[in] | ctrl | index of USB Host controller. |
The function USBH_Initialize initializes the USB Host Stack and the USB Host Controller Hardware and prepares the USB Host Controller to detect whether an USB device gets attached or detached from the USB bus. It starts a thread responsible for the USB Device enumeration process. Call this function before calling any other USB Host functions. The function does not initialize any non-USB Host hardware features.
Code Example
usbStatus USBH_Uninitialize | ( | uint8_t | ctrl | ) |
De-initialize USB Host stack and controller.
[in] | ctrl | index of USB Host controller. |
The function USBH_Uninitialize de-initializes the USB Host Stack and the USB Host Controller Hardware. It can be used if during the application run-time the USB Host Stack needs to be disabled for whatever reason (for example for lowering power consumption). Reinitialize the USB Host Stack only with USBH_Initialize.
Code Example
usbStatus USBH_Port_Suspend | ( | uint8_t | ctrl, |
uint8_t | port | ||
) |
Suspend a root HUB port on specified controller.
[in] | ctrl | index of USB Host controller. |
[in] | port | root HUB port. |
The function USBH_Port_Suspend suspends the USB bus, stops generating Start Of Frame or Keep-Alive signals.
The argument ctrl specifies the USB Host controller number.
The argument port specifies the USB Host root HUB port number.
usbStatus USBH_Port_Resume | ( | uint8_t | ctrl, |
uint8_t | port | ||
) |
Resume a root HUB port on specified controller.
[in] | ctrl | index of USB Host controller. |
[in] | port | root HUB port. |
The function USBH_Port_Resume re-activates the USB bus from suspended state, starts generating Start Of Frame or Keep-Alive signals.
The argument ctrl specifies the USB Host controller number.
The argument port specifies the USB Host root HUB port number.
uint8_t USBH_Device_GetController | ( | uint8_t | device | ) |
Get index of USB Host controller to which USB Device is connected.
[in] | device | index of USB Device. |
The function USBH_Device_GetController retrieves the USB Host controller index to which the requested device is connected to.
The argument device specifies the instance of the device.
uint8_t USBH_Device_GetPort | ( | uint8_t | device | ) |
Get index of USB Host Root HUB port to which USB Device is connected.
[in] | device | index of USB Device. |
The function USBH_Device_GetPort retrieves the USB Host root HUB port index to which the requested device is connected to.
The argument device specifies the instance of the device.
usbStatus USBH_Device_GetStatus | ( | uint8_t | device | ) |
Get status of USB Device.
[in] | device | index of USB Device. |
The function USBH_Device_GetStatus checks if a device instance is connected and initialized.
The argument device specifies the instance of the device.
int32_t USBH_Device_GetSpeed | ( | uint8_t | device | ) |
Get communication speed of USB Device.
[in] | device | index of USB Device. |
The function USBH_Device_GetSpeed retrieves current communication speed of the connected device.
The argument device specifies the instance of the device.
int32_t USBH_Device_GetAddress | ( | uint8_t | device | ) |
Get communication address of USB Device.
[in] | device | index of USB Device. |
The function USBH_Device_GetAddress retrieves current communication address of the connected device.
The argument device specifies the instance of the device.
uint16_t USBH_Device_GetVID | ( | uint8_t | device | ) |
Get Vendor ID (VID) of USB Device.
[in] | device | index of USB Device. |
The function USBH_Device_GetVID retrieves Vendor ID of the connected device.
The argument device specifies the instance of the device.
uint16_t USBH_Device_GetPID | ( | uint8_t | device | ) |
Get Product ID (PID) of USB Device.
[in] | device | index of USB Device. |
The function USBH_Device_GetPID retrieves Product ID of the connected device.
The argument device specifies the instance of the device.
usbStatus USBH_Device_GetStringDescriptor | ( | uint8_t | device, |
uint8_t | index, | ||
uint16_t | language_id, | ||
uint8_t * | descriptor_data, | ||
uint16_t | descriptor_length | ||
) |
Get String Descriptor of USB Device.
[in] | device | index of USB Device. |
[in] | index | index of string descriptor. |
[in] | language_id | language ID. |
[out] | descriptor_data | pointer to where descriptor data will be read. |
[in] | descriptor_length | maximum descriptor length. |
The function USBH_Device_GetStringDescriptor is used for retrieving string descriptor form the device and is implemented with standard device request GET_DESCRIPTOR
. This request returns the specified string descriptor if the descriptor exists.
The argument device specifies the instance of the device.
The argument index specifies the string descriptor index.
The argument language_id specifies the Language ID of string descriptor.
The argument descriptor_data is a pointer to where descriptor data will be read and descriptor_length specifies the number of bytes to return.
void USBH_Notify | ( | uint8_t | ctrl, |
uint8_t | port, | ||
uint8_t | device, | ||
USBH_NOTIFY | notify | ||
) |
Callback function called when some event has happened on corresponding controller and port.
[in] | ctrl | index of USB Host controller. |
[in] | port | index of Root HUB port. |
[in] | device | index of USB Device :
|
[in] | notify | notification :
|
The function USBH_Notify is called from the USB Host Core module on any of the available notification events. For example, when a device is connected to a USB port, this function will get called with the notification value USBH_NOTIFY_CONNECT.
The argument ctrl specifies the USB Host controller number.
The argument port specifies the USB Host root HUB port number.
The argument device specifies the instance of the device.
The argument notify specifies the type of event that has occurred.
Code Example