USB HAL Exported Types

group USB_HAL_Exported_Types

Defines

HAL_USB_ISR_HOOKS(type, t_enter, t_handler, t_exit)

struct _hal_usb_isr_hooks_##type                                          \

{                                                                         \

t_enter enter;                                                        \

t_handler handler;                                                    \

t_exit exit;                                                          \

}


USB ISR Hooks.

参数:
  • enter -- Called at the beginning of the common ISR.

  • handler -- The handler of the ISR defined in T_HAL_USB_COMMON_ISR.

  • exit -- Called at the end of the common ISR.

Typedefs

typedef struct _hal_usb_request_block T_HAL_USB_REQUEST_BLOCK

USB request block-USB data transfer entity.

Param length:

The length of data that will be sent or received.

Param actual:

The actual length of data that has been sent or received.

Param buf:

The buffer that stores data will be sent or has been received.

Param zlp:

Send a zero-length packet when the length is equal to the maximum packet size of the endpoint.

Param complete_in_isr:

1: The complete callback will be called in ISR.

0: The complete callback will not be called in ISR, and the URB will be transferred through

HAL_USB_COMMON_ISR_XFER_DONE.

Param status:

The status of the data transfer.

Param ep_handle:

The handle of endpoint that will transfer data.

Param complete:

The callback will be called when data that has been sent or received.

For sending data, this callback is mainly used to indicate the result of data sending.

For receiving data, this callback is used to get the data already received and related information.

Param priv:

The private data.

typedef struct _hal_usb_iso_pkt_info T_HAL_USB_ISO_PKT_INFO

USB isochronous packet information.

For isochronous transfer, multiple packets can be sent at once. For example, if USB speed is high and bInterval of isochronous endpoint is 3, the host will send a token packet every 0.5ms, but the upper application may prepare data every 2 ms. In this case, the upper application can process 4 packets at a time.

Param offset:

The offset of the current packet in buf of T_HAL_USB_ISO_REQUEST_BLOCK.

Param actual:

The actual length of the current packet.

Param status:

The status of the current packet transferred.

typedef struct _hal_usb_iso_request_block T_HAL_USB_ISO_REQUEST_BLOCK

USB isochronous request block.

For isochronous transfer, ping-pong buffers are used to manage data transfer. For example, if the current data transfer uses buf0, the next data transfer will use buf1, and this alternation continues between the two buffers. The interval at which data is processed is determined by both the bInterval field in the endpoint descriptor and buf_proc_intrvl. The formula to calculate the data processing interval is: 2^(bInterval - 1) * buf_proc_intrvl *125us.

Param buf0:

The buffer 0 of ping-pong buffers.

Param buf1:

The buffer 1 of ping-pong buffers.

Param data_per_frame:

The data length per host polling.

Param buf_proc_intrvl:

The number of the host polling per data process.

Param pkt_cnt:

The packet number per data process.

Param iso_pkt0:

The packets information stored in buf0, refer to T_HAL_USB_ISO_PKT_INFO.

Param iso_pkt1:

The packets information stored in buf1, refer to T_HAL_USB_ISO_PKT_INFO.

Param ep_handle:

The handle of endpoint that will transfer data.

Param complete:

The callback will be called when data has been sent or received.

For sending data, the upper application SHOULD prepare data in the buffer indexed by proc_buf_num.

For receiving data, the upper application SHOULD process data stored in the buffer indexed by proc_buf_num.

Param priv:

The private data.

typedef union _hal_usb_isr_param T_HAL_USB_ISR_PARAM

The parameter of the ISR handler in HAL_USB_ISR_HOOKS.

Param enum_done:

Used in HAL_USB_COMMON_ISR_ENUM_DONE.

Param setup:

Used in HAL_USB_COMMON_ISR_SETUP.

Param xfer_done:

Used in HAL_USB_COMMON_ISR_XFER_DONE.

typedef void (*HAL_USB_COMMON_ISR_ENTER)(void)

The entrance of common ISR.

typedef void (*HAL_USB_COMMON_ISR_HANDLER)(T_HAL_USB_COMMON_ISR, T_HAL_USB_ISR_PARAM *param)

The handler of common ISR.

Param T_HAL_USB_COMMON_ISR:

ISR type defined in T_HAL_USB_COMMON_ISR.

Param param:

Defined in T_HAL_USB_ISR_PARAM.

typedef void (*HAL_USB_COMMON_ISR_EXIT)(void)

The exit of common ISR.

typedef void (*HAL_USB_SUSPENDN_ISR_ENTER)(void)

The entrance of suspend ISR.

typedef void (*HAL_USB_SUSPENDN_ISR_HANDLER)(void)

The handler of suspend ISR.

typedef void (*HAL_USB_SUSPENDN_ISR_EXIT)(void)

The exit of suspend ISR.

typedef void (*HAL_USB_ISOC_ISR_ENTER)(void)

The entrance of isochronous ISR.

typedef void (*HAL_USB_ISOC_ISR_HANDLER)(void)

The handler of isochronous ISR.

typedef void (*HAL_USB_ISOC_ISR_EXIT)(void)

The exit of isochronous ISR.

typedef struct _hal_usb_isr_hooks_common HAL_USB_COMMON_ISR_HOOKS

USB common ISR Hooks.

typedef struct _hal_usb_isr_hooks_suspend HAL_USB_SUSPENDN_ISR_HOOKS

USB suspend ISR Hooks.

struct _hal_usb_request_block

USB request block-USB data transfer entity.

Param length:

The length of data that will be sent or received.

Param actual:

The actual length of data that has been sent or received.

Param buf:

The buffer that stores data will be sent or has been received.

Param zlp:

Send a zero-length packet when the length is equal to the maximum packet size of the endpoint.

Param complete_in_isr:

1: The complete callback will be called in ISR.

0: The complete callback will not be called in ISR, and the URB will be transferred through

HAL_USB_COMMON_ISR_XFER_DONE.

Param status:

The status of the data transfer.

Param ep_handle:

The handle of endpoint that will transfer data.

Param complete:

The callback will be called when data that has been sent or received.

For sending data, this callback is mainly used to indicate the result of data sending.

For receiving data, this callback is used to get the data already received and related information.

Param priv:

The private data.

Public Members

int length
int actual
uint8_t *buf
uint8_t zlp
uint8_t complete_in_isr
uint8_t rsv
int status
void *ep_handle
int (*complete)(struct _hal_usb_request_block *urb)
void *priv
struct _hal_usb_iso_pkt_info

USB isochronous packet information.

For isochronous transfer, multiple packets can be sent at once. For example, if USB speed is high and bInterval of isochronous endpoint is 3, the host will send a token packet every 0.5ms, but the upper application may prepare data every 2 ms. In this case, the upper application can process 4 packets at a time.

Param offset:

The offset of the current packet in buf of T_HAL_USB_ISO_REQUEST_BLOCK.

Param actual:

The actual length of the current packet.

Param status:

The status of the current packet transferred.

Public Members

uint32_t offset
uint32_t actual
int status
struct _hal_usb_iso_request_block

USB isochronous request block.

For isochronous transfer, ping-pong buffers are used to manage data transfer. For example, if the current data transfer uses buf0, the next data transfer will use buf1, and this alternation continues between the two buffers. The interval at which data is processed is determined by both the bInterval field in the endpoint descriptor and buf_proc_intrvl. The formula to calculate the data processing interval is: 2^(bInterval - 1) * buf_proc_intrvl *125us.

Param buf0:

The buffer 0 of ping-pong buffers.

Param buf1:

The buffer 1 of ping-pong buffers.

Param data_per_frame:

The data length per host polling.

Param buf_proc_intrvl:

The number of the host polling per data process.

Param pkt_cnt:

The packet number per data process.

Param iso_pkt0:

The packets information stored in buf0, refer to T_HAL_USB_ISO_PKT_INFO.

Param iso_pkt1:

The packets information stored in buf1, refer to T_HAL_USB_ISO_PKT_INFO.

Param ep_handle:

The handle of endpoint that will transfer data.

Param complete:

The callback will be called when data has been sent or received.

For sending data, the upper application SHOULD prepare data in the buffer indexed by proc_buf_num.

For receiving data, the upper application SHOULD process data stored in the buffer indexed by proc_buf_num.

Param priv:

The private data.

Public Members

uint8_t *buf0
uint8_t *buf1
uint32_t data_per_frame
uint32_t buf_proc_intrvl
uint8_t pkt_cnt
T_HAL_USB_ISO_PKT_INFO *iso_pkt
void *ep_handle
int (*complete)(struct _hal_usb_iso_request_block *urb, uint8_t proc_buf_num)
void *priv
union _hal_usb_isr_param

The parameter of the ISR handler in HAL_USB_ISR_HOOKS.

Param enum_done:

Used in HAL_USB_COMMON_ISR_ENUM_DONE.

Param setup:

Used in HAL_USB_COMMON_ISR_SETUP.

Param xfer_done:

Used in HAL_USB_COMMON_ISR_XFER_DONE.

Public Members

T_HAL_USB_SPEED speed
struct _hal_usb_isr_param enum_done
uint8_t *setup_pkt
struct _hal_usb_isr_param setup
T_HAL_USB_REQUEST_BLOCK *urb
struct _hal_usb_isr_param xfer_done
struct _hal_usb_isr_hooks_common

USB common ISR Hooks.

struct _hal_usb_isr_hooks_suspend

USB suspend ISR Hooks.