HAL HCD Functions

Initialization and de-initialization functions

group HCD_Exported_Functions_Group1

Initialization and Configuration functions.

 ===============================================================================
          ##### Initialization and de-initialization functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:

Functions

hal_status_t HAL_HCD_Init ( hal_hcd_handle_t * hhcd , hal_hcd_t instance )

Initialize the host driver.

Parameters :
  • hhcd – HCD handle

  • instance – HCD instance

Return values :

HAL – status

void HAL_HCD_DeInit ( hal_hcd_handle_t * hhcd )

DeInitialize the host driver.

Parameters :

hhcd – HCD handle

hal_status_t HAL_HCD_SetConfig ( hal_hcd_handle_t * hhcd , const hal_hcd_config_t * p_config )

Configure the HCD according to the specified parameters in the hal_hcd_handle_t and initialize the associated handle.

Parameters :
  • hhcd – HCD handle

  • p_config – pointer to the peripheral configuration structure

Return values :

HAL – status

hal_status_t HAL_HCD_SetConfigChannel ( hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num , const hal_hcd_channel_config_t * p_channel_config )

Initialize a host channel.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

  • p_channel_config – channel config structure

Return values :

HAL – status

hal_status_t HAL_HCD_HaltChannel ( const hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num )

Halt a host channel.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

Return values :

HAL – status

void HAL_HCD_SofCallback ( hal_hcd_handle_t * hhcd )

SOF callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortConnectCallback ( hal_hcd_handle_t * hhcd )

Connection Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortDisconnectCallback ( hal_hcd_handle_t * hhcd )

Disconnection Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortEnabledCallback ( hal_hcd_handle_t * hhcd )

Port Enabled Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortDisabledCallback ( hal_hcd_handle_t * hhcd )

Port Disabled Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortSuspendCallback ( hal_hcd_handle_t * hhcd )

Suspend Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortResumeCallback ( hal_hcd_handle_t * hhcd )

Resume Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_ChannelNotifyURBChangeCallback ( hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num , hal_hcd_channel_urb_state_t urb_state )

Notify URB state change callback.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

  • urb_state – This parameter can be one of these values: HAL_HCD_CHANNEL_URB_STATE_IDLE/ HAL_HCD_CHANNEL_URB_STATE_DONE/ HAL_HCD_CHANNEL_URB_STATE_NOTREADY/ HAL_HCD_CHANNEL_URB_STATE_ERROR/ HAL_HCD_CHANNEL_URB_STATE_STALL/

void HAL_HCD_ErrorCallback ( hal_hcd_handle_t * hhcd )

HCD Error callback.

Parameters :

hhcd – HCD handle

hal_status_t HAL_HCD_RegisterSofCallback ( hal_hcd_handle_t * hhcd , hal_hcd_cb_t p_callback )

Register User SOF Callback To be used instead of the weak predefined callback.

Parameters :
  • hhcd – USB HCD handle

  • p_callback – pointer to the Callback function

Return values :

HAL – status

hal_status_t HAL_HCD_RegisterPortConnectCallback ( hal_hcd_handle_t * hhcd , hal_hcd_cb_t p_callback )

Register a USB HCD Connect Callback To be used instead of the weak predefined callback.

Parameters :
  • hhcd – USB HCD handle

  • p_callback – pointer to the Callback function

Return values :

HAL – status

hal_status_t HAL_HCD_RegisterPortDisconnectCallback ( hal_hcd_handle_t * hhcd , hal_hcd_cb_t p_callback )

Register a USB HCD Disconnect Callback To be used instead of the weak predefined callback.

Parameters :
  • hhcd – USB HCD handle

  • p_callback – pointer to the Callback function

Return values :

HAL – status

hal_status_t HAL_HCD_RegisterPortEnabledCallback ( hal_hcd_handle_t * hhcd , hal_hcd_cb_t p_callback )

Register a USB HCD Port Enabled Callback To be used instead of the weak predefined callback.

Parameters :
  • hhcd – USB HCD handle

  • p_callback – pointer to the Callback function

Return values :

HAL – status

hal_status_t HAL_HCD_RegisterPortDisabledCallback ( hal_hcd_handle_t * hhcd , hal_hcd_cb_t p_callback )

Register a USB HCD Port Disabled Callback To be used instead of the weak predefined callback.

Parameters :
  • hhcd – USB HCD handle

  • p_callback – pointer to the Callback function

Return values :

HAL – status

hal_status_t HAL_HCD_RegisterPortSuspendCallback ( hal_hcd_handle_t * hhcd , hal_hcd_cb_t p_callback )

Register a USB HCD Suspend Callback To be used instead of the weak predefined callback.

Parameters :
  • hhcd – USB HCD handle

  • p_callback – pointer to the Callback function

Return values :

HAL – status

hal_status_t HAL_HCD_RegisterPortResumeCallback ( hal_hcd_handle_t * hhcd , hal_hcd_cb_t p_callback )

Register a USB HCD Resume Callback To be used instead of the weak predefined callback.

Parameters :
  • hhcd – USB HCD handle

  • p_callback – pointer to the Callback function

Return values :

HAL – status

hal_status_t HAL_HCD_RegisterChannelNotifyURBChangeCallback ( hal_hcd_handle_t * hhcd , hal_hcd_ch_notify_urb_change_cb_t p_callback )

Register USB HCD Host Channel Notify URB Change Callback To be used instead of the weak HAL_HCD_ChannelNotifyURBChangeCallback() predefined callback.

Parameters :
  • hhcd – HCD handle

  • p_callback – pointer to the USB HCD Host Channel Notify URB Change Callback function

Return values :

HAL – status

hal_status_t HAL_HCD_RegisterErrorCallback ( hal_hcd_handle_t * hhcd , hal_hcd_cb_t p_callback )

Register USB HCD Error Callback To be used instead of the weak HAL_HCD_ErrorCallback() predefined callback.

Parameters :
  • hhcd – HCD handle

  • p_callback – pointer to the USB HCD Error Callback function

Return values :

HAL – status

uint32_t HAL_HCD_GetLastErrorCodes ( const hal_hcd_handle_t * hhcd )

Get Last Error codes.

Parameters :

hhcd – Pointer to a hal_hcd_handle_t

Return values :

last – error code.

Input and Output operation functions

group HCD_Exported_Functions_Group2

Data transfers functions.

 ===============================================================================
                      ##### IO operation functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to manage the HCD data
    transfers.

Functions

uint32_t HAL_HCD_GetChannelTransferCount ( const hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num )

Return the last host transfer size.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

Return values :

last – transfer size in byte

uint32_t HAL_HCD_GetCurrentFrame ( const hal_hcd_handle_t * hhcd )

Return the current Host frame number.

Parameters :

hhcd – HCD handle

Return values :

Current – Host frame number

hal_hcd_port_speed_t HAL_HCD_GetPortSpeed ( const hal_hcd_handle_t * hhcd )

Return the Host enumeration speed.

Parameters :

hhcd – HCD handle

Return values :

Enumeration – speed

hal_status_t HAL_HCD_SetChannelHubInfo ( hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num , uint8_t hub_addr , uint8_t port_nbr )

Set host channel hub information.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

  • hub_addr – Hub address

  • port_nbr – Hub port number

Return values :

HAL – status

hal_status_t HAL_HCD_ClearChannelHubInfo ( hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num )

Clear host channel hub information.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

Return values :

HAL – status

hal_hcd_dma_status_t HAL_HCD_IsEnabledDma ( const hal_hcd_handle_t * hhcd )

Return the HCD DMA status enabled or disabled.

Parameters :

hhcd – HCD handle

Return values :

state

hal_status_t HAL_HCD_RequestChannelTransfer ( hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num , hal_hcd_channel_transfer_req_t * p_channel_transfer_req )

Submit a new URB transfer request for processing.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

  • p_channel_transfer_req – Channel transfer request.

Return values :

HAL – status

void HAL_HCD_IRQHandler ( hal_hcd_handle_t * hhcd )

Handles HCD interrupt request.

Parameters :

hhcd – HCD handle

uint32_t HAL_HCD_GetLastErrorCodes ( const hal_hcd_handle_t * hhcd )

Get Last Error codes.

Parameters :

hhcd – Pointer to a hal_hcd_handle_t

Return values :

last – error code.

void HAL_HCD_SetUserData ( hal_hcd_handle_t * hhcd , const void * p_user_data )

Set the user data pointer into the handle.

Parameters :
const void * HAL_HCD_GetUserData ( const hal_hcd_handle_t * hhcd )

Get the user data pointer from the handle.

Parameters :

hhcd – Pointer to a hal_hcd_handle_t

Return values :

Pointer – to the user data.

void HAL_HCD_OTG_IRQHandler ( hal_hcd_handle_t * hhcd )

Handle HCD interrupt request.

Parameters :

hhcd – HCD handle

void HAL_HCD_ErrorCallback ( hal_hcd_handle_t * hhcd )

HCD Error callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_SofCallback ( hal_hcd_handle_t * hhcd )

SOF callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortConnectCallback ( hal_hcd_handle_t * hhcd )

Connection Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortDisconnectCallback ( hal_hcd_handle_t * hhcd )

Disconnection Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortEnabledCallback ( hal_hcd_handle_t * hhcd )

Port Enabled Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortDisabledCallback ( hal_hcd_handle_t * hhcd )

Port Disabled Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortSuspendCallback ( hal_hcd_handle_t * hhcd )

Suspend Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_PortResumeCallback ( hal_hcd_handle_t * hhcd )

Resume Event callback.

Parameters :

hhcd – HCD handle

void HAL_HCD_ChannelNotifyURBChangeCallback ( hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num , hal_hcd_channel_urb_state_t urb_state )

Notify URB state change callback.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

  • urb_state – This parameter can be one of these values: HAL_HCD_CHANNEL_URB_STATE_IDLE/ HAL_HCD_CHANNEL_URB_STATE_DONE/ HAL_HCD_CHANNEL_URB_STATE_NOTREADY/ HAL_HCD_CHANNEL_URB_STATE_ERROR/ HAL_HCD_CHANNEL_URB_STATE_STALL/

Peripheral Control functions

group HCD_Exported_Functions_Group3

Management functions.

 ===============================================================================
                      ##### Peripheral Control functions #####
 ===============================================================================
    [..]
    This subsection provides a set of functions allowing to control the HCD data
    transfers.

Functions

hal_status_t HAL_HCD_Start ( hal_hcd_handle_t * hhcd )

Start the host driver.

Parameters :

hhcd – HCD handle

Return values :

HAL – status

hal_status_t HAL_HCD_Stop ( hal_hcd_handle_t * hhcd )

Stop the host driver.

Parameters :

hhcd – HCD handle

Return values :

HAL – status

hal_status_t HAL_HCD_ResetPort ( hal_hcd_handle_t * hhcd )

Reset the host port.

Parameters :

hhcd – HCD handle

Return values :

HAL – status

hal_status_t HAL_HCD_SuspendPort ( hal_hcd_handle_t * hhcd )

Put the Device in suspend mode.

Parameters :

hhcd – HCD handle

Return values :

HAL – status

hal_status_t HAL_HCD_ResumePort ( hal_hcd_handle_t * hhcd )

Resme the host port.

Parameters :

hhcd – HCD handle

Return values :

HAL – status

Peripheral State functions

group HCD_Exported_Functions_Group4

Peripheral State functions.

 ===============================================================================
                      ##### Peripheral State functions #####
 ===============================================================================
    [..]
    This subsection permits to get in run-time the status of the peripheral
    and the data flow.

Functions

hal_hcd_state_t HAL_HCD_GetState ( const hal_hcd_handle_t * hhcd )

Return the HCD handle state.

Parameters :

hhcd – HCD handle

Return values :

HAL – state

hal_hcd_channel_urb_state_t HAL_HCD_GetChannelURBState ( const hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num )

Return URB state for a channel.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

Return values :

URB – state. This parameter can be one of these values: HAL_HCD_CHANNEL_URB_STATE_IDLE/ HAL_HCD_CHANNEL_URB_STATE_DONE/ HAL_HCD_CHANNEL_URB_STATE_NOTREADY/ HAL_HCD_CHANNEL_URB_STATE_ERROR/ HAL_HCD_CHANNEL_URB_STATE_STALL

hal_hcd_channel_state_t HAL_HCD_GetChannelState ( const hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num )

Return the Host Channel state.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 0 to 15

Return values :

Host – channel state This parameter can be one of these values: HAL_HCD_CHANNEL_STATE_RESET HAL_HCD_CHANNEL_STATE_IDLE HAL_HCD_CHANNEL_STATE_XFRC HAL_HCD_CHANNEL_STATE_HALTED HAL_HCD_CHANNEL_STATE_NYET HAL_HCD_CHANNEL_STATE_NAK HAL_HCD_CHANNEL_STATE_STALL HAL_HCD_CHANNEL_STATE_XACTERR HAL_HCD_CHANNEL_STATE_BBLERR HAL_HCD_CHANNEL_STATE_DATATGLERR

hal_hcd_port_speed_t HAL_HCD_GetPortSpeed ( const hal_hcd_handle_t * hhcd )

Return the Host enumeration speed.

Parameters :

hhcd – HCD handle

Return values :

Enumeration – speed

hal_hcd_dma_status_t HAL_HCD_IsEnabledDma ( const hal_hcd_handle_t * hhcd )

Return the HCD DMA status enabled or disabled.

Parameters :

hhcd – HCD handle

Return values :

state

uint32_t HAL_HCD_GetChannelTransferCount ( const hal_hcd_handle_t * hhcd , hal_hcd_channel_t ch_num )

Return the last host transfer size.

Parameters :
  • hhcd – HCD handle

  • ch_num – Channel number. This parameter can be a value from 1 to 15

Return values :

last – transfer size in byte

uint32_t HAL_HCD_GetCurrentFrame ( const hal_hcd_handle_t * hhcd )

Return the current Host frame number.

Parameters :

hhcd – HCD handle

Return values :

Current – Host frame number

Set/Get user data

group HCD_Exported_Functions_Group5

Functions

void HAL_HCD_SetUserData ( hal_hcd_handle_t * hhcd , const void * p_user_data )

Set the user data pointer into the handle.

Parameters :
const void * HAL_HCD_GetUserData ( const hal_hcd_handle_t * hhcd )

Get the user data pointer from the handle.

Parameters :

hhcd – Pointer to a hal_hcd_handle_t

Return values :

Pointer – to the user data.