User API reference of the Custom Class. More...
Functions | |
uint8_t | USBH_CustomClass_GetDevice (uint8_t instance) |
Get Device instance of Custom Class Device. | |
usbStatus | USBH_CustomClass_GetStatus (uint8_t instance) |
Get status of Custom Class Device. | |
uint8_t | USBH_CustomClass_Configure (uint8_t device, const USB_DEVICE_DESCRIPTOR *ptr_dev_desc, const USB_CONFIGURATION_DESCRIPTOR *ptr_cfg_desc) |
Callback function called when custom class device is connected and needs to configure resources used by custom class device instance. | |
usbStatus | USBH_CustomClass_Unconfigure (uint8_t instance) |
Callback function called when custom class device is disconnected and needs to de-configure resources used by custom class device instance. | |
usbStatus | USBH_CustomClass_Initialize (uint8_t instance) |
Callback function called when custom class device is connected and needs to initialize custom class device instance. | |
usbStatus | USBH_CustomClass_Uninitialize (uint8_t instance) |
Callback function called when custom class device is disconnected and needs to de-initialize custom class device instance. | |
USBH_PIPE_HANDLE | USBH_PipeCreate (uint8_t device, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_max_packet_size, uint8_t ep_interval) |
Create Pipe. | |
usbStatus | USBH_PipeRegisterCallback (USBH_PIPE_HANDLE pipe_hndl, USBH_PipeEvent_t cb_pipe_event) |
Register a callback for Pipe events. | |
usbStatus | USBH_PipeUpdate (USBH_PIPE_HANDLE pipe_hndl) |
Update Pipe. | |
usbStatus | USBH_PipeDelete (USBH_PIPE_HANDLE pipe_hndl) |
Delete Pipe. | |
usbStatus | USBH_PipeReset (USBH_PIPE_HANDLE pipe_hndl) |
Reset Pipe (reset data toggle) | |
usbStatus | USBH_PipeReceive (USBH_PIPE_HANDLE pipe_hndl, uint8_t *buf, uint32_t len) |
Receive data on Pipe. | |
uint32_t | USBH_PipeReceiveGetResult (USBH_PIPE_HANDLE pipe_hndl) |
Get result of receive data operation on Pipe. | |
usbStatus | USBH_PipeSend (USBH_PIPE_HANDLE pipe_hndl, const uint8_t *buf, uint32_t len) |
Send data on Pipe. | |
uint32_t | USBH_PipeSendGetResult (USBH_PIPE_HANDLE pipe_hndl) |
Get result of send data operation on Pipe. | |
usbStatus | USBH_PipeAbort (USBH_PIPE_HANDLE pipe_hndl) |
Abort send/receive operation on Pipe. | |
usbStatus | USBH_ControlTransfer (uint8_t device, const USB_SETUP_PACKET *setup_packet, uint8_t *data, uint32_t len) |
Do a Control Transfer on Default Pipe. | |
usbStatus | USBH_DeviceRequest_GetStatus (uint8_t device, uint8_t recipient, uint8_t index, uint8_t *ptr_stat_dat) |
Standard Device Request on Default Pipe - GET_STATUS. | |
usbStatus | USBH_DeviceRequest_ClearFeature (uint8_t device, uint8_t recipient, uint8_t index, uint8_t feature_selector) |
Standard Device Request on Default Pipe - CLEAR_FEATURE. | |
usbStatus | USBH_DeviceRequest_SetFeature (uint8_t device, uint8_t recipient, uint8_t index, uint8_t feature_selector) |
Standard Device Request on Default Pipe - SET_FEATURE. | |
usbStatus | USBH_DeviceRequest_SetAddress (uint8_t device, uint8_t device_address) |
Standard Device Request on Default Pipe - SET_ADDRESS. | |
usbStatus | USBH_DeviceRequest_GetDescriptor (uint8_t device, uint8_t recipient, uint8_t descriptor_type, uint8_t descriptor_index, uint16_t language_id, uint8_t *descriptor_data, uint16_t descriptor_length) |
Standard Device Request on Default Pipe - GET_DESCRIPTOR. | |
usbStatus | USBH_DeviceRequest_SetDescriptor (uint8_t device, uint8_t recipient, uint8_t descriptor_type, uint8_t descriptor_index, uint16_t language_id, const uint8_t *descriptor_data, uint16_t descriptor_length) |
Standard Device Request on Default Pipe - SET_DESCRIPTOR. | |
usbStatus | USBH_DeviceRequest_GetConfiguration (uint8_t device, uint8_t *ptr_configuration) |
Standard Device Request on Default Pipe - GET_CONFIGURATION. | |
usbStatus | USBH_DeviceRequest_SetConfiguration (uint8_t device, uint8_t configuration) |
Standard Device Request on Default Pipe - SET_CONFIGURATION. | |
usbStatus | USBH_DeviceRequest_GetInterface (uint8_t device, uint8_t index, uint8_t *ptr_alternate) |
Standard Device Request on Default Pipe - GET_INTERFACE. | |
usbStatus | USBH_DeviceRequest_SetInterface (uint8_t device, uint8_t index, uint8_t alternate) |
Standard Device Request on Default Pipe - SET_INTERFACE. | |
usbStatus | USBH_DeviceRequest_SynchFrame (uint8_t device, uint8_t index, uint8_t *ptr_frame_number) |
Standard Device Request on Default Pipe - SYNCH_FRAME. | |
User API reference of the Custom Class.
usbStatus USBH_ControlTransfer | ( | uint8_t | device, |
const USB_SETUP_PACKET * | setup_packet, | ||
uint8_t * | data, | ||
uint32_t | len | ||
) |
Do a Control Transfer on Default Pipe.
[in] | device | index of USB Device. |
[in] | setup_packet | pointer to setup packet. |
[in,out] | data | buffer containing data bytes to send or where data should be received in data stage of Control Transfer. |
[in] | len | number of bytes to send or receive in data stage of Control Transfer. |
The function USBH_ControlTransfer does an Control Transfer on the Default Pipe.
The argument device is the index of the USB Device to which Control Transfer is addressed.
The argument setup_packet pointer to setup packet.
The argument data containing data bytes to send or where data should be received in data stage of Control Transfer.
The argument len number of bytes to send or receive in data stage of Control Transfer.
Code Example
uint8_t USBH_CustomClass_Configure | ( | uint8_t | device, |
const USB_DEVICE_DESCRIPTOR * | ptr_dev_desc, | ||
const USB_CONFIGURATION_DESCRIPTOR * | ptr_cfg_desc | ||
) |
Callback function called when custom class device is connected and needs to configure resources used by custom class device instance.
[in] | device | index of USB Device. |
[in] | ptr_dev_desc | pointer to device descriptor. |
[in] | ptr_cfg_desc | pointer to configuration descriptor. |
The function USBH_CustomClass_Configure should create all necessary pipes for the custom class. It needs to be adapted to the specific needs of the Custom Class that is to be supported. For more information on the USB_DEVICE_DESCRIPTOR
, please refer to Device Descriptor. For more information on the USB_CONFIGURATION_DESCRIPTOR
, please refer to Configuration Descriptor.
The argument device specifies the instance of the connected device.
The argument ptr_dev_desc specifies the pointer to the device descriptor (Device Descriptor) of the Custom Class.
The argument ptr_cfg_desc specifies the pointer to the configuration descriptor (Configuration Descriptor) of the Custom Class.
Code Example
uint8_t USBH_CustomClass_GetDevice | ( | uint8_t | instance | ) |
Get Device instance of Custom Class Device.
[in] | instance | instance of Custom Class Device. |
The function USBH_CustomClass_GetDevice is used to retrieve device instance that is used to handle custom class device instance.
The argument instance specifies the custom class device instance.
usbStatus USBH_CustomClass_GetStatus | ( | uint8_t | instance | ) |
Get status of Custom Class Device.
[in] | instance | instance of Custom Class Device. |
The function USBH_CustomClass_GetStatus checks if a custom class device is connected and initialized.
The argument instance specifies the custom class device instance.
usbStatus USBH_CustomClass_Initialize | ( | uint8_t | instance | ) |
Callback function called when custom class device is connected and needs to initialize custom class device instance.
[in] | instance | index of custom class device instance. |
The function USBH_CustomClass_Initialize initializes the Custom Class device when connected to the system. It needs to be adapted to the specific needs of the Custom Class that is to be supported.
The argument instance specifies device instance of the Custom Class USB Device.
Code Example
usbStatus USBH_CustomClass_Unconfigure | ( | uint8_t | instance | ) |
Callback function called when custom class device is disconnected and needs to de-configure resources used by custom class device instance.
[in] | instance | index of custom class device instance. |
The function USBH_CustomClass_Unconfigure should release all resources that were used by the Custom Class device after it has been de-initialized using USBH_CustomClass_Uninitialize. All pipes relating to the Custom Class should be removed. It needs to be adapted to the specific needs of the Custom Class that is to be supported.
The argument instance specifies device instance of the Custom Class USB Device.
Code Example
usbStatus USBH_CustomClass_Uninitialize | ( | uint8_t | instance | ) |
Callback function called when custom class device is disconnected and needs to de-initialize custom class device instance.
[in] | instance | index of custom class device instance. |
The function USBH_CustomClass_Uninitialize de-initializes the Custom Class device after it has been disconnected from the system. It needs to be adapted to the specific needs of the Custom Class that is to be supported.
The argument instance specifies device instance of the Custom Class USB Device.
Code Example
usbStatus USBH_DeviceRequest_ClearFeature | ( | uint8_t | device, |
uint8_t | recipient, | ||
uint8_t | index, | ||
uint8_t | feature_selector | ||
) |
Standard Device Request on Default Pipe - CLEAR_FEATURE.
[in] | device | index of USB Device. |
[in] | recipient | recipient. |
[in] | index | interface or endpoint index. |
[in] | feature_selector | feature selector. |
The function USBH_DeviceRequest_ClearFeature implements the standard device request CLEAR_FEATURE
. This request is used to clear or disable a specific feature.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument recipient defines the recipient of the CLEAR_FEATURE
command.
The argument index denotes the interface or endpoint index to be used.
The argument feature_selector indicates the feature to be cleared.
usbStatus USBH_DeviceRequest_GetConfiguration | ( | uint8_t | device, |
uint8_t * | ptr_configuration | ||
) |
Standard Device Request on Default Pipe - GET_CONFIGURATION.
[in] | device | index of USB Device. |
[out] | ptr_configuration | pointer to where configuration will be read. |
The function USBH_DeviceRequest_GetConfiguration implements the standard device request GET_CONFIGURATION
. This request returns the current device configuration value.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument ptr_configuration specifies the pointer to where the configuration will be read.
usbStatus USBH_DeviceRequest_GetDescriptor | ( | uint8_t | device, |
uint8_t | recipient, | ||
uint8_t | descriptor_type, | ||
uint8_t | descriptor_index, | ||
uint16_t | language_id, | ||
uint8_t * | descriptor_data, | ||
uint16_t | descriptor_length | ||
) |
Standard Device Request on Default Pipe - GET_DESCRIPTOR.
[in] | device | index of USB Device. |
[in] | recipient | recipient. |
[in] | descriptor_type | descriptor type. |
[in] | descriptor_index | descriptor index. |
[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_DeviceRequest_GetDescriptor implements the standard device request GET_DESCRIPTOR
. This request returns the specified descriptor if the descriptor exists.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument recipient defines the recipient of the GET_DESCRIPTOR
command.
The argument descriptor_type specifies the descriptor type to be queried, whereas the argument descriptor_index is used to select a specific descriptor (only for configuration and string descriptors) when several descriptors of the same type are implemented in a device.
The argument language_id specifies the Language ID of string descriptors or is set to zero for other descriptors.
The argument descriptor_data is a pointer to where descriptor data will be read and descriptor_length specifies the number of bytes to return.
usbStatus USBH_DeviceRequest_GetInterface | ( | uint8_t | device, |
uint8_t | index, | ||
uint8_t * | ptr_alternate | ||
) |
Standard Device Request on Default Pipe - GET_INTERFACE.
[in] | device | index of USB Device. |
[in] | index | interface index. |
[out] | ptr_alternate | pointer to where alternate setting data will be read. |
The function USBH_DeviceRequest_GetInterface implements the standard device request GET_INTERFACE
. This request returns the selected alternate setting for the specified interface.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument index specifies the interface index.
The argument ptr_alternate specifies the pointer to where alternate setting data will be read.
usbStatus USBH_DeviceRequest_GetStatus | ( | uint8_t | device, |
uint8_t | recipient, | ||
uint8_t | index, | ||
uint8_t * | ptr_stat_dat | ||
) |
Standard Device Request on Default Pipe - GET_STATUS.
[in] | device | index of USB Device. |
[in] | recipient | recipient. |
[in] | index | interface or endpoint index. |
[out] | ptr_stat_dat | pointer to where status data should be received. |
The function USBH_DeviceRequest_GetStatus implements the standard device request GET_STATUS
. This request returns the current device configuration value.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument recipient defines the recipient of the GET_STATUS
command.
The argument index denotes the interface or endpoint index to be used.
The argument ptr_stat_dat is a pointer to the where the data should be received.
usbStatus USBH_DeviceRequest_SetAddress | ( | uint8_t | device, |
uint8_t | device_address | ||
) |
Standard Device Request on Default Pipe - SET_ADDRESS.
[in] | device | index of USB Device. |
[in] | device_address | device address. |
The function USBH_DeviceRequest_SetAddress implements the standard device request SET_ADDRESS
. This request sets the device address for all future device accesses.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument device_address specifies the new device address.
usbStatus USBH_DeviceRequest_SetConfiguration | ( | uint8_t | device, |
uint8_t | configuration | ||
) |
Standard Device Request on Default Pipe - SET_CONFIGURATION.
[in] | device | index of USB Device. |
[in] | configuration | configuration. |
The function USBH_DeviceRequest_SetConfiguration implements the standard device request SET_CONFIGURATION
. This request sets the device configuration.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument configuration contains the new configuration to be set.
usbStatus USBH_DeviceRequest_SetDescriptor | ( | uint8_t | device, |
uint8_t | recipient, | ||
uint8_t | descriptor_type, | ||
uint8_t | descriptor_index, | ||
uint16_t | language_id, | ||
const uint8_t * | descriptor_data, | ||
uint16_t | descriptor_length | ||
) |
Standard Device Request on Default Pipe - SET_DESCRIPTOR.
[in] | device | index of USB Device. |
[in] | recipient | recipient. |
[in] | descriptor_type | descriptor type. |
[in] | descriptor_index | descriptor index. |
[in] | language_id | language ID. |
[in] | descriptor_data | pointer to descriptor data to be written. |
[in] | descriptor_length | descriptor length. |
The function USBH_DeviceRequest_SetDescriptor implements the standard device request SET_DESCRIPTOR
. This request may be used to update existing or add new descriptors.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument recipient defines the recipient of the SET_DESCRIPTOR
command.
The argument descriptor_type specifies the descriptor type to be queried, whereas the argument descriptor_index is used to select a specific descriptor (only for configuration and string descriptors) when several descriptors of the same type are implemented in a device.
The argument language_id specifies the Language ID for string descriptors or is set to zero for other descriptors.
The argument descriptor_data is a pointer to where descriptor data will be written and descriptor_length specifies the number of bytes to return.
usbStatus USBH_DeviceRequest_SetFeature | ( | uint8_t | device, |
uint8_t | recipient, | ||
uint8_t | index, | ||
uint8_t | feature_selector | ||
) |
Standard Device Request on Default Pipe - SET_FEATURE.
[in] | device | index of USB Device. |
[in] | recipient | recipient. |
[in] | index | interface or endpoint index. |
[in] | feature_selector | feature selector. |
The function USBH_DeviceRequest_SetFeature implements the standard device request SET_FEATURE
. This request is used to set or enable a specific feature.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument recipient defines the recipient of the SET_FEATURE
command.
The argument index denotes the interface or endpoint index to be used.
The argument feature_selector indicates the feature to be cleared.
usbStatus USBH_DeviceRequest_SetInterface | ( | uint8_t | device, |
uint8_t | index, | ||
uint8_t | alternate | ||
) |
Standard Device Request on Default Pipe - SET_INTERFACE.
[in] | device | index of USB Device. |
[in] | index | interface index. |
[in] | alternate | alternate setting. |
The function USBH_DeviceRequest_SetInterface implements the standard device request SET_INTERFACE
. This request allows the host to select an alternate setting for the specified interface.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument index specifies the interface index.
The argument alternate specifies the alternate setting to be set.
usbStatus USBH_DeviceRequest_SynchFrame | ( | uint8_t | device, |
uint8_t | index, | ||
uint8_t * | ptr_frame_number | ||
) |
Standard Device Request on Default Pipe - SYNCH_FRAME.
[in] | device | index of USB Device. |
[in] | index | interface or endpoint index. |
[out] | ptr_frame_number | pointer to where frame number data will be read. |
The function USBH_DeviceRequest_SynchFrame implements the standard device request SYNCH_FRAME
. This request is used to set and then report an endpoint's synchronization frame. When an endpoint supports isochronous transfers, the endpoint may also require per-frame transfers to vary in size according to a specific pattern. The host and the endpoint must agree on which frame the repeating pattern begins. The number of the frame in which the pattern began is returned to the host.
The argument device is the index of the USB Device to which standard device request is addressed.
The argument index specifies the interface index.
The argument ptr_frame_number is a pointer to where frame number data will be sent.
usbStatus USBH_PipeAbort | ( | USBH_PIPE_HANDLE | pipe_hndl | ) |
Abort send/receive operation on Pipe.
[in] | pipe_hndl | pipe handle. |
The function USBH_PipeAbort aborts active send/receive operation on a Pipe.
The argument pipe_hndl is a handle to pipe on which active transfer should be aborted.
USBH_PIPE_HANDLE USBH_PipeCreate | ( | uint8_t | device, |
uint8_t | ep_addr, | ||
uint8_t | ep_type, | ||
uint16_t | ep_max_packet_size, | ||
uint8_t | ep_interval | ||
) |
Create Pipe.
[in] | device | index of USB Device. |
[in] | ep_addr | endpoint address :
|
[in] | ep_type | endpoint type. |
[in] | ep_max_packet_size | endpoint maximum packet size. |
[in] | ep_interval | endpoint polling interval. |
The function USBH_PipeCreate a Pipe for communication with specific Endpoint in a Device.
The argument device specifies the instance of the device.
The argument ep_addr is the address of the endpoint.
The argument ep_type is the type of the endpoint.
The argument ep_max_packet_size is the maximum packet size of the endpoint.
The argument ep_interval is the endpoint polling interval of the endpoint.
Code Example
usbStatus USBH_PipeDelete | ( | USBH_PIPE_HANDLE | pipe_hndl | ) |
Delete Pipe.
[in] | pipe_hndl | pipe handle. |
The function USBH_PipeDelete removes a Pipe.
The argument pipe_hndl is a handle to pipe to be updated.
Code Example
usbStatus USBH_PipeReceive | ( | USBH_PIPE_HANDLE | pipe_hndl, |
uint8_t * | buf, | ||
uint32_t | len | ||
) |
Receive data on Pipe.
[in] | pipe_hndl | pipe handle. |
[out] | buf | buffer that receives data. |
[in] | len | maximum number of bytes to receive. |
The function USBH_PipeReceive receives data on a Pipe. Number of bytes received can be retrieved by USBH_PipeReceiveGetResult function.
The argument pipe_hndl is a handle to pipe used for data reception.
The argument buf buffer that receives data. It is recommended that buffer is 4-byte aligned as some drivers might not support 1-byte alignment if DMA is used.
The argument len maximum number of bytes to receive (must be multiple of device endpoint maximum packet size).
Code Example
uint32_t USBH_PipeReceiveGetResult | ( | USBH_PIPE_HANDLE | pipe_hndl | ) |
Get result of receive data operation on Pipe.
[in] | pipe_hndl | pipe handle. |
The function USBH_PipeReceiveGetResult retrieves number of received data bytes on a Pipe.
The argument pipe_hndl is a handle to pipe used for data reception.
usbStatus USBH_PipeRegisterCallback | ( | USBH_PIPE_HANDLE | pipe_hndl, |
USBH_PipeEvent_t | cb_pipe_event | ||
) |
Register a callback for Pipe events.
[in] | pipe_hndl | pipe handle. |
[in] | cb_pipe_event | pointer to pipe event callback function :
|
The function USBH_PipeRegisterCallback registers a callback function that will be called upon pipe event.
The argument pipe_hndl is a handle to pipe for registering callback.
The argument cb_pipe_event specifies the callback function.
Code Example
usbStatus USBH_PipeReset | ( | USBH_PIPE_HANDLE | pipe_hndl | ) |
Reset Pipe (reset data toggle)
[in] | pipe_hndl | pipe handle. |
The function USBH_PipeReset resets data toggle of a Pipe.
The argument pipe_hndl is a handle to pipe to be reset.
usbStatus USBH_PipeSend | ( | USBH_PIPE_HANDLE | pipe_hndl, |
const uint8_t * | buf, | ||
uint32_t | len | ||
) |
Send data on Pipe.
[in] | pipe_hndl | pipe handle. |
[in] | buf | buffer containing data bytes to send. |
[in] | len | number of bytes to send. |
The function USBH_PipeSend sends data on a Pipe. Number of bytes sent can be retrieved by USBH_PipeSendGetResult function.
The argument pipe_hndl is a handle to pipe used for sending data.
The argument buf buffer containing data bytes to send. It is recommended that buffer is 4-byte aligned as some drivers might not support 1-byte alignment if DMA is used.
The argument len maximum number of bytes to send.
Code Example
uint32_t USBH_PipeSendGetResult | ( | USBH_PIPE_HANDLE | pipe_hndl | ) |
Get result of send data operation on Pipe.
[in] | pipe_hndl | pipe handle. |
The function USBH_PipeSendGetResult retrieves number of successfully sent data bytes on a Pipe.
The argument pipe_hndl is a handle to pipe used for sending data.
usbStatus USBH_PipeUpdate | ( | USBH_PIPE_HANDLE | pipe_hndl | ) |
Update Pipe.
[in] | pipe_hndl | pipe handle. |
The function USBH_PipeUpdate modifies a Pipe with changed device parameters (for example if device address has changed).
The argument pipe_hndl is a handle to pipe to be updated.