M480 BSP  V3.05.001
The Board Support Package for M480 Series
Functions
USB Host Exported Functions

Functions

void usbh_hid_regitser_mouse_callback (HID_MOUSE_FUNC *func)
 Register the mouse event callback function to HID class driver. Any mouse reports will be sent to user application via this callback. More...
 
void usbh_hid_regitser_keyboard_callback (HID_KEYBOARD_FUNC *func)
 Register the keyboard event callback function to HID class driver. Any keyboard reports will be sent to user application via this callback. More...
 
void usbh_core_init (void)
 Initialize M480 USB Host controller and USB stack. More...
 
int usbh_pooling_hubs (void)
 Let USB stack polls all root hubs and downstream hubs. If there's any hub port change found, USB stack will manage the hub events in this function call. In this function, USB stack enumerates newly connected devices and remove staff of disconnected devices. User's application should periodically invoke this function. More...
 
void usbh_install_conn_callback (CONN_FUNC *conn_func, CONN_FUNC *disconn_func)
 Install device connect and disconnect callback function. More...
 
void usbh_suspend (void)
 Suspend USB Host Controller and devices. More...
 
void usbh_resume (void)
 Resume USB Host controller and devices. More...
 
struct udev_t * usbh_find_device (char *hub_id, int port)
 Find the device under the specified hub port. More...
 
uint32_t get_ticks (void)
 A function return current tick count. More...
 
void usbh_cdc_init (void)
 Init USB Host CDC driver. More...
 
struct cdc_dev_tusbh_cdc_get_device_list (void)
 Get a list of currently connected USB Hid devices. More...
 
HIDDEN_SYMBOLS int32_t usbh_cdc_set_control_line_state (CDC_DEV_T *cdev, int active_carrier, int DTE_present)
 SET_CONTROL_LINE_STATE request. More...
 
int32_t usbh_cdc_start_polling_status (CDC_DEV_T *cdev, CDC_CB_FUNC *func)
 Start purge the CDC device's interrupt-in transfer pipe. More...
 
int32_t usbh_cdc_start_to_receive_data (CDC_DEV_T *cdev, CDC_CB_FUNC *func)
 Make CDC device start to receive data from bulk-in transfer pipe. More...
 
int32_t usbh_cdc_send_data (CDC_DEV_T *cdev, uint8_t *buff, int buff_len)
 Send a block of data via CDC device's bulk-out transfer pipe. More...
 
void usbh_hid_init (void)
 Initialize USB Host HID driver. More...
 
struct usbhid_devusbh_hid_get_device_list (void)
 Get a list of currently connected USB Hid devices. More...
 
int32_t usbh_hid_get_report_descriptor (struct usbhid_dev *hdev, uint8_t *desc_buf, int buf_max_len)
 
int32_t usbh_hid_get_report (struct usbhid_dev *hdev, int rtp_typ, int rtp_id, uint8_t *data, int len)
 
int32_t usbh_hid_set_report (struct usbhid_dev *hdev, int rtp_typ, int rtp_id, uint8_t *data, int len)
 
int32_t usbh_hid_get_idle (struct usbhid_dev *hdev, int rtp_id, uint8_t *idle_rate)
 
int32_t usbh_hid_set_idle (struct usbhid_dev *hdev, int rtp_id, uint8_t idle_rate)
 
int32_t usbh_hid_get_protocol (struct usbhid_dev *hdev, uint8_t *protocol)
 
int32_t usbh_hid_set_protocol (struct usbhid_dev *hdev, uint8_t protocol)
 
int32_t usbh_hid_start_int_read (struct usbhid_dev *hdev, uint8_t ep_addr, HID_IR_FUNC *func)
 
int32_t usbh_hid_stop_int_read (struct usbhid_dev *hdev, uint8_t ep_addr)
 
int32_t usbh_hid_start_int_write (struct usbhid_dev *hdev, uint8_t ep_addr, HID_IW_FUNC *func)
 
int32_t usbh_hid_stop_int_write (struct usbhid_dev *hdev, uint8_t ep_addr)
 
int usbh_umas_init (void)
 Register and initialize USB Host Mass Storage driver. More...
 
int usbh_umas_disk_status (int drv_no)
 
int usbh_umas_read (int drv_no, uint32_t sec_no, int sec_cnt, uint8_t *buff)
 
int usbh_umas_write (int drv_no, uint32_t sec_no, int sec_cnt, uint8_t *buff)
 
int usbh_umas_ioctl (int drv_no, int cmd, void *buff)
 
HIDDEN_SYMBOLS void usbh_uac_init (void)
 Initialize USB Audio Class driver. More...
 
int usbh_uac_open (UAC_DEV_T *uac)
 Open an connected UAC device. More...
 
struct uac_dev_tusbh_uac_get_device_list (void)
 Get a list of currently connected USB Audio Class devices. More...
 
int usbh_uac_get_channel_number (UAC_DEV_T *uac, uint8_t target)
 Obtain Audio Class device's channel number. More...
 
int usbh_uac_get_bit_resolution (UAC_DEV_T *uac, uint8_t target, uint8_t *byte_cnt)
 Obtain Audio Class device subframe bit resolution.. More...
 
int usbh_uac_get_sampling_rate (UAC_DEV_T *uac, uint8_t target, uint32_t *srate_list, int max_cnt, uint8_t *type)
 Get a list of sampling rate frequencies supported by the UAC device. More...
 
int usbh_uac_sampling_rate_control (UAC_DEV_T *uac, uint8_t target, uint8_t req, uint32_t *srate)
 Set sampling rate frequency. More...
 
int usbh_uac_mute_control (UAC_DEV_T *uac, uint8_t target, uint8_t req, uint16_t chn, uint8_t *mute)
 Control Audio Class device mute on/off. More...
 
int usbh_uac_vol_control (UAC_DEV_T *uac, uint8_t target, uint8_t req, uint16_t chn, uint16_t *volume)
 Audio Class device volume control. More...
 
int usbh_uac_auto_gain_control (UAC_DEV_T *uac, uint8_t target, uint8_t req, uint16_t chn, uint8_t *bAGC)
 Audio Class device automatic gain control. More...
 
int usbh_uac_start_audio_in (UAC_DEV_T *uac, UAC_CB_FUNC *func)
 Start to receive audio data from UAC device. (Microphone) More...
 
int usbh_uac_stop_audio_in (UAC_DEV_T *uac)
 Stop UAC device audio in data stream. More...
 
int usbh_uac_start_audio_out (UAC_DEV_T *uac, UAC_CB_FUNC *func)
 Start to transmit audio data to UAC device. (Speaker) More...
 
int usbh_uac_stop_audio_out (UAC_DEV_T *uac)
 Stop UAC device audio out data stream. More...
 
int32_t usbh_cdc_get_line_coding (CDC_DEV_T *cdev, LINE_CODING_T *line_code)
 GET_LINE_CODING request. More...
 
int32_t usbh_cdc_set_line_coding (CDC_DEV_T *cdev, LINE_CODING_T *line_code)
 SET_LINE_CODING request. More...
 

Detailed Description

Function Documentation

◆ get_ticks()

uint32_t get_ticks ( void  )

A function return current tick count.

Returns
Current tick.

User application must provide this function to return current tick. The tick should increase by 1 for every 10 ms.

◆ usbh_cdc_get_device_list()

struct cdc_dev_t* usbh_cdc_get_device_list ( void  )

Get a list of currently connected USB Hid devices.

Returns
List of CDC devices.
Return values
NULLThere's no CDC device found.
OtherwiseA list of connected CDC devices.

The CDC devices are chained by the "next" member of CDC_DEV_T.

Definition at line 280 of file cdc_driver.c.

◆ usbh_cdc_get_line_coding()

int32_t usbh_cdc_get_line_coding ( CDC_DEV_T cdev,
LINE_CODING_T line_code 
)

GET_LINE_CODING request.

Parameters
[in]cdevCDC device
[out]line_codeThe currently configured line coding.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 46 of file cdc_core.c.

◆ usbh_cdc_init()

void usbh_cdc_init ( void  )

Init USB Host CDC driver.

Returns
None

Definition at line 265 of file cdc_driver.c.

◆ usbh_cdc_send_data()

int32_t usbh_cdc_send_data ( CDC_DEV_T cdev,
uint8_t *  buff,
int  buff_len 
)

Send a block of data via CDC device's bulk-out transfer pipe.

Parameters
[in]cdevCDC device
[in]buffBuffer contains the data block to be send.
[in]buff_lenLength in byte of data to be send
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 383 of file cdc_core.c.

◆ usbh_cdc_set_control_line_state()

int32_t usbh_cdc_set_control_line_state ( CDC_DEV_T cdev,
int  active_carrier,
int  DTE_present 
)

SET_CONTROL_LINE_STATE request.

Parameters
[in]cdevCDC device
[in]active_carrierCarrier control for half duplex modems is activated or not.
[in]DTE_presentIndicates to DCE if DTE is present or not.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 135 of file cdc_core.c.

◆ usbh_cdc_set_line_coding()

int32_t usbh_cdc_set_line_coding ( CDC_DEV_T cdev,
LINE_CODING_T line_code 
)

SET_LINE_CODING request.

Parameters
[in]cdevCDC device
[in]line_codeThe line coding configuration to be set.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 85 of file cdc_core.c.

◆ usbh_cdc_start_polling_status()

HIDDEN_SYMBOLS int32_t usbh_cdc_start_polling_status ( CDC_DEV_T cdev,
CDC_CB_FUNC func 
)

Start purge the CDC device's interrupt-in transfer pipe.

Parameters
[in]cdevCDC device
[in]funcThe interrupt in data receiver callback function.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 213 of file cdc_core.c.

◆ usbh_cdc_start_to_receive_data()

HIDDEN_SYMBOLS int32_t usbh_cdc_start_to_receive_data ( CDC_DEV_T cdev,
CDC_CB_FUNC func 
)

Make CDC device start to receive data from bulk-in transfer pipe.

Parameters
[in]cdevCDC device
[in]funcThe BULK in data receiver callback function.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 306 of file cdc_core.c.

◆ usbh_core_init()

void usbh_core_init ( void  )

Initialize M480 USB Host controller and USB stack.

Returns
None.

Definition at line 39 of file usb_core.c.

◆ usbh_find_device()

struct udev_t* usbh_find_device ( char *  hub_id,
int  port 
)

Find the device under the specified hub port.

Parameters
[in]hub_idHub identify ID
[in]portPort number of the specified ub.
Return values
NULLNot found. There's no valid device connected under that hub port.
OtherwiseAn UDEV_T pointer reference to the device under specified hub and port.

Definition at line 685 of file hub.c.

◆ usbh_hid_get_device_list()

struct usbhid_dev* usbh_hid_get_device_list ( void  )

Get a list of currently connected USB Hid devices.

Returns
A list HID_DEV_T pointer reference to connected HID devices.
Return values
NULLThere's no HID device found.
OtherwiseA list of connected HID devices.

The HID devices are chained by the "next" member of HID_DEV_T.

Definition at line 225 of file hid_driver.c.

◆ usbh_hid_get_idle()

int32_t usbh_hid_get_idle ( struct usbhid_dev hdev,
int  rtp_id,
uint8_t *  idle_rate 
)

◆ usbh_hid_get_protocol()

int32_t usbh_hid_get_protocol ( struct usbhid_dev hdev,
uint8_t *  protocol 
)

◆ usbh_hid_get_report()

int32_t usbh_hid_get_report ( struct usbhid_dev hdev,
int  rtp_typ,
int  rtp_id,
uint8_t *  data,
int  len 
)

◆ usbh_hid_get_report_descriptor()

int32_t usbh_hid_get_report_descriptor ( struct usbhid_dev hdev,
uint8_t *  desc_buf,
int  buf_max_len 
)

◆ usbh_hid_init()

void usbh_hid_init ( void  )

Initialize USB Host HID driver.

Returns
None

Definition at line 209 of file hid_driver.c.

◆ usbh_hid_regitser_keyboard_callback()

void usbh_hid_regitser_keyboard_callback ( HID_KEYBOARD_FUNC func)

Register the keyboard event callback function to HID class driver. Any keyboard reports will be sent to user application via this callback.

Parameters
[in]funcKeyboard event callback function
Returns
None

Definition at line 755 of file hid_core.c.

◆ usbh_hid_regitser_mouse_callback()

void usbh_hid_regitser_mouse_callback ( HID_MOUSE_FUNC func)

Register the mouse event callback function to HID class driver. Any mouse reports will be sent to user application via this callback.

Parameters
[in]funcMouse event callback function
Returns
None

Definition at line 743 of file hid_core.c.

◆ usbh_hid_set_idle()

int32_t usbh_hid_set_idle ( struct usbhid_dev hdev,
int  rtp_id,
uint8_t  idle_rate 
)

◆ usbh_hid_set_protocol()

int32_t usbh_hid_set_protocol ( struct usbhid_dev hdev,
uint8_t  protocol 
)

◆ usbh_hid_set_report()

int32_t usbh_hid_set_report ( struct usbhid_dev hdev,
int  rtp_typ,
int  rtp_id,
uint8_t *  data,
int  len 
)

◆ usbh_hid_start_int_read()

int32_t usbh_hid_start_int_read ( struct usbhid_dev hdev,
uint8_t  ep_addr,
HID_IR_FUNC func 
)

◆ usbh_hid_start_int_write()

int32_t usbh_hid_start_int_write ( struct usbhid_dev hdev,
uint8_t  ep_addr,
HID_IW_FUNC func 
)

◆ usbh_hid_stop_int_read()

int32_t usbh_hid_stop_int_read ( struct usbhid_dev hdev,
uint8_t  ep_addr 
)

◆ usbh_hid_stop_int_write()

int32_t usbh_hid_stop_int_write ( struct usbhid_dev hdev,
uint8_t  ep_addr 
)

◆ usbh_install_conn_callback()

void usbh_install_conn_callback ( CONN_FUNC conn_func,
CONN_FUNC disconn_func 
)

Install device connect and disconnect callback function.

Parameters
[in]conn_funcDevice connect callback function.
[in]disconn_funcDevice disconnect callback function.
Returns
None.

Definition at line 86 of file usb_core.c.

◆ usbh_pooling_hubs()

int usbh_pooling_hubs ( void  )

Let USB stack polls all root hubs and downstream hubs. If there's any hub port change found, USB stack will manage the hub events in this function call. In this function, USB stack enumerates newly connected devices and remove staff of disconnected devices. User's application should periodically invoke this function.

Returns
There's hub port change or not.
Return values
0No any hub port status changes found.
1There's hub port status changes.

Definition at line 637 of file hub.c.

◆ usbh_resume()

void usbh_resume ( void  )

Resume USB Host controller and devices.

Returns
None

Definition at line 176 of file usb_core.c.

◆ usbh_suspend()

void usbh_suspend ( void  )

Suspend USB Host Controller and devices.

Returns
None

Definition at line 115 of file usb_core.c.

◆ usbh_uac_auto_gain_control()

int usbh_uac_auto_gain_control ( UAC_DEV_T uac,
uint8_t  target,
uint8_t  req,
uint16_t  chn,
uint8_t *  bAGC 
)

Audio Class device automatic gain control.

Parameters
[in]uacUAC device
[in]targetSelect the control target.
[in]reqControl request. This UAC driver supports the following request:
[in]chnThe requested channel. It can be one of the followings:
[in]bAGCOne byte data. If the channel's automatic gain control is on, then the value is 1. Otherwise, it's 0.
Returns
Success or failed.
Return values
0Success
UAC_RET_DEV_NOT_SUPPORTEDThis UAC device does not support this function.
OtherwiseError occurred

Definition at line 385 of file uac_core.c.

◆ usbh_uac_get_bit_resolution()

int usbh_uac_get_bit_resolution ( UAC_DEV_T uac,
uint8_t  target,
uint8_t *  byte_cnt 
)

Obtain Audio Class device subframe bit resolution..

Parameters
[in]uacUAC device
[in]targetSelect the control target.
[out]byte_cntThe number of bytes occupied by one audio subframe. Can be 1, 2, 3 or 4.
Returns
Bit resolution or error code.
Return values
<0 Failed. UAC device may not present or function not supported.
OtherwiseThe number of effectively used bits from the available bits in an audio subframe.

Definition at line 71 of file uac_core.c.

◆ usbh_uac_get_channel_number()

int usbh_uac_get_channel_number ( UAC_DEV_T uac,
uint8_t  target 
)

Obtain Audio Class device's channel number.

Parameters
[in]uacUAC device
[in]targetSelect the control target.
Returns
Channel number or error code.
Return values
<0 Failed. UAC device may not present or function not supported.
OtherwiseThe channel number.

Definition at line 44 of file uac_core.c.

◆ usbh_uac_get_device_list()

UAC_DEV_T * usbh_uac_get_device_list ( void  )

Get a list of currently connected USB Audio Class devices.

Returns
List of current connected UAC devices.
Return values
NULLThere's no UAC devices found.
OtherwiseA list of connected UAC devices.

The Audio Class devices are chained by the "next" member of UAC_DEV_T.

Definition at line 266 of file uac_driver.c.

◆ usbh_uac_get_sampling_rate()

HIDDEN_SYMBOLS int usbh_uac_get_sampling_rate ( UAC_DEV_T uac,
uint8_t  target,
uint32_t *  srate_list,
int  max_cnt,
uint8_t *  type 
)

Get a list of sampling rate frequencies supported by the UAC device.

Parameters
[in]uacUAC device
[in]targetSelect the control target.
[out]srate_listA word array provided by user application to hold the sampling rate list.
[in]max_cntAvailable number of entries of srate_list[]. Must be > 2.
[out]typeIndicates how the sampling frequency can be programmed. 0: Continuous sampling frequency. srate_list[0] is the lower bound in Hz of the sampling frequency and srate_list[1] is the upper bound. 1~255: The number of discrete sampling frequencies supported. They are listed in srate_list[].
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 116 of file uac_core.c.

◆ usbh_uac_init()

HIDDEN_SYMBOLS void usbh_uac_init ( void  )

Initialize USB Audio Class driver.

Returns
None

Definition at line 250 of file uac_driver.c.

◆ usbh_uac_mute_control()

int usbh_uac_mute_control ( UAC_DEV_T uac,
uint8_t  target,
uint8_t  req,
uint16_t  chn,
uint8_t *  mute 
)

Control Audio Class device mute on/off.

Parameters
[in]uacUAC device
[in]targetSelect the control target.
[in]reqControl request. This UAC driver supports the following request:
[in]chnThe requested channel. It can be one of the followings:
[in]muteOne byte data. If the channel is muted, then the value is 1. Otherwise, it's 0.
Returns
Success or failed.
Return values
0Success
UAC_RET_DEV_NOT_SUPPORTEDThis UAC device does not support this function.
OtherwiseError occurred

Definition at line 240 of file uac_core.c.

◆ usbh_uac_open()

int usbh_uac_open ( UAC_DEV_T uac)

Open an connected UAC device.

Parameters
[in]uacAudio Class device
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 997 of file uac_core.c.

◆ usbh_uac_sampling_rate_control()

int usbh_uac_sampling_rate_control ( UAC_DEV_T uac,
uint8_t  target,
uint8_t  req,
uint32_t *  srate 
)

Set sampling rate frequency.

Parameters
[in]uacUAC device
[in]targetSelect the control target.
[in]reqControl request. This UAC driver supports the following request:
[in]srateSampling rate frequency to be set or get.
Returns
Success or failed.
Return values
0Success
OtherwiseError occurred

Definition at line 169 of file uac_core.c.

◆ usbh_uac_start_audio_in()

HIDDEN_SYMBOLS int usbh_uac_start_audio_in ( UAC_DEV_T uac,
UAC_CB_FUNC func 
)

Start to receive audio data from UAC device. (Microphone)

Parameters
[in]uacAudio Class device
[in]funcAudio in callback function.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 554 of file uac_core.c.

◆ usbh_uac_start_audio_out()

HIDDEN_SYMBOLS int usbh_uac_start_audio_out ( UAC_DEV_T uac,
UAC_CB_FUNC func 
)

Start to transmit audio data to UAC device. (Speaker)

Parameters
[in]uacAudio Class device
[in]funcAudio out call-back function. UAC driver call this function to get audio out stream data from user application.
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 796 of file uac_core.c.

◆ usbh_uac_stop_audio_in()

int usbh_uac_stop_audio_in ( UAC_DEV_T uac)

Stop UAC device audio in data stream.

Parameters
[in]uacAudio Class device
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 703 of file uac_core.c.

◆ usbh_uac_stop_audio_out()

int usbh_uac_stop_audio_out ( UAC_DEV_T uac)

Stop UAC device audio out data stream.

Parameters
[in]uacAudio Class device
Returns
Success or not.
Return values
0Success
OtherwiseFailed

Definition at line 946 of file uac_core.c.

◆ usbh_uac_vol_control()

int usbh_uac_vol_control ( UAC_DEV_T uac,
uint8_t  target,
uint8_t  req,
uint16_t  chn,
uint16_t *  volume 
)

Audio Class device volume control.

Parameters
[in]uacUAC device
[in]targetSelect the control target.
[in]reqControl request. This UAC driver supports the following request:
[in]chnThe requested channel. It can be one of the followings:
[in]volumeAudio Class device volume value, which is interpreted as the following: 0x7FFF: 127.9961 dB . . . 0x0100: 1.0000 dB . . . 0x0002: 0.0078 dB 0x0001: 0.0039 dB 0x0000: 0.0000 dB 0xFFFF: -0.0039 dB 0xFFFE: -0.0078 dB . . . 0xFE00: -1.0000 dB . . . 0x8002: -127.9922 dB 0x8001: -127.9961 dB
Returns
Success or failed.
Return values
0Success
UAC_RET_DEV_NOT_SUPPORTEDThis UAC device does not support this function.
OtherwiseError occurred

Definition at line 323 of file uac_core.c.

◆ usbh_umas_disk_status()

int usbh_umas_disk_status ( int  drv_no)

◆ usbh_umas_init()

int usbh_umas_init ( void  )

Register and initialize USB Host Mass Storage driver.

Return values
0Success.
1Failed.

Definition at line 631 of file msc_driver.c.

◆ usbh_umas_ioctl()

int usbh_umas_ioctl ( int  drv_no,
int  cmd,
void *  buff 
)

◆ usbh_umas_read()

int usbh_umas_read ( int  drv_no,
uint32_t  sec_no,
int  sec_cnt,
uint8_t *  buff 
)

◆ usbh_umas_write()

int usbh_umas_write ( int  drv_no,
uint32_t  sec_no,
int  sec_cnt,
uint8_t *  buff 
)