USBHS low-level driver for USB host mode.
The UHD driver provides a low-level abstraction of the host controller hardware.
The defines UHD_ENABLE and UDD_ENABLE must be added in project to allow the USB low level (UHD) to manage or not the dual role (device and host).
The following USBHS driver configuration must be defined in conf_usb_host.h file of the application.
UHD_USB_INT_LEVEL
Option to change the interrupt priority (0 to 15) by default 5 (recommended).
UHD_USB_INT_FUN
Option to fit interrupt function to what defined in exception table.
UHD_ISOCHRONOUS_NB_BANK
Feature to reduce or increase isochronous endpoints buffering (1 to 2). Default value 2.
UHD_BULK_NB_BANK
Feature to reduce or increase bulk endpoints buffering (1 to 2). Default value 2.
UHD_INTERRUPT_NB_BANK
Feature to reduce or increase interrupt endpoints buffering (1 to 2). Default value 1.
UHD_BULK_INTERVAL_MIN
Feature to reduce or increase bulk token rate when it's NAKed (0, 1 ...). To adjust bandwidth usage. Default value 1.
UHD_NO_SLEEP_MGR
Feature to work without sleep manager module. Default not defined. Note that with this feature defined sleep manager must not be used in application.
The USB driver is fully managed by interrupt and does not request periodic task. Thereby, the USB events use callbacks to transfer the information. The callbacks can be declared in static during compilation or dynamically during code execution.
The driver uses the sleepmgr service to manage the different sleep modes. The sleep mode depends on USB driver state (uhd_uotghs_state_enum).
Most events coming from the hardware such as interrupts may cause the UHD performing function call in UHC and UHI.
Data Structures | |
struct | uhd_ctrl_request_t |
Structure to store the high level setup request. More... | |
struct | uhd_pipe_job_t |
Structure definition to store registered jobs on a pipe. More... | |
Macros | |
#define | UHD_BULK_INTERVAL_MIN 1 |
Minimal bulk interval value. More... | |
#define | UHD_BULK_NB_BANK 2 |
#define | UHD_INTERRUPT_NB_BANK 1 |
#define | UHD_ISOCHRONOUS_NB_BANK 2 |
Typedefs | |
typedef void(* | uhd_callback_reset_t )(void) |
End of reset callback function type. More... | |
typedef void(* | uhd_callback_setup_end_t )(usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans) |
End of setup callback function type. More... | |
typedef bool(* | uhd_callback_setup_run_t )(usb_add_t add, uint8_t **payload, uint16_t *payload_size) |
Data setup transfer callback function type. More... | |
typedef void(* | uhd_callback_trans_t )(usb_add_t add, usb_ep_t ep, uhd_trans_status_t status, iram_size_t nb_transfered) |
End of transfer callback function type. More... | |
Enumerations | |
enum | uhd_speed_t { UHD_SPEED_LOW = 0, UHD_SPEED_FULL = 1, UHD_SPEED_HIGH = 2 } |
Device speed. More... | |
enum | uhd_trans_status_t { UHD_TRANS_NOERROR = 0, UHD_TRANS_DISCONNECT, UHD_TRANS_CRC, UHD_TRANS_DT_MISMATCH, UHD_TRANS_STALL, UHD_TRANS_NOTRESPONDING, UHD_TRANS_PIDFAILURE, UHD_TRANS_TIMEOUT, UHD_TRANS_ABORTED } |
Endpoint transfer status The status field is updated after each transaction attempt, whether successful or not. More... | |
Functions | |
ISR (UHD_USB_INT_FUN) | |
Function called by USBHS interrupt handler to manage USB interrupts. More... | |
void | otg_dual_disable (void) |
Uninitialize the dual role This function is implemented in usbhs_host.c file. More... | |
bool | otg_dual_enable (void) |
Initialize the dual role This function is implemented in usbhs_host.c file. More... | |
static void | otg_id_handler (uint32_t id, uint32_t mask) |
USB ID pin change handler. More... | |
static void | uhd_ctrl_interrupt (void) |
Manages the events related to control endpoint. More... | |
static void | uhd_ctrl_phase_data_in (void) |
Manages the DATA IN phase on control endpoint. More... | |
static void | uhd_ctrl_phase_data_in_start (void) |
Starts the DATA IN phase on control endpoint. More... | |
static void | uhd_ctrl_phase_data_out (void) |
Manages the DATA OUT phase on control endpoint. More... | |
static void | uhd_ctrl_phase_setup (void) |
Sends a USB setup packet to start a control request sequence. More... | |
static void | uhd_ctrl_phase_zlp_in (void) |
Starts the ZLP IN phase on control endpoint. More... | |
static void | uhd_ctrl_phase_zlp_out (void) |
Starts the ZLP OUT phase on control endpoint. More... | |
static void | uhd_ctrl_request_end (uhd_trans_status_t status) |
Call the callback linked to control request and start the next request from the queue. More... | |
static void | uhd_ctrl_timeout (void) |
static void | uhd_delayed_resume (void) |
static void | uhd_delayed_suspend (void) |
void | uhd_disable (bool b_id_stop) |
Disables the USB host mode. More... | |
void | uhd_enable (void) |
Enables the USB host mode Start the ID pin management if the ID pin is available. More... | |
static void | uhd_ep_abort_pipe (uint8_t pipe, uhd_trans_status_t status) |
Aborts the on going transfer on a pipe. More... | |
uint16_t | uhd_get_frame_number (void) |
Returns the current Start Of Frame (SOF) number. More... | |
uint16_t | uhd_get_microframe_number (void) |
Returns the current micro start of frame number. More... | |
static uint8_t | uhd_get_pipe (usb_add_t add, usb_ep_t endp) |
Returns the pipe number matching a USB endpoint. More... | |
uhd_speed_t | uhd_get_speed (void) |
Returns the speed of connected device. More... | |
static void | uhd_interrupt (void) |
Function called by USBHS interrupt to manage USB host interrupts. More... | |
bool | uhd_is_suspend (void) |
Test if the suspend state is enabled on the USB line. More... | |
static void | uhd_pipe_finish_job (uint8_t pipe, uhd_trans_status_t status) |
Call the callback linked to the end of pipe transfer. More... | |
static uhd_trans_status_t | uhd_pipe_get_error (uint8_t pipe) |
Translates the USBHS pipe error to UHD error. More... | |
static void | uhd_pipe_in_received (uint8_t pipe) |
static void | uhd_pipe_interrupt (uint8_t pipe) |
Manages the following pipe interrupts: More... | |
static void | uhd_pipe_out_ready (uint8_t pipe) |
void | uhd_resume (void) |
Enables the IDLE state on the USB line. More... | |
void | uhd_send_reset (uhd_callback_reset_t callback) |
Enables the Reset state on the USB line. More... | |
bool | uhd_setup_request (usb_add_t add, usb_setup_req_t *req, uint8_t *payload, uint16_t payload_size, uhd_callback_setup_run_t callback_run, uhd_callback_setup_end_t callback_end) |
Add a setup request in the control endpoint setup queue. More... | |
static void | uhd_sof_interrupt (void) |
Manages timeouts and actions based on SOF events. More... | |
void | uhd_suspend (void) |
Enables the suspend state on the USB line. More... | |
static void | uhd_vbus_handler (uint32_t id, uint32_t mask) |
USB VBus pin change handler. More... | |
Variables | |
static bool | otg_initialized = false |
State of USBHS OTG initialization. More... | |
static uhd_callback_reset_t | uhd_reset_callback = NULL |
Store the callback to be call at the end of reset signal. More... | |
Power management | |
enum | uhd_usbhs_state_enum { UHD_STATE_OFF = 0, UHD_STATE_WAIT_ID_HOST = 1, UHD_STATE_NO_VBUS = 2, UHD_STATE_DISCONNECT = 3, UHD_STATE_SUSPEND = 4, UHD_STATE_IDLE = 5 } |
States of USBHS interface. More... | |
static void | uhd_sleep_mode (enum uhd_usbhs_state_enum new_state) |
Manages the sleep mode following the USBHS state. More... | |
Control endpoint low level management routine. | |
This function performs control endpoint management. It handles the SETUP/DATA/HANDSHAKE phases of a control transaction. | |
enum | uhd_ctrl_request_phase_t { UHD_CTRL_REQ_PHASE_SETUP = 0, UHD_CTRL_REQ_PHASE_DATA_OUT = 1, UHD_CTRL_REQ_PHASE_DATA_IN = 2, UHD_CTRL_REQ_PHASE_ZLP_IN = 3, UHD_CTRL_REQ_PHASE_ZLP_OUT = 4 } |
Bit definitions to store setup request state machine. More... | |
struct uhd_ctrl_request_t * | uhd_ctrl_request_first |
Entry points of setup request list. More... | |
struct uhd_ctrl_request_t * | uhd_ctrl_request_last |
volatile uint16_t | uhd_ctrl_request_timeout |
Remaining time for on-going setup request (No request on-going if equal 0) More... | |
uint16_t | uhd_ctrl_nb_trans |
Number of transfered byte on DATA phase of current setup request. More... | |
static bool | uhd_b_suspend_requested |
Flag to delay a suspend request after all on-going setup request. More... | |
uhd_ctrl_request_phase_t | uhd_ctrl_request_phase |
Management of bulk/interrupt/isochronous endpoints | |
The UHD manages the data transfer on endpoints:
| |
static uhd_pipe_job_t | uhd_pipe_job [USBHS_EPT_NUM-1] |
Array to register a job on bulk/interrupt/isochronous endpoint. More... | |
static uint8_t | uhd_suspend_start |
Variables to manage the suspend/resume sequence. More... | |
static uint8_t | uhd_resume_start |
static uint16_t | uhd_pipes_unfreeze |
USBHS Host IP properties | |
#define | uhd_get_pipe_max_nbr() (9) |
#define | USBHS_EPT_NUM (uhd_get_pipe_max_nbr()+1) |
#define | uhd_get_pipe_bank_max_nbr(ep) ((ep == 0) ? 1 : (( ep <= 2) ? 3 : 2)) |
Get maximal number of banks of endpoints. More... | |
#define | uhd_get_pipe_size_max(ep) (((ep) == 0) ? 64 : 1024) |
Get maximal size of endpoint (3X, 1024/64) More... | |
#define | Is_uhd_pipe_dma_supported(ep) ((((ep) >= 1) && ((ep) <= 7)) ? true : false) |
Get DMA support of endpoints. More... | |
#define | Is_uhd_pipe_high_bw_supported(ep) (((ep) >= 2) ? true : false) |
Get High Band Width support of endpoints. More... | |
#define | uhd_enable_vbus() (USBHS->USBHS_SFR = USBHS_SFR_VBUSRQS) |
#define | uhd_disable_vbus() (USBHS->USBHS_SCR = USBHS_SCR_VBUSRQC) |
Requests VBus deactivation. More... | |
#define | Is_uhd_vbus_enabled() (Tst_bits(USBHS->USBHS_SR, USBHS_SR_VBUSRQ)) |
Tests if VBus activation has been requested. More... | |
USB device connection/disconnection monitoring | |
#define | uhd_enable_connection_int() (USBHS->USBHS_HSTIER = USBHS_HSTIER_DCONNIES) |
#define | uhd_disable_connection_int() (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_DCONNIEC) |
#define | Is_uhd_connection_int_enabled() (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_DCONNIE)) |
#define | uhd_ack_connection() (USBHS->USBHS_HSTICR = USBHS_HSTICR_DCONNIC) |
#define | Is_uhd_connection() (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_DCONNI)) |
#define | uhd_raise_connection() (USBHS->USBHS_HSTIFR = USBHS_HSTIFR_DCONNIS) |
#define | uhd_enable_disconnection_int() (USBHS->USBHS_HSTIER = USBHS_HSTIER_DDISCIES) |
#define | uhd_disable_disconnection_int() (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_DDISCIEC) |
#define | Is_uhd_disconnection_int_enabled() (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_DDISCIE)) |
#define | uhd_ack_disconnection() (USBHS->USBHS_HSTICR = USBHS_HSTICR_DDISCIC) |
#define | Is_uhd_disconnection() (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_DDISCI)) |
#define | uhd_raise_disconnection() (USBHS->USBHS_HSTIFR = USBHS_HSTIFR_DDISCIS) |
USB device speed control | |
#define | uhd_get_speed_mode() (Rd_bits(USBHS->USBHS_SR, USBHS_SR_SPEED_Msk)) |
#define | Is_uhd_low_speed_mode() (uhd_get_speed_mode() == USBHS_SR_SPEED_LOW_SPEED) |
#define | Is_uhd_full_speed_mode() (uhd_get_speed_mode() == USBHS_SR_SPEED_FULL_SPEED) |
#define | Is_uhd_high_speed_mode() (uhd_get_speed_mode() == USBHS_SR_SPEED_HIGH_SPEED) |
#define | uhd_enable_high_speed_mode() (Wr_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SPDCONF_Msk, USBHS_HSTCTRL_SPDCONF_HIGH_SPEED)) |
Enable high speed mode. More... | |
#define | uhd_disable_high_speed_mode() (Wr_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SPDCONF_Msk, USBHS_HSTCTRL_SPDCONF_FORCED_FS)) |
Disable high speed mode. More... | |
Bus events control | |
These macros manage the bus events: reset, SOF, resume, wakeup. | |
#define | uhd_start_reset() (Set_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESET)) |
Initiates a reset event. More... | |
#define | Is_uhd_starting_reset() (Tst_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESET)) |
#define | uhd_stop_reset() (Clr_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESET)) |
#define | uhd_enable_reset_sent_interrupt() (USBHS->USBHS_HSTIER = USBHS_HSTIER_RSTIES) |
#define | uhd_disable_reset_sent_interrupt() (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_RSTIEC) |
#define | Is_uhd_reset_sent_interrupt_enabled() (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_RSTIE)) |
#define | uhd_ack_reset_sent() (USBHS->USBHS_HSTICR = USBHS_HSTICR_RSTIC) |
#define | Is_uhd_reset_sent() (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_RSTI)) |
#define | uhd_enable_sof() (Set_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SOFE)) |
Initiates a SOF events. More... | |
#define | uhd_disable_sof() (Clr_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SOFE)) |
#define | Is_uhd_sof_enabled() (Tst_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SOFE)) |
#define | uhd_get_sof_number() ((USBHS->USBHS_HSTFNUM & USBHS_HSTFNUM_FNUM_Msk) >> USBHS_HSTFNUM_FNUM_Pos) |
#define | uhd_get_microsof_number() |
#define | uhd_get_frame_position() (Rd_bitfield(USBHS->USBHS_HSTFNUM, USBHS_HSTFNUM_FLENHIGH_Msk)) |
#define | uhd_enable_sof_interrupt() (USBHS->USBHS_HSTIER = USBHS_HSTIER_HSOFIES) |
#define | uhd_disable_sof_interrupt() (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_HSOFIEC) |
#define | Is_uhd_sof_interrupt_enabled() (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_HSOFIE)) |
#define | uhd_ack_sof() (USBHS->USBHS_HSTICR = USBHS_HSTICR_HSOFIC) |
#define | Is_uhd_sof() (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_HSOFI)) |
#define | uhd_send_resume() (Set_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESUME)) |
Initiates a resume event It is called downstream resume event. More... | |
#define | Is_uhd_sending_resume() (Tst_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESUME)) |
#define | uhd_enable_downstream_resume_interrupt() (USBHS->USBHS_HSTIER = USBHS_HSTIER_RSMEDIES) |
#define | uhd_disable_downstream_resume_interrupt() (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_RSMEDIEC) |
#define | Is_uhd_downstream_resume_interrupt_enabled() (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_RSMEDIE)) |
#define | uhd_ack_downstream_resume() (USBHS->USBHS_HSTICR = USBHS_HSTICR_RSMEDIC) |
#define | Is_uhd_downstream_resume() (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_RSMEDI)) |
#define | uhd_enable_wakeup_interrupt() (USBHS->USBHS_HSTIER = USBHS_HSTIER_HWUPIES) |
Detection of a wake-up event A wake-up event is received when the host controller is in the suspend mode: More... | |
#define | uhd_disable_wakeup_interrupt() (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_HWUPIEC) |
#define | Is_uhd_wakeup_interrupt_enabled() (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_HWUPIE)) |
#define | uhd_ack_wakeup() (USBHS->USBHS_HSTICR = USBHS_HSTICR_HWUPIC) |
#define | Is_uhd_wakeup() (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_HWUPI)) |
#define | uhd_enable_upstream_resume_interrupt() (USBHS->USBHS_HSTIER = USBHS_HSTIER_RXRSMIES) |
#define | uhd_disable_upstream_resume_interrupt() (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_RXRSMIEC) |
#define | Is_uhd_upstream_resume_interrupt_enabled() (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_RXRSMIE)) |
#define | uhd_ack_upstream_resume() (USBHS->USBHS_HSTICR = USBHS_HSTICR_RXRSMIC) |
#define | Is_uhd_upstream_resume() (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_RXRSMI)) |
Endpoint Management | |
The following functions allow drivers to create and remove endpoints, as well as set, clear and query their "halted" and "wedged" states. | |
bool | uhd_ep0_alloc (usb_add_t add, uint8_t ep_size) |
Configures and enables a control endpoint 0. More... | |
bool | uhd_ep_alloc (usb_add_t add, usb_ep_desc_t *ep_desc, uhd_speed_t speed) |
Configures and enables an endpoint. More... | |
void | uhd_ep_free (usb_add_t add, usb_ep_t endp) |
Disables an endpoint or all endpoint of a device. More... | |
bool | uhd_ep_run (usb_add_t add, usb_ep_t endp, bool b_shortpacket, uint8_t *buf, iram_size_t buf_size, uint16_t timeout, uhd_callback_trans_t callback) |
Allows to receive or send data on an endpoint. More... | |
void | uhd_ep_abort (usb_add_t add, usb_ep_t endp) |
Aborts an on-going transfer on an endpoint. More... | |
High speed test mode management | |
The following functions allow the host to jump to a specific test mode required in high speed mode. | |
void | uhd_test_mode_j (void) |
void | uhd_test_mode_k (void) |
void | uhd_test_mode_se0_nak (void) |
void | uhd_test_mode_packet (void) |
UHC callbacks to provide for UHD | |
void | uhc_start (void) |
Starts the host mode. More... | |
void | uhc_stop (bool b_id_stop) |
Stops the host mode. More... | |
void | uhc_notify_connection (bool b_plug) |
Notify device connection or disconnection. More... | |
void | uhc_notify_sof (bool b_micro) |
Notify each start of frame sent by driver. More... | |
void | uhc_notify_resume (void) |
Notify that a resume bus occurs A resume can occur after a downstream or an upstream resume. More... | |
#define Is_uhd_connection | ( | ) | (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_DCONNI)) |
Referenced by uhd_interrupt().
#define Is_uhd_connection_int_enabled | ( | ) | (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_DCONNIE)) |
Referenced by uhd_interrupt().
#define Is_uhd_disconnection | ( | ) | (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_DDISCI)) |
Referenced by uhd_delayed_suspend(), and uhd_interrupt().
#define Is_uhd_disconnection_int_enabled | ( | ) | (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_DDISCIE)) |
Referenced by uhd_interrupt().
#define Is_uhd_downstream_resume | ( | ) | (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_RSMEDI)) |
Referenced by uhd_interrupt().
#define Is_uhd_downstream_resume_interrupt_enabled | ( | ) | (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_RSMEDIE)) |
#define Is_uhd_full_speed_mode | ( | ) | (uhd_get_speed_mode() == USBHS_SR_SPEED_FULL_SPEED) |
#define Is_uhd_high_speed_mode | ( | ) | (uhd_get_speed_mode() == USBHS_SR_SPEED_HIGH_SPEED) |
Referenced by uhd_interrupt(), and uhd_sof_interrupt().
#define Is_uhd_low_speed_mode | ( | ) | (uhd_get_speed_mode() == USBHS_SR_SPEED_LOW_SPEED) |
Referenced by uhd_interrupt().
Get DMA support of endpoints.
Referenced by uhd_ep_abort_pipe(), uhd_ep_run(), and uhd_pipe_interrupt().
Get High Band Width support of endpoints.
#define Is_uhd_reset_sent | ( | ) | (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_RSTI)) |
Referenced by uhd_interrupt().
#define Is_uhd_reset_sent_interrupt_enabled | ( | ) | (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_RSTIE)) |
#define Is_uhd_sending_resume | ( | ) | (Tst_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESUME)) |
#define Is_uhd_sof | ( | ) | (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_HSOFI)) |
Referenced by uhd_interrupt().
#define Is_uhd_sof_enabled | ( | ) | (Tst_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SOFE)) |
Referenced by uhd_is_suspend(), and uhd_resume().
#define Is_uhd_sof_interrupt_enabled | ( | ) | (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_HSOFIE)) |
#define Is_uhd_starting_reset | ( | ) | (Tst_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESET)) |
#define Is_uhd_upstream_resume | ( | ) | (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_RXRSMI)) |
Referenced by uhd_interrupt().
#define Is_uhd_upstream_resume_interrupt_enabled | ( | ) | (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_RXRSMIE)) |
#define Is_uhd_vbus_enabled | ( | ) | (Tst_bits(USBHS->USBHS_SR, USBHS_SR_VBUSRQ)) |
Tests if VBus activation has been requested.
#define Is_uhd_wakeup | ( | ) | (Tst_bits(USBHS->USBHS_HSTISR, USBHS_HSTISR_HWUPI)) |
Referenced by uhd_interrupt().
#define Is_uhd_wakeup_interrupt_enabled | ( | ) | (Tst_bits(USBHS->USBHS_HSTIMR, USBHS_HSTIMR_HWUPIE)) |
Referenced by uhd_interrupt().
#define uhd_ack_connection | ( | ) | (USBHS->USBHS_HSTICR = USBHS_HSTICR_DCONNIC) |
Referenced by uhd_interrupt().
#define uhd_ack_disconnection | ( | ) | (USBHS->USBHS_HSTICR = USBHS_HSTICR_DDISCIC) |
Referenced by uhd_interrupt().
#define uhd_ack_downstream_resume | ( | ) | (USBHS->USBHS_HSTICR = USBHS_HSTICR_RSMEDIC) |
#define uhd_ack_reset_sent | ( | ) | (USBHS->USBHS_HSTICR = USBHS_HSTICR_RSTIC) |
Referenced by uhd_interrupt().
#define uhd_ack_sof | ( | ) | (USBHS->USBHS_HSTICR = USBHS_HSTICR_HSOFIC) |
Referenced by uhd_sof_interrupt().
#define uhd_ack_upstream_resume | ( | ) | (USBHS->USBHS_HSTICR = USBHS_HSTICR_RXRSMIC) |
#define uhd_ack_wakeup | ( | ) | (USBHS->USBHS_HSTICR = USBHS_HSTICR_HWUPIC) |
Referenced by uhd_interrupt().
#define UHD_BULK_INTERVAL_MIN 1 |
Minimal bulk interval value.
Referenced by uhd_ep_alloc().
#define UHD_BULK_NB_BANK 2 |
Referenced by uhd_ep_alloc().
#define uhd_disable_connection_int | ( | ) | (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_DCONNIEC) |
Referenced by uhd_interrupt().
#define uhd_disable_disconnection_int | ( | ) | (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_DDISCIEC) |
Referenced by uhd_interrupt().
#define uhd_disable_downstream_resume_interrupt | ( | ) | (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_RSMEDIEC) |
#define uhd_disable_high_speed_mode | ( | ) | (Wr_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SPDCONF_Msk, USBHS_HSTCTRL_SPDCONF_FORCED_FS)) |
Disable high speed mode.
#define uhd_disable_reset_sent_interrupt | ( | ) | (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_RSTIEC) |
#define uhd_disable_sof | ( | ) | (Clr_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SOFE)) |
Referenced by uhd_delayed_suspend(), and uhd_disable().
#define uhd_disable_sof_interrupt | ( | ) | (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_HSOFIEC) |
#define uhd_disable_upstream_resume_interrupt | ( | ) | (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_RXRSMIEC) |
#define uhd_disable_vbus | ( | ) | (USBHS->USBHS_SCR = USBHS_SCR_VBUSRQC) |
Requests VBus deactivation.
Referenced by uhd_disable().
#define uhd_disable_wakeup_interrupt | ( | ) | (USBHS->USBHS_HSTIDR = USBHS_HSTIDR_HWUPIEC) |
#define uhd_enable_connection_int | ( | ) | (USBHS->USBHS_HSTIER = USBHS_HSTIER_DCONNIES) |
Referenced by uhd_interrupt().
#define uhd_enable_disconnection_int | ( | ) | (USBHS->USBHS_HSTIER = USBHS_HSTIER_DDISCIES) |
Referenced by uhd_interrupt().
#define uhd_enable_downstream_resume_interrupt | ( | ) | (USBHS->USBHS_HSTIER = USBHS_HSTIER_RSMEDIES) |
#define uhd_enable_high_speed_mode | ( | ) | (Wr_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SPDCONF_Msk, USBHS_HSTCTRL_SPDCONF_HIGH_SPEED)) |
Enable high speed mode.
#define uhd_enable_reset_sent_interrupt | ( | ) | (USBHS->USBHS_HSTIER = USBHS_HSTIER_RSTIES) |
#define uhd_enable_sof | ( | ) | (Set_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_SOFE)) |
Initiates a SOF events.
Referenced by uhd_interrupt(), and uhd_resume().
#define uhd_enable_sof_interrupt | ( | ) | (USBHS->USBHS_HSTIER = USBHS_HSTIER_HSOFIES) |
#define uhd_enable_upstream_resume_interrupt | ( | ) | (USBHS->USBHS_HSTIER = USBHS_HSTIER_RXRSMIES) |
#define uhd_enable_vbus | ( | ) | (USBHS->USBHS_SFR = USBHS_SFR_VBUSRQS) |
Requests VBus activation
Referenced by uhd_enable().
#define uhd_enable_wakeup_interrupt | ( | ) | (USBHS->USBHS_HSTIER = USBHS_HSTIER_HWUPIES) |
Detection of a wake-up event A wake-up event is received when the host controller is in the suspend mode:
Referenced by uhd_interrupt(), and uhd_vbus_handler().
#define uhd_get_frame_position | ( | ) | (Rd_bitfield(USBHS->USBHS_HSTFNUM, USBHS_HSTFNUM_FLENHIGH_Msk)) |
Referenced by uhd_delayed_suspend().
#define uhd_get_microsof_number | ( | ) |
Referenced by uhd_get_microframe_number().
#define uhd_get_pipe_bank_max_nbr | ( | ep | ) | ((ep == 0) ? 1 : (( ep <= 2) ? 3 : 2)) |
Get maximal number of banks of endpoints.
#define uhd_get_pipe_max_nbr | ( | ) | (9) |
#define uhd_get_pipe_size_max | ( | ep | ) | (((ep) == 0) ? 64 : 1024) |
Get maximal size of endpoint (3X, 1024/64)
#define uhd_get_sof_number | ( | ) | ((USBHS->USBHS_HSTFNUM & USBHS_HSTFNUM_FNUM_Msk) >> USBHS_HSTFNUM_FNUM_Pos) |
Referenced by uhd_get_frame_number().
#define uhd_get_speed_mode | ( | ) | (Rd_bits(USBHS->USBHS_SR, USBHS_SR_SPEED_Msk)) |
Referenced by uhd_delayed_suspend(), and uhd_get_speed().
#define UHD_INTERRUPT_NB_BANK 1 |
Referenced by uhd_ep_alloc().
#define UHD_ISOCHRONOUS_NB_BANK 2 |
Referenced by uhd_ep_alloc().
#define uhd_raise_connection | ( | ) | (USBHS->USBHS_HSTIFR = USBHS_HSTIFR_DCONNIS) |
#define uhd_raise_disconnection | ( | ) | (USBHS->USBHS_HSTIFR = USBHS_HSTIFR_DDISCIS) |
#define uhd_send_resume | ( | ) | (Set_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESUME)) |
Initiates a resume event It is called downstream resume event.
Referenced by uhd_interrupt(), and uhd_resume().
#define uhd_start_reset | ( | ) | (Set_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESET)) |
Initiates a reset event.
Referenced by uhd_send_reset().
#define uhd_stop_reset | ( | ) | (Clr_bits(USBHS->USBHS_HSTCTRL, USBHS_HSTCTRL_RESET)) |
Referenced by uhd_interrupt().
#define USBHS_EPT_NUM (uhd_get_pipe_max_nbr()+1) |
typedef void(* uhd_callback_reset_t)(void) |
End of reset callback function type.
Registered by uhd_send_reset() Callback called when reset event is completed.
typedef void(* uhd_callback_setup_end_t)(usb_add_t add, uhd_trans_status_t status, uint16_t payload_trans) |
End of setup callback function type.
Registered by uhd_setup_request() Called when the setup request is completed.
add | USB address of the setup request |
status | Transfer status |
payload_trans | Number of data transfered during DATA phase |
Data setup transfer callback function type.
Registered by uhd_setup_request() Called during DATA phase when the (payload) buffer is full or empty. Then the setup request is halted. A new buffer can be provided to continue the DATA phase or abort DATA phase.
add | USB address of the setup request |
payload | To return the next buffer address |
payload_size | To return the size of next buffer |
true
, if a new buffer is available, otherwise stop the request. typedef void(* uhd_callback_trans_t)(usb_add_t add, usb_ep_t ep, uhd_trans_status_t status, iram_size_t nb_transfered) |
End of transfer callback function type.
Registered by uhd_ep_run() Callback called by USB interrupt after data transfer or abort (reset,...).
add | USB address used by the transfer |
status | Transfer status |
nb_transfered | Number of data transfered |
Bit definitions to store setup request state machine.
enum uhd_speed_t |
enum uhd_trans_status_t |
Endpoint transfer status The status field is updated after each transaction attempt, whether successful or not.
enum uhd_usbhs_state_enum |
ISR | ( | UHD_USB_INT_FUN | ) |
Function called by USBHS interrupt handler to manage USB interrupts.
It manages the interrupt redirection between host or device interrupt. It answers to OTG events (ID pin change).
Note: Here, the global interrupt mask is not cleared when an USB interrupt is enabled because this one can not occurred during the USB ISR (=during INTX is masked). See Technical reference $3.8.3 Masking interrupt requests in peripheral modules.
References cpu_irq_disable, Is_otg_device_mode_forced, pmc_enable_periph_clk(), udd_interrupt(), and uhd_interrupt().
void otg_dual_disable | ( | void | ) |
Uninitialize the dual role This function is implemented in usbhs_host.c file.
References otg_disable, otg_freeze_clock, otg_id_interrupt_disable, otg_unfreeze_clock, pmc_clr_fast_startup_input(), pmc_disable_periph_clk(), sysclk_disable_usb(), uhd_sleep_mode(), and UHD_STATE_OFF.
Referenced by uhd_disable().
bool otg_dual_enable | ( | void | ) |
Initialize the dual role This function is implemented in usbhs_host.c file.
true
if the ID pin management has been started, otherwise false
. References Is_otg_id_device, otg_force_host_mode, otg_id_handler(), otg_id_init, pmc_enable_periph_clk(), pmc_set_fast_startup_input(), sysclk_enable_usb(), udc_start(), UHC_MODE_CHANGE, uhc_start(), uhd_sleep_mode(), UHD_STATE_OFF, UHD_STATE_WAIT_ID_HOST, and UHD_USB_INT_LEVEL.
Referenced by udd_enable(), and uhd_enable().
|
static |
USB ID pin change handler.
References Is_otg_id_device, otg_force_host_mode, udc_start(), udc_stop(), UHC_MODE_CHANGE, uhc_start(), and uhc_stop().
Referenced by otg_dual_enable().
void uhc_notify_connection | ( | bool | b_plug | ) |
Notify device connection or disconnection.
b_plug | Device connection, if true |
References uhc_device_t::address, Assert, uhc_connection_tree(), uhc_power_running, and UHC_USB_ADD_NOT_VALID.
Referenced by uhd_disable(), and uhd_interrupt().
void uhc_notify_resume | ( | void | ) |
Notify that a resume bus occurs A resume can occur after a downstream or an upstream resume.
References uhc_remotewakeup(), and UHC_WAKEUP_EVENT.
Referenced by uhd_delayed_resume().
void uhc_notify_sof | ( | bool | b_micro | ) |
Notify each start of frame sent by driver.
b_micro | It is a micro start of frame, if true |
References NULL, uhi_api_t::sof_notify, UHC_NB_UHI, uhc_sof_timeout, and uhc_sof_timeout_callback.
Referenced by uhd_sof_interrupt().
void uhc_start | ( | void | ) |
Starts the host mode.
void uhc_stop | ( | bool | b_id_stop | ) |
Stops the host mode.
|
static |
Manages the events related to control endpoint.
References Assert, usb_setup_req_t::bmRequestType, Is_uhd_in_received, Is_uhd_in_received_interrupt_enabled, Is_uhd_out_ready, Is_uhd_out_ready_interrupt_enabled, Is_uhd_pipe_error, Is_uhd_pipe_frozen, Is_uhd_setup_ready, Is_uhd_stall, uhd_ctrl_request_t::req, uhd_ack_in_received, uhd_ack_out_ready, uhd_ack_setup_ready, uhd_ack_stall, uhd_ctrl_phase_data_in(), uhd_ctrl_phase_data_in_start(), uhd_ctrl_phase_data_out(), uhd_ctrl_phase_zlp_in(), UHD_CTRL_REQ_PHASE_DATA_IN, UHD_CTRL_REQ_PHASE_DATA_OUT, UHD_CTRL_REQ_PHASE_SETUP, UHD_CTRL_REQ_PHASE_ZLP_IN, UHD_CTRL_REQ_PHASE_ZLP_OUT, uhd_ctrl_request_end(), uhd_enable_pipe_error_interrupt, uhd_enable_stall_interrupt, uhd_freeze_pipe, uhd_pipe_get_error(), uhd_reset_pipe, UHD_TRANS_NOERROR, UHD_TRANS_STALL, USB_REQ_DIR_IN, USB_REQ_DIR_MASK, and usb_setup_req_t::wLength.
Referenced by uhd_interrupt().
|
static |
Manages the DATA IN phase on control endpoint.
References uhd_ctrl_request_t::callback_run, Is_uhd_short_packet, NULL, uhd_ctrl_request_t::payload, uhd_ctrl_request_t::payload_size, uhd_ctrl_request_t::req, uhd_ack_fifocon, uhd_ack_short_packet, uhd_byte_count, uhd_ctrl_phase_zlp_out(), uhd_enable_in_received_interrupt, uhd_get_configured_address, uhd_get_pipe_fifo_access, uhd_get_pipe_size, uhd_unfreeze_pipe, and usb_setup_req_t::wLength.
Referenced by uhd_ctrl_interrupt().
|
static |
Starts the DATA IN phase on control endpoint.
References uhd_ack_fifocon, uhd_ack_in_received, uhd_ack_short_packet, uhd_configure_pipe_token, UHD_CTRL_REQ_PHASE_DATA_IN, uhd_enable_in_received_interrupt, and uhd_unfreeze_pipe.
Referenced by uhd_ctrl_interrupt().
|
static |
Manages the DATA OUT phase on control endpoint.
References uhd_ctrl_request_t::callback_run, NULL, uhd_ctrl_request_t::payload, uhd_ctrl_request_t::payload_size, uhd_ctrl_request_t::req, uhd_ack_fifocon, uhd_ack_out_ready, uhd_configure_pipe_token, uhd_ctrl_phase_zlp_in(), UHD_CTRL_REQ_PHASE_DATA_OUT, uhd_enable_out_ready_interrupt, uhd_get_configured_address, uhd_get_pipe_fifo_access, uhd_get_pipe_size, uhd_unfreeze_pipe, and usb_setup_req_t::wLength.
Referenced by uhd_ctrl_interrupt().
|
static |
Sends a USB setup packet to start a control request sequence.
References uhd_ctrl_request_t::add, Assert, cpu_to_le16, Is_uhd_pipe_enabled, uhd_ctrl_request_t::req, uhd_ack_fifocon, uhd_ack_setup_ready, uhd_configure_address, uhd_configure_pipe_token, UHD_CTRL_REQ_PHASE_SETUP, uhd_ctrl_request_end(), uhd_enable_setup_ready_interrupt, uhd_get_configured_address, uhd_get_pipe_fifo_access, UHD_TRANS_DISCONNECT, and uhd_unfreeze_pipe.
Referenced by uhd_ctrl_request_end(), and uhd_setup_request().
|
static |
Starts the ZLP IN phase on control endpoint.
References uhd_ack_fifocon, uhd_ack_in_received, uhd_ack_short_packet, uhd_configure_pipe_token, UHD_CTRL_REQ_PHASE_ZLP_IN, uhd_enable_in_received_interrupt, and uhd_unfreeze_pipe.
Referenced by uhd_ctrl_interrupt(), and uhd_ctrl_phase_data_out().
|
static |
Starts the ZLP OUT phase on control endpoint.
References uhd_ack_fifocon, uhd_ack_out_ready, uhd_configure_pipe_token, UHD_CTRL_REQ_PHASE_ZLP_OUT, uhd_enable_out_ready_interrupt, and uhd_unfreeze_pipe.
Referenced by uhd_ctrl_phase_data_in().
|
static |
Call the callback linked to control request and start the next request from the queue.
References uhd_ctrl_request_t::callback_end, cpu_irq_restore(), cpu_irq_save(), uhd_ctrl_request_t::next_request, NULL, uhd_ctrl_phase_setup(), uhd_ctrl_request_first, uhd_get_configured_address, and uhd_suspend().
Referenced by uhd_ctrl_interrupt(), uhd_ctrl_phase_setup(), uhd_ctrl_timeout(), and uhd_ep_free().
|
static |
References uhd_ctrl_request_end(), uhd_enable_pipe_error_interrupt, uhd_enable_stall_interrupt, uhd_reset_pipe, and UHD_TRANS_TIMEOUT.
Referenced by uhd_sof_interrupt().
|
static |
References uhc_notify_resume(), uhd_unfreeze_pipe, and USBHS_EPT_NUM.
Referenced by uhd_sof_interrupt().
|
static |
References barrier, Is_uhd_disconnection, otg_freeze_clock, uhd_disable_sof, uhd_get_frame_position, uhd_get_speed_mode, uhd_sleep_mode(), and UHD_STATE_SUSPEND.
Referenced by uhd_sof_interrupt().
void uhd_disable | ( | bool | b_id_stop | ) |
Disables the USB host mode.
b_id_stop | Stop ID pin management, if true. |
References cpu_irq_restore(), cpu_irq_save(), Is_otg_clock_usable, otg_disable, otg_dual_disable(), otg_freeze_clock, otg_unfreeze_clock, uhc_notify_connection(), uhd_disable_sof, uhd_disable_vbus, uhd_sleep_mode(), and UHD_STATE_WAIT_ID_HOST.
Referenced by uhc_stop().
void uhd_enable | ( | void | ) |
Enables the USB host mode Start the ID pin management if the ID pin is available.
References cpu_irq_restore(), cpu_irq_save(), Is_otg_clock_usable, Is_otg_id_device, Is_otg_vbus_high, NULL, otg_dual_enable(), otg_enable, otg_force_host_mode, otg_unfreeze_clock, otg_vbus_init, pmc_enable_periph_clk(), pmc_set_fast_startup_input(), sysclk_enable_usb(), uhd_enable_vbus, uhd_sleep_mode(), UHD_STATE_DISCONNECT, UHD_STATE_NO_VBUS, UHD_STATE_OFF, UHD_USB_INT_LEVEL, and uhd_vbus_handler().
Referenced by uhc_start().
Configures and enables a control endpoint 0.
add | USB address of endpoint |
ep_size | Endpoint control maximum size |
1
if the endpoint is enabled, otherwise 0
. References Is_uhd_pipe_configured, Is_uhd_pipe_enabled, uhd_allocate_memory, uhd_configure_address, uhd_configure_pipe, uhd_disable_pipe, uhd_enable_pipe, uhd_enable_pipe_error_interrupt, uhd_enable_pipe_interrupt, and uhd_enable_stall_interrupt.
Referenced by uhc_enumeration_step11(), uhc_enumeration_step5(), and uhc_enumeration_step9().
Aborts an on-going transfer on an endpoint.
If a transfer is on going, then it is stopped and the callback registered is called to signal the end of transfer. Note: The control endpoint is not authorized.
add | USB address of endpoint |
endp | Endpoint to abort |
References uhd_ep_abort_pipe(), uhd_get_pipe(), UHD_TRANS_ABORTED, and USBHS_EPT_NUM.
|
static |
Aborts the on going transfer on a pipe.
pipe | Pipe number |
status | Reason of abort |
References uhd_pipe_job_t::buf, Is_uhd_pipe_dma_supported, uhd_pipe_job_t::nb_trans, uhd_disable_in_received_interrupt, uhd_disable_nak_received_interrupt, uhd_disable_out_ready_interrupt, uhd_enable_pipe_bank_autoswitch, uhd_enable_pipe_error_interrupt, uhd_enable_stall_interrupt, uhd_freeze_pipe, uhd_pipe_dma_get_addr, uhd_pipe_dma_set_control, uhd_pipe_finish_job(), and uhd_reset_pipe.
Referenced by uhd_ep_abort(), uhd_ep_free(), uhd_pipe_interrupt(), and uhd_sof_interrupt().
bool uhd_ep_alloc | ( | usb_add_t | add, |
usb_ep_desc_t * | ep_desc, | ||
uhd_speed_t | speed | ||
) |
Configures and enables an endpoint.
add | USB address of endpoint |
ep_desc | Endpoint descriptor |
speed | Endpoint working speed |
1
if the endpoint is enabled, otherwise 0
. References Assert, usb_ep_desc_t::bEndpointAddress, usb_ep_desc_t::bInterval, usb_ep_desc_t::bmAttributes, Is_uhd_pipe_configured, Is_uhd_pipe_enabled, le16_to_cpu, uhd_allocate_memory, UHD_BULK_INTERVAL_MIN, UHD_BULK_NB_BANK, uhd_configure_address, uhd_configure_pipe, uhd_disable_pipe, uhd_enable_pipe, uhd_enable_pipe_dma_interrupt, uhd_enable_pipe_error_interrupt, uhd_enable_pipe_interrupt, uhd_enable_stall_interrupt, UHD_INTERRUPT_NB_BANK, UHD_ISOCHRONOUS_NB_BANK, UHD_SPEED_HIGH, USB_EP_ADDR_MASK, USB_EP_DIR_IN, USB_EP_TYPE_BULK, USB_EP_TYPE_INTERRUPT, USB_EP_TYPE_ISOCHRONOUS, USB_EP_TYPE_MASK, USBHS_EPT_NUM, and usb_ep_desc_t::wMaxPacketSize.
Referenced by uhi_aoa_install(), uhi_cdc_install(), uhi_hid_mouse_install(), and uhi_vendor_install().
Disables an endpoint or all endpoint of a device.
add | USB address of endpoint |
endp | Endpoint number and direction (USB_EP_DIR_IN/OUT). Remove all endpoints of USB address, if 0xFF. |
References uhd_ctrl_request_t::add, Is_uhd_pipe_enabled, uhd_ctrl_request_end(), uhd_ep_abort_pipe(), uhd_get_configured_address, uhd_get_pipe_endpoint_address, UHD_TRANS_DISCONNECT, and USBHS_EPT_NUM.
Referenced by uhc_connection_tree(), uhc_enumeration_error(), uhc_enumeration_step11(), uhc_enumeration_step14(), uhc_enumeration_step5(), uhc_enumeration_step9(), and uhi_aoa_install().
bool uhd_ep_run | ( | usb_add_t | add, |
usb_ep_t | endp, | ||
bool | b_shortpacket, | ||
uint8_t * | buf, | ||
iram_size_t | buf_size, | ||
uint16_t | timeout, | ||
uhd_callback_trans_t | callback | ||
) |
Allows to receive or send data on an endpoint.
If a USB DMA is available, the driver uses it to transfer endpoint data from or to internal RAM. When the transfer is finished or aborted (stall, reset, ...), the callback is called. This callback returns the transfer status and eventually the number of byte transfered. Note: The control endpoint is not authorized.
add | USB address of endpoint |
endp | Endpoint number |
b_shortpacket | Enabled automatic short packet |
buf | Buffer on Internal RAM to send or fill. It must be align, then use COMPILER_WORD_ALIGNED. |
buf_size | Buffer size to send or fill |
timeout | Transfer timeout (ms) |
callback | NULL or function to call at the end of transfer |
1
if function was successfully done, otherwise 0
. References uhd_pipe_job_t::b_periodic_start, uhd_pipe_job_t::b_shortpacket, uhd_pipe_job_t::buf, uhd_pipe_job_t::buf_size, uhd_pipe_job_t::busy, uhd_pipe_job_t::call_end, callback, cpu_irq_restore(), cpu_irq_save(), Is_uhd_pipe_bulk, Is_uhd_pipe_dma_supported, Is_uhd_pipe_int, Is_uhd_pipe_iso, Is_uhd_pipe_out, uhd_pipe_job_t::nb_trans, uhd_pipe_job_t::timeout, uhd_ack_nak_received, uhd_disable_bank_interrupt, uhd_disable_pipe_bank_autoswitch, uhd_enable_continuous_in_mode, uhd_enable_in_received_interrupt, uhd_enable_nak_received_interrupt, uhd_enable_out_ready_interrupt, uhd_enable_pipe_interrupt, uhd_enable_short_packet_interrupt, uhd_get_pipe(), uhd_is_pipe_in, uhd_unfreeze_pipe, and USBHS_EPT_NUM.
Referenced by uhi_aoa_read(), uhi_aoa_write(), uhi_cdc_rx_update(), uhi_cdc_tx_update(), uhi_hid_mouse_start_trans_report(), uhi_msc_transfer(), uhi_vendor_bulk_in_run(), uhi_vendor_bulk_out_run(), uhi_vendor_int_in_run(), uhi_vendor_int_out_run(), uhi_vendor_iso_in_run(), and uhi_vendor_iso_out_run().
uint16_t uhd_get_frame_number | ( | void | ) |
Returns the current Start Of Frame (SOF) number.
References uhd_get_sof_number.
Referenced by uhi_cdc_rx_received(), uhi_cdc_rx_update(), uhi_cdc_tx_send(), and uhi_cdc_tx_update().
uint16_t uhd_get_microframe_number | ( | void | ) |
Returns the current micro start of frame number.
References uhd_get_microsof_number.
Referenced by uhi_cdc_rx_received(), uhi_cdc_rx_update(), uhi_cdc_tx_send(), and uhi_cdc_tx_update().
Returns the pipe number matching a USB endpoint.
add | USB address |
endp | Endpoint number |
References Is_uhd_pipe_enabled, uhd_get_configured_address, uhd_get_pipe_endpoint_address, and USBHS_EPT_NUM.
Referenced by uhd_ep_abort(), and uhd_ep_run().
uhd_speed_t uhd_get_speed | ( | void | ) |
Returns the speed of connected device.
References Assert, uhd_get_speed_mode, UHD_SPEED_FULL, UHD_SPEED_HIGH, and UHD_SPEED_LOW.
Referenced by uhc_enumeration_step4().
|
static |
Function called by USBHS interrupt to manage USB host interrupts.
USB host interrupt events are split into four sections:
References Assert, Is_otg_clock_usable, Is_uhd_connection, Is_uhd_connection_int_enabled, Is_uhd_disconnection, Is_uhd_disconnection_int_enabled, Is_uhd_downstream_resume, Is_uhd_high_speed_mode, Is_uhd_low_speed_mode, Is_uhd_reset_sent, Is_uhd_sof, Is_uhd_upstream_resume, Is_uhd_wakeup, Is_uhd_wakeup_interrupt_enabled, NULL, uhc_notify_connection(), uhd_ack_connection, uhd_ack_disconnection, uhd_ack_reset_sent, uhd_ack_wakeup, uhd_ctrl_interrupt(), uhd_disable_connection_int, uhd_disable_disconnection_int, uhd_enable_connection_int, uhd_enable_disconnection_int, uhd_enable_sof, uhd_enable_wakeup_interrupt, uhd_get_interrupt_pipe_number(), uhd_get_pipe_dma_interrupt_number(), uhd_pipe_interrupt(), uhd_reset_callback, uhd_send_resume, uhd_sleep_mode(), uhd_sof_interrupt(), UHD_STATE_DISCONNECT, UHD_STATE_IDLE, uhd_stop_reset, and USBHS_EPT_NUM.
Referenced by ISR().
bool uhd_is_suspend | ( | void | ) |
Test if the suspend state is enabled on the USB line.
References Is_uhd_sof_enabled.
Referenced by uhc_is_suspend().
|
static |
Call the callback linked to the end of pipe transfer.
pipe | Pipe number |
status | Status of the transfer |
References uhd_pipe_job_t::busy, uhd_pipe_job_t::call_end, uhd_pipe_job_t::nb_trans, NULL, uhd_disable_pipe, uhd_get_configured_address, uhd_get_pipe_endpoint_address, UHD_TRANS_DISCONNECT, and uhd_unallocate_memory.
Referenced by uhd_ep_abort_pipe(), uhd_pipe_in_received(), and uhd_pipe_interrupt().
|
static |
Translates the USBHS pipe error to UHD error.
pipe | Pipe number to use |
References uhd_ack_all_errors, uhd_error_status, UHD_TRANS_DT_MISMATCH, UHD_TRANS_NOTRESPONDING, and UHD_TRANS_PIDFAILURE.
Referenced by uhd_ctrl_interrupt(), and uhd_pipe_interrupt().
|
static |
References uhd_pipe_job_t::buf, uhd_pipe_job_t::buf_size, uhd_pipe_job_t::busy, uhd_pipe_job_t::nb_trans, uhd_ack_fifocon, uhd_byte_count, uhd_disable_continuous_in_mode, uhd_disable_in_received_interrupt, uhd_disable_nak_received_interrupt, uhd_disable_pipe_interrupt, uhd_disable_short_packet_interrupt, uhd_freeze_pipe, uhd_get_pipe_fifo_access, uhd_get_pipe_size, uhd_pipe_finish_job(), and UHD_TRANS_NOERROR.
Referenced by uhd_pipe_interrupt().
|
static |
Manages the following pipe interrupts:
pipe | Pipe number |
References Assert, Is_uhd_bank_interrupt_enabled, Is_uhd_in_received, Is_uhd_in_received_interrupt_enabled, Is_uhd_nak_received, Is_uhd_nak_received_interrupt_enabled, Is_uhd_out_ready, Is_uhd_out_ready_interrupt_enabled, Is_uhd_pipe_bulk_in, Is_uhd_pipe_dma_supported, Is_uhd_pipe_error, Is_uhd_pipe_iso, Is_uhd_short_packet, Is_uhd_short_packet_interrupt_enabled, Is_uhd_stall, uhd_ack_fifocon, uhd_ack_in_received, uhd_ack_nak_received, uhd_ack_out_ready, uhd_ack_short_packet, uhd_ack_stall, uhd_disable_bank_interrupt, uhd_disable_out_ready_interrupt, uhd_disable_pipe_interrupt, uhd_enable_bank_interrupt, uhd_enable_pipe_bank_autoswitch, uhd_ep_abort_pipe(), uhd_freeze_pipe, uhd_nb_busy_bank, uhd_pipe_finish_job(), uhd_pipe_get_error(), uhd_pipe_in_received(), uhd_pipe_out_ready(), uhd_reset_data_toggle, UHD_TRANS_NOERROR, UHD_TRANS_STALL, and uhd_unfreeze_pipe.
Referenced by uhd_interrupt().
|
static |
References uhd_pipe_job_t::b_shortpacket, uhd_pipe_job_t::buf, uhd_pipe_job_t::buf_size, uhd_pipe_job_t::busy, min, uhd_pipe_job_t::nb_trans, uhd_ack_fifocon, uhd_ack_out_ready, uhd_disable_out_ready_interrupt, uhd_enable_bank_interrupt, uhd_get_pipe_fifo_access, and uhd_get_pipe_size.
Referenced by uhd_pipe_interrupt().
void uhd_resume | ( | void | ) |
Enables the IDLE state on the USB line.
The IDLE state is enable when SOF are present on USB line. A Downstream Resume signal can be sent.
References Is_otg_clock_usable, Is_uhd_sof_enabled, otg_unfreeze_clock, uhd_enable_sof, uhd_send_resume, uhd_sleep_mode(), and UHD_STATE_IDLE.
Referenced by uhc_resume().
void uhd_send_reset | ( | uhd_callback_reset_t | callback | ) |
Enables the Reset state on the USB line.
callback | Callback when reset sequence is finished |
References callback, and uhd_start_reset.
Referenced by uhc_enumeration_reset().
bool uhd_setup_request | ( | usb_add_t | add, |
usb_setup_req_t * | req, | ||
uint8_t * | payload, | ||
uint16_t | payload_size, | ||
uhd_callback_setup_run_t | callback_run, | ||
uhd_callback_setup_end_t | callback_end | ||
) |
Add a setup request in the control endpoint setup queue.
Note: Request timeout is 5s.
add | USB address of control endpoint |
req | Setup request definition |
payload | Buffer to use in setup DATA phase |
payload_size | Size of buffer used in DATA phase |
callback_run | Callback to call if buffer is empty or full |
callback_end | Callback to call when request is finish |
true
if the request has been accepted, otherwise false
. Note: The swap of "req.wValues" from uin16_t to le16_t is done by UHD. References uhd_ctrl_request_t::add, Assert, uhd_ctrl_request_t::callback_end, uhd_ctrl_request_t::callback_run, cpu_irq_restore(), cpu_irq_save(), uhd_ctrl_request_t::next_request, NULL, uhd_ctrl_request_t::payload, uhd_ctrl_request_t::payload_size, uhd_ctrl_request_t::req, and uhd_ctrl_phase_setup().
Referenced by uhc_dev_get_string(), uhc_dev_is_high_speed_support(), uhc_enumeration_step11(), uhc_enumeration_step12(), uhc_enumeration_step13(), uhc_enumeration_step14(), uhc_enumeration_step5(), uhc_enumeration_step9(), uhc_remotewakeup(), uhi_aoa_mode_enable_step1(), uhi_aoa_mode_enable_step3(), uhi_aoa_register_hid(), uhi_aoa_send_hid_event(), uhi_aoa_send_info_string(), uhi_aoa_unregister_hid(), uhi_cdc_set_conf(), uhi_cdc_set_ctrl_line(), uhi_msc_enable_step1(), uhi_msc_reset_endpoint(), uhi_vendor_control_in_run(), uhi_vendor_control_out_run(), and uhi_vendor_enable().
|
static |
Manages the sleep mode following the USBHS state.
new_state | New USBHS state |
References SLEEPMGR_BACKUP, sleepmgr_lock_mode(), SLEEPMGR_SLEEP_WFI, sleepmgr_unlock_mode(), SLEEPMGR_WAIT_FAST, and UHD_STATE_OFF.
Referenced by otg_dual_disable(), otg_dual_enable(), uhd_delayed_suspend(), uhd_disable(), uhd_enable(), uhd_interrupt(), uhd_resume(), and uhd_vbus_handler().
|
static |
Manages timeouts and actions based on SOF events.
References uhd_pipe_job_t::b_periodic_start, uhd_pipe_job_t::busy, Is_uhd_high_speed_mode, Is_uhd_pipe_bulk_in, Is_uhd_pipe_frozen, uhd_pipe_job_t::timeout, uhc_notify_sof(), UHC_SOF_EVENT, uhd_ack_sof, uhd_ctrl_timeout(), uhd_delayed_resume(), uhd_delayed_suspend(), uhd_ep_abort_pipe(), UHD_TRANS_TIMEOUT, uhd_unfreeze_pipe, and USBHS_EPT_NUM.
Referenced by uhd_interrupt().
void uhd_suspend | ( | void | ) |
Enables the suspend state on the USB line.
The SUSPEND state is enable when SOF are disabled on USB line.
References Is_uhd_pipe_frozen, uhd_freeze_pipe, and USBHS_EPT_NUM.
Referenced by uhc_enumeration_suspend(), uhc_suspend(), and uhd_ctrl_request_end().
void uhd_test_mode_j | ( | void | ) |
void uhd_test_mode_k | ( | void | ) |
void uhd_test_mode_packet | ( | void | ) |
void uhd_test_mode_se0_nak | ( | void | ) |
|
static |
USB VBus pin change handler.
References Is_otg_vbus_high, otg_freeze_clock, otg_unfreeze_clock, UHC_VBUS_CHANGE, uhd_enable_wakeup_interrupt, uhd_sleep_mode(), UHD_STATE_DISCONNECT, and UHD_STATE_NO_VBUS.
Referenced by uhd_enable().
|
static |
Flag to delay a suspend request after all on-going setup request.
uint16_t uhd_ctrl_nb_trans |
Number of transfered byte on DATA phase of current setup request.
struct uhd_ctrl_request_t* uhd_ctrl_request_first |
Entry points of setup request list.
Referenced by uhd_ctrl_request_end().
struct uhd_ctrl_request_t* uhd_ctrl_request_last |
uhd_ctrl_request_phase_t uhd_ctrl_request_phase |
volatile uint16_t uhd_ctrl_request_timeout |
Remaining time for on-going setup request (No request on-going if equal 0)
|
static |
Array to register a job on bulk/interrupt/isochronous endpoint.
|
static |
|
static |
Store the callback to be call at the end of reset signal.
Referenced by uhd_interrupt().
|
static |
|
static |
Variables to manage the suspend/resume sequence.