USB low-level driver for USB Host mode.
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 | dbg_print(...) |
#define | UHD_ENDPOINT_MAX_TRANS ((8 *1024 ) - 1) |
#define | USB_STATUS_PIPE_CRC16ER (1 << 4) |
#define | USB_STATUS_PIPE_DAPIDER (1 << 1) |
#define | USB_STATUS_PIPE_DTGLER (1 << 0) |
#define | USB_STATUS_PIPE_PIDER (1 << 2) |
#define | USB_STATUS_PIPE_TOUTER (1 << 3) |
Functions | |
static void | _uhd_connect (struct usb_module *module_inst) |
Manages connection interrupt. More... | |
static void | _uhd_ctrl_phase_data_in (uint16_t nb_byte_received) |
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. More... | |
static void | _uhd_disconnect (struct usb_module *module_inst) |
Manages disconnection interrupt. More... | |
static void | _uhd_downstream_resume (struct usb_module *module_inst) |
Manages downstream resume interrupt. More... | |
static void | _uhd_ep0_error (struct usb_module *module_inst, void *pointer) |
Manages endpoint 0 error interrupt. More... | |
static void | _uhd_ep0_setup (struct usb_module *module_inst, void *null) |
Manages endpoint 0 setup interrupt. More... | |
static void | _uhd_ep0_stall (struct usb_module *module_inst, void *null) |
Manages endpoint 0 stall interrupt. More... | |
static void | _uhd_ep0_transfer_complete (struct usb_module *module_inst, void *pointer) |
Manages endpoint 0 transfer complete interrupt. More... | |
static void | _uhd_ep_abort_pipe (uint8_t pipe, uhd_trans_status_t status) |
Aborts the on-going transfer on a pipe. More... | |
static void | _uhd_ep_error (struct usb_module *module_inst, void *pointer) |
Manages pipe endpoint error callback. More... | |
static void | _uhd_ep_stall (struct usb_module *module_inst, void *pointer) |
Manages pipe endpoint stall interrupt. More... | |
static uint8_t | _uhd_get_pipe (usb_add_t add, usb_ep_t endp) |
Returns the pipe number matching a USB endpoint. 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 void | _uhd_pipe_trans_complete (struct usb_module *module_inst, void *pointer) |
Computes and starts the next transfer on a pipe. More... | |
static void | _uhd_ram_error (struct usb_module *module_inst) |
Manages ram access error interrupt. More... | |
static void | _uhd_reset (struct usb_module *module_inst) |
Manages bus reset interrupt. More... | |
static void | _uhd_sof_interrupt (struct usb_module *module_inst) |
Manages timeouts and actions based on SOF events. More... | |
static void | _uhd_upstream_resume (struct usb_module *module_inst) |
Manages upstream resume interrupt. More... | |
static void | _uhd_wakeup (struct usb_module *module_inst) |
Manages wakeup interrupt. More... | |
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... | |
bool | uhd_ep0_alloc (usb_add_t add, uint8_t ep_size) |
Configures and enables a control endpoint 0. More... | |
void | uhd_ep_abort (usb_add_t add, usb_ep_t endp) |
Aborts an on-going transfer on an endpoint. 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... | |
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... | |
uhd_speed_t | uhd_get_speed (void) |
Returns the speed of connected device. More... | |
bool | uhd_is_suspend (void) |
Test if the suspend state is enabled on the USB line. More... | |
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... | |
void | uhd_suspend (void) |
Enables the suspend state on the USB line. More... | |
bool | uhd_suspend_lpm (bool b_remotewakeup, uint8_t hird) |
Enables the suspend L1 state on the USB line. More... | |
Variables | |
struct usb_module | dev |
static bool | uhd_lpm_suspend = false |
Notify that USB Host is enter in suspend LPM state. More... | |
static uhd_callback_reset_t | uhd_reset_callback = NULL |
Store the callback to be called at the end of reset signal. More... | |
Power management | |
enum | uhd_usb_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_SUSPEND_LPM = 5, UHD_STATE_IDLE = 6 } |
States of USB interface. More... | |
enum sleepmgr_mode | sleep_mode [] |
static enum uhd_usb_state_enum | uhd_state = UHD_STATE_OFF |
static void | uhd_sleep_mode (enum uhd_usb_state_enum new_state) |
Manages the sleep mode following the USB 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... | |
uint8_t | uhd_ctrl_buffer [64] |
Buffer to store the sent/received data on control endpoint. 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 [USB_PIPE_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 uint8_t | uhd_pipes_unfreeze |
#define dbg_print | ( | ... | ) |
Referenced by _uhd_connect(), _uhd_disconnect(), _uhd_downstream_resume(), _uhd_ep0_error(), _uhd_ep0_setup(), _uhd_ep0_stall(), _uhd_ep0_transfer_complete(), _uhd_ep_error(), _uhd_ep_stall(), _uhd_ram_error(), _uhd_sof_interrupt(), _uhd_upstream_resume(), _uhd_wakeup(), uhd_enable(), uhd_resume(), and uhd_suspend_lpm().
#define UHD_ENDPOINT_MAX_TRANS ((8 *1024 ) - 1) |
Referenced by _uhd_pipe_trans_complete().
#define USB_STATUS_PIPE_CRC16ER (1 << 4) |
Referenced by _uhd_ep0_error(), and _uhd_ep_error().
#define USB_STATUS_PIPE_DAPIDER (1 << 1) |
Referenced by _uhd_ep0_error(), and _uhd_ep_error().
#define USB_STATUS_PIPE_DTGLER (1 << 0) |
Referenced by _uhd_ep0_error(), and _uhd_ep_error().
#define USB_STATUS_PIPE_PIDER (1 << 2) |
Referenced by _uhd_ep0_error(), and _uhd_ep_error().
#define USB_STATUS_PIPE_TOUTER (1 << 3) |
Referenced by _uhd_ep0_error(), and _uhd_ep_error().
Bit definitions to store setup request state machine.
enum uhd_usb_state_enum |
|
static |
Manages connection interrupt.
module_inst | Pointer to USB module instance |
References dbg_print, dev, uhc_notify_connection(), uhd_resume_start, uhd_sleep_mode(), UHD_STATE_IDLE, uhd_suspend_start, USB_HOST_CALLBACK_CONNECT, USB_HOST_CALLBACK_DISCONNECT, USB_HOST_CALLBACK_WAKEUP, usb_host_disable_callback(), usb_host_enable_callback(), and usb_host_enable_sof().
Referenced by uhd_enable().
|
static |
Manages the DATA IN phase on control endpoint.
nb_byte_received | Number of bytes received |
In HUB mode, the control pipe is always configured to 64B
thus the short packet flag must be computed
References _uhd_ctrl_phase_zlp_out(), uhd_ctrl_request_t::callback_run, dev, usb_host_pipe_config::device_address, NULL, uhd_ctrl_request_t::payload, uhd_ctrl_request_t::payload_size, uhd_ctrl_request_t::req, usb_host_pipe_config::size, uhd_ctrl_buffer, uhd_ctrl_nb_trans, usb_host_pipe_get_config(), usb_host_pipe_read_job(), and usb_setup_req_t::wLength.
Referenced by _uhd_ep0_transfer_complete().
|
static |
Starts the DATA IN phase on control endpoint.
References dev, usb_host_pipe_config::size, uhd_ctrl_buffer, UHD_CTRL_REQ_PHASE_DATA_IN, uhd_ctrl_request_phase, usb_host_pipe_get_config(), and usb_host_pipe_read_job().
Referenced by _uhd_ep0_setup().
|
static |
Manages the DATA OUT phase on control endpoint.
References _uhd_ctrl_phase_zlp_in(), uhd_ctrl_request_t::callback_run, dev, usb_host_pipe_config::device_address, NULL, uhd_ctrl_request_t::payload, uhd_ctrl_request_t::payload_size, uhd_ctrl_request_t::req, usb_host_pipe_config::size, uhd_ctrl_buffer, uhd_ctrl_nb_trans, UHD_CTRL_REQ_PHASE_DATA_OUT, uhd_ctrl_request_phase, usb_host_pipe_get_config(), usb_host_pipe_write_job(), and usb_setup_req_t::wLength.
Referenced by _uhd_ep0_setup(), and _uhd_ep0_transfer_complete().
|
static |
Sends a USB setup packet to start a control request sequence.
References _uhd_ctrl_request_end(), uhd_ctrl_request_t::add, cpu_to_le16, dev, usb_host_pipe_config::device_address, usb_host_pipe_config::pipe_type, uhd_ctrl_request_t::req, uhd_ctrl_buffer, uhd_ctrl_nb_trans, UHD_CTRL_REQ_PHASE_SETUP, uhd_ctrl_request_phase, uhd_ctrl_request_timeout, UHD_TRANS_DISCONNECT, USB_HOST_PIPE_CALLBACK_SETUP, usb_host_pipe_enable_callback(), usb_host_pipe_get_config(), usb_host_pipe_setup_job(), USB_HOST_PIPE_TYPE_DISABLE, usb_setup_req_t::wIndex, usb_setup_req_t::wLength, and usb_setup_req_t::wValue.
Referenced by _uhd_ctrl_request_end(), and uhd_setup_request().
|
static |
Starts the ZLP IN phase on control endpoint.
References dev, uhd_ctrl_buffer, UHD_CTRL_REQ_PHASE_ZLP_IN, uhd_ctrl_request_phase, usb_host_pipe_read_job(), and usb_host_pipe_set_toggle().
Referenced by _uhd_ctrl_phase_data_out(), and _uhd_ep0_setup().
|
static |
Starts the ZLP OUT phase on control endpoint.
References dev, uhd_ctrl_buffer, UHD_CTRL_REQ_PHASE_ZLP_OUT, uhd_ctrl_request_phase, usb_host_pipe_set_toggle(), and usb_host_pipe_write_job().
Referenced by _uhd_ctrl_phase_data_in().
|
static |
Call the callback linked to control request and start the next request.
status | Request finish status passed to callback |
References _uhd_ctrl_phase_setup(), Assert, uhd_ctrl_request_t::callback_end, cpu_irq_restore(), cpu_irq_save(), dev, usb_host_pipe_config::device_address, uhd_ctrl_request_t::next_request, NULL, uhd_b_suspend_requested, uhd_ctrl_nb_trans, uhd_ctrl_request_first, uhd_ctrl_request_timeout, uhd_suspend(), and usb_host_pipe_get_config().
Referenced by _uhd_ctrl_phase_setup(), _uhd_ep0_error(), _uhd_ep0_stall(), _uhd_ep0_transfer_complete(), _uhd_sof_interrupt(), and uhd_ep_free().
|
static |
Manages disconnection interrupt.
module_inst | Pointer to USB module instance |
References dbg_print, dev, uhc_notify_connection(), uhd_resume_start, uhd_sleep_mode(), UHD_STATE_DISCONNECT, uhd_suspend_start, USB_HOST_CALLBACK_CONNECT, USB_HOST_CALLBACK_DISCONNECT, USB_HOST_CALLBACK_WAKEUP, usb_host_disable_callback(), and usb_host_enable_callback().
Referenced by uhd_enable().
|
static |
Manages downstream resume interrupt.
module_inst | Pointer to USB module instance |
References dbg_print, dev, uhc_notify_resume_lpm(), uhd_lpm_suspend, uhd_resume_start, uhd_sleep_mode(), UHD_STATE_IDLE, USB_HOST_CALLBACK_DNRSM, USB_HOST_CALLBACK_UPRSM, USB_HOST_CALLBACK_WAKEUP, and usb_host_disable_callback().
Referenced by uhd_enable().
|
static |
Manages endpoint 0 error interrupt.
module_inst | Pointer to USB module instance |
pointer | Pointer to USB pipe transfer callback status parameters |
References _uhd_ctrl_request_end(), dbg_print, dev, usb_pipe_callback_parameter::pipe_error_status, usb_host_pipe_config::pipe_type, UHD_TRANS_CRC, UHD_TRANS_DT_MISMATCH, UHD_TRANS_NOTRESPONDING, UHD_TRANS_PIDFAILURE, UHD_TRANS_TIMEOUT, usb_host_pipe_get_config(), usb_host_pipe_set_config(), USB_HOST_PIPE_TYPE_CONTROL, USB_HOST_PIPE_TYPE_EXTENDED, USB_STATUS_PIPE_CRC16ER, USB_STATUS_PIPE_DAPIDER, USB_STATUS_PIPE_DTGLER, USB_STATUS_PIPE_PIDER, and USB_STATUS_PIPE_TOUTER.
Referenced by uhd_ep0_alloc().
|
static |
Manages endpoint 0 setup interrupt.
module_inst | Pointer to USB module instance |
null | Not used |
References _uhd_ctrl_phase_data_in_start(), _uhd_ctrl_phase_data_out(), _uhd_ctrl_phase_zlp_in(), Assert, usb_setup_req_t::bmRequestType, dbg_print, dev, uhd_ctrl_request_t::req, UHD_CTRL_REQ_PHASE_SETUP, uhd_ctrl_request_phase, usb_host_pipe_freeze(), USB_REQ_DIR_IN, USB_REQ_DIR_MASK, and usb_setup_req_t::wLength.
Referenced by uhd_ep0_alloc().
|
static |
Manages endpoint 0 stall interrupt.
module_inst | Pointer to USB module instance |
null | Not used |
References _uhd_ctrl_request_end(), dbg_print, dev, usb_host_pipe_config::pipe_type, UHD_TRANS_STALL, usb_host_pipe_get_config(), usb_host_pipe_set_config(), USB_HOST_PIPE_TYPE_CONTROL, and USB_HOST_PIPE_TYPE_EXTENDED.
Referenced by uhd_ep0_alloc().
|
static |
Manages endpoint 0 transfer complete interrupt.
module_inst | Pointer to USB module instance |
pointer | Pointer to USB pipe transfer callback status parameters |
References _uhd_ctrl_phase_data_in(), _uhd_ctrl_phase_data_out(), _uhd_ctrl_request_end(), Assert, dbg_print, dev, usb_host_pipe_config::pipe_type, usb_pipe_callback_parameter::transfered_size, UHD_CTRL_REQ_PHASE_DATA_IN, UHD_CTRL_REQ_PHASE_DATA_OUT, UHD_CTRL_REQ_PHASE_ZLP_IN, UHD_CTRL_REQ_PHASE_ZLP_OUT, uhd_ctrl_request_phase, uhd_lpm_suspend, uhd_sleep_mode(), UHD_STATE_SUSPEND_LPM, UHD_TRANS_NOERROR, USB_HOST_CALLBACK_DNRSM, USB_HOST_CALLBACK_UPRSM, USB_HOST_CALLBACK_WAKEUP, usb_host_enable_callback(), usb_host_pipe_freeze(), usb_host_pipe_get_config(), usb_host_pipe_set_config(), USB_HOST_PIPE_TYPE_CONTROL, and USB_HOST_PIPE_TYPE_EXTENDED.
Referenced by uhd_ep0_alloc().
|
static |
Aborts the on-going transfer on a pipe.
pipe | Pipe number |
status | Reason of abort |
References _uhd_pipe_finish_job(), dev, and usb_host_pipe_freeze().
Referenced by _uhd_ep_error(), _uhd_ep_stall(), _uhd_sof_interrupt(), and uhd_ep_abort().
|
static |
Manages pipe endpoint error callback.
module_inst | Pointer to USB module instance |
pointer | Pointer to USB pipe transfer callback status parameters |
References _uhd_ep_abort_pipe(), dbg_print, usb_pipe_callback_parameter::pipe_error_status, usb_pipe_callback_parameter::pipe_num, UHD_TRANS_CRC, UHD_TRANS_DT_MISMATCH, UHD_TRANS_NOTRESPONDING, UHD_TRANS_PIDFAILURE, UHD_TRANS_TIMEOUT, USB_STATUS_PIPE_CRC16ER, USB_STATUS_PIPE_DAPIDER, USB_STATUS_PIPE_DTGLER, USB_STATUS_PIPE_PIDER, and USB_STATUS_PIPE_TOUTER.
Referenced by uhd_ep_alloc().
|
static |
Manages pipe endpoint stall interrupt.
module_inst | Pointer to USB module instance |
pointer | Pointer to USB pipe transfer callback status parameters |
References _uhd_ep_abort_pipe(), dbg_print, dev, usb_pipe_callback_parameter::pipe_num, UHD_TRANS_STALL, and usb_host_pipe_clear_toggle().
Referenced by uhd_ep_alloc().
Returns the pipe number matching a USB endpoint.
add | USB device address |
endp | Endpoint Address |
References dev, usb_host_pipe_config::device_address, usb_host_pipe_config::endpoint_address, and usb_host_pipe_get_config().
Referenced by uhd_ep_abort(), and uhd_ep_run().
|
static |
Call the callback linked to the end of pipe transfer.
pipe | Pipe number |
status | Status of the transfer |
References uhd_pipe_job_t::buf_internal, uhd_pipe_job_t::busy, uhd_pipe_job_t::call_end, dev, usb_host_pipe_config::device_address, usb_host_pipe_config::endpoint_address, uhd_pipe_job_t::nb_trans, NULL, and usb_host_pipe_get_config().
Referenced by _uhd_ep_abort_pipe(), _uhd_pipe_trans_complete(), and uhd_ep_free().
|
static |
Computes and starts the next transfer on a pipe.
module_inst | Pointer to USB module instance |
pointer | Pointer to USB pipe transfer callback status parameters |
The USB hardware supports a maximum transfer size of UHD_ENDPOINT_MAX_TRANS Bytes
If all previous requested data have been received and user buffer not full then need to receive other data
References _uhd_pipe_finish_job(), Assert, uhd_pipe_job_t::b_shortpacket, uhd_pipe_job_t::buf, uhd_pipe_job_t::buf_internal, uhd_pipe_job_t::buf_size, uhd_pipe_job_t::busy, cpu_irq_restore(), cpu_irq_save(), dev, usb_host_pipe_config::endpoint_address, uhd_pipe_job_t::nb_trans, NULL, usb_pipe_callback_parameter::pipe_num, usb_pipe_callback_parameter::required_size, usb_host_pipe_config::size, usb_pipe_callback_parameter::transfered_size, UHD_ENDPOINT_MAX_TRANS, UHD_TRANS_NOERROR, USB_EP_DIR_IN, USB_HOST_PIPE_CALLBACK_TRANSFER_COMPLETE, usb_host_pipe_enable_callback(), usb_host_pipe_freeze(), usb_host_pipe_get_config(), usb_host_pipe_read_job(), usb_host_pipe_set_auto_zlp(), and usb_host_pipe_write_job().
Referenced by uhd_ep_alloc(), and uhd_ep_run().
|
static |
Manages ram access error interrupt.
module_inst | Pointer to USB module instance |
References dbg_print.
Referenced by uhd_enable().
|
static |
Manages bus reset interrupt.
module_inst | Pointer to USB module instance |
References NULL, and uhd_reset_callback.
Referenced by uhd_enable().
|
static |
Manages timeouts and actions based on SOF events.
module_inst | Pointer to USB module instance |
References _uhd_ctrl_request_end(), _uhd_ep_abort_pipe(), uhd_pipe_job_t::busy, dbg_print, dev, uhd_pipe_job_t::timeout, uhc_notify_resume(), uhc_notify_sof(), UHC_SOF_EVENT, uhd_ctrl_request_timeout, uhd_pipes_unfreeze, uhd_resume_start, uhd_sleep_mode(), UHD_STATE_SUSPEND, uhd_suspend_start, UHD_TRANS_TIMEOUT, usb_get_state_machine_status(), USB_HOST_CALLBACK_DNRSM, USB_HOST_CALLBACK_UPRSM, USB_HOST_CALLBACK_WAKEUP, usb_host_disable_sof(), usb_host_enable_callback(), usb_host_pipe_freeze(), and usb_host_pipe_unfreeze().
Referenced by uhd_enable().
|
static |
Manages upstream resume interrupt.
module_inst | Pointer to USB module instance |
References dbg_print, dev, uhc_notify_resume_lpm(), uhd_lpm_suspend, uhd_resume_start, uhd_sleep_mode(), UHD_STATE_IDLE, USB_HOST_CALLBACK_DNRSM, USB_HOST_CALLBACK_UPRSM, USB_HOST_CALLBACK_WAKEUP, usb_host_disable_callback(), usb_host_send_l1_resume(), and usb_host_send_resume().
Referenced by uhd_enable().
|
static |
Manages wakeup interrupt.
module_inst | Pointer to USB module instance |
References dbg_print, dev, uhc_notify_resume_lpm(), uhd_lpm_suspend, uhd_resume_start, uhd_sleep_mode(), UHD_STATE_IDLE, USB_HOST_CALLBACK_DNRSM, USB_HOST_CALLBACK_UPRSM, USB_HOST_CALLBACK_WAKEUP, usb_host_disable_callback(), usb_host_send_l1_resume(), and usb_host_send_resume().
Referenced by uhd_enable().
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(), dev, EXTINT_CALLBACK_TYPE_DETECT, extint_chan_disable_callback(), uhc_notify_connection(), uhd_sleep_mode(), UHD_STATE_WAIT_ID_HOST, UNUSED, usb_dual_disable(), USB_HOST_CALLBACK_CONNECT, USB_HOST_CALLBACK_DISCONNECT, USB_HOST_CALLBACK_RAMACER, USB_HOST_CALLBACK_RESET, USB_HOST_CALLBACK_SOF, usb_host_disable_callback(), and usb_host_disable_sof().
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 _uhd_connect(), _uhd_disconnect(), _uhd_downstream_resume(), _uhd_ram_error(), _uhd_reset(), _uhd_sof_interrupt(), _uhd_upstream_resume(), _uhd_vbus_handler(), _uhd_wakeup(), _usb_vbus_config(), cpu_irq_restore(), cpu_irq_save(), dbg_print, dev, is_usb_vbus_high, NULL, usb_config::select_host_mode, uhd_b_suspend_requested, uhd_ctrl_request_timeout, uhd_resume_start, uhd_sleep_mode(), UHD_STATE_DISCONNECT, UHD_STATE_NO_VBUS, uhd_suspend_start, usb_dual_enable(), usb_enable(), usb_get_config_defaults(), USB_HOST_CALLBACK_CONNECT, USB_HOST_CALLBACK_DISCONNECT, USB_HOST_CALLBACK_DNRSM, USB_HOST_CALLBACK_RAMACER, USB_HOST_CALLBACK_RESET, USB_HOST_CALLBACK_SOF, USB_HOST_CALLBACK_UPRSM, USB_HOST_CALLBACK_WAKEUP, usb_host_enable(), usb_host_enable_callback(), usb_host_register_callback(), and usb_init().
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 _uhd_ep0_error(), _uhd_ep0_setup(), _uhd_ep0_stall(), _uhd_ep0_transfer_complete(), usb_host_pipe_config::binterval, dev, usb_host_pipe_config::device_address, usb_host_pipe_config::size, USB_HOST_PIPE_CALLBACK_ERROR, USB_HOST_PIPE_CALLBACK_SETUP, USB_HOST_PIPE_CALLBACK_STALL, USB_HOST_PIPE_CALLBACK_TRANSFER_COMPLETE, usb_host_pipe_enable_callback(), usb_host_pipe_get_config_defaults(), usb_host_pipe_register_callback(), and usb_host_pipe_set_config().
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(), and UHD_TRANS_ABORTED.
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 _uhd_ep_error(), _uhd_ep_stall(), _uhd_pipe_trans_complete(), usb_ep_desc_t::bEndpointAddress, usb_host_pipe_config::binterval, usb_ep_desc_t::bInterval, usb_ep_desc_t::bmAttributes, dev, usb_host_pipe_config::device_address, usb_host_pipe_config::endpoint_address, le16_to_cpu, usb_host_pipe_config::pipe_type, usb_host_pipe_config::size, USB_EP_TYPE_MASK, USB_HOST_PIPE_CALLBACK_ERROR, USB_HOST_PIPE_CALLBACK_STALL, USB_HOST_PIPE_CALLBACK_TRANSFER_COMPLETE, usb_host_pipe_enable_callback(), usb_host_pipe_get_config(), usb_host_pipe_get_config_defaults(), usb_host_pipe_register_callback(), usb_host_pipe_set_config(), USB_HOST_PIPE_TYPE_DISABLE, 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_end(), _uhd_pipe_finish_job(), dev, usb_host_pipe_config::device_address, usb_host_pipe_config::endpoint_address, NULL, usb_host_pipe_config::pipe_type, uhd_ctrl_request_timeout, UHD_TRANS_DISCONNECT, usb_host_pipe_freeze(), usb_host_pipe_get_config(), and USB_HOST_PIPE_TYPE_DISABLE.
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_get_pipe(), _uhd_pipe_trans_complete(), 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(), dev, uhd_pipe_job_t::nb_trans, usb_pipe_callback_parameter::pipe_num, usb_pipe_callback_parameter::required_size, uhd_pipe_job_t::timeout, and usb_pipe_callback_parameter::transfered_size.
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 dev, and usb_host_get_frame_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.
Referenced by uhi_cdc_rx_received(), uhi_cdc_rx_update(), uhi_cdc_tx_send(), and uhi_cdc_tx_update().
uhd_speed_t uhd_get_speed | ( | void | ) |
Returns the speed of connected device.
References Assert, dev, UHD_SPEED_FULL, UHD_SPEED_LOW, usb_host_get_speed(), USB_SPEED_FULL, and USB_SPEED_LOW.
Referenced by uhc_enumeration_step4().
bool uhd_is_suspend | ( | void | ) |
Test if the suspend state is enabled on the USB line.
References dev, and usb_host_is_sof_enabled().
Referenced by uhc_is_suspend().
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 dbg_print, dev, usb_host_pipe_config::pipe_type, uhd_lpm_suspend, uhd_resume_start, uhd_sleep_mode(), UHD_STATE_IDLE, uhd_suspend_start, usb_host_is_sof_enabled(), usb_host_pipe_get_config(), USB_HOST_PIPE_TYPE_EXTENDED, usb_host_send_l1_resume(), and usb_host_send_resume().
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, dev, uhd_reset_callback, and usb_host_send_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_phase_setup(), 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, and uhd_ctrl_request_t::req.
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(), uhc_request_bos_desc(), 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 USB state.
new_state | New USB state |
References new_state, sleep_mode, sleepmgr_lock_mode(), sleepmgr_unlock_mode(), uhd_state, and UHD_STATE_OFF.
Referenced by _uhd_connect(), _uhd_disconnect(), _uhd_downstream_resume(), _uhd_ep0_transfer_complete(), _uhd_sof_interrupt(), _uhd_upstream_resume(), _uhd_wakeup(), uhd_disable(), uhd_enable(), and uhd_resume().
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 dev, uhd_b_suspend_requested, uhd_ctrl_request_timeout, uhd_pipes_unfreeze, uhd_suspend_start, usb_host_pipe_freeze(), and usb_host_pipe_is_frozen().
Referenced by _uhd_ctrl_request_end(), uhc_enumeration_suspend(), and uhc_suspend().
Enables the suspend L1 state on the USB line.
The SUSPEND LPM state is enable when a LPM transaction is done.
b_remotewakeup | Authorize the remote wakeup features, if true |
hird | Host Initiated Resume Duration |
References dbg_print, dev, uhd_ctrl_request_timeout, and usb_host_pipe_lpm_job().
Referenced by uhc_suspend_lpm().
struct usb_module dev |
Referenced by _uhd_connect(), _uhd_ctrl_phase_data_in(), _uhd_ctrl_phase_data_in_start(), _uhd_ctrl_phase_data_out(), _uhd_ctrl_phase_setup(), _uhd_ctrl_phase_zlp_in(), _uhd_ctrl_phase_zlp_out(), _uhd_ctrl_request_end(), _uhd_disconnect(), _uhd_downstream_resume(), _uhd_ep0_error(), _uhd_ep0_setup(), _uhd_ep0_stall(), _uhd_ep0_transfer_complete(), _uhd_ep_abort_pipe(), _uhd_ep_stall(), _uhd_get_pipe(), _uhd_pipe_finish_job(), _uhd_pipe_trans_complete(), _uhd_sof_interrupt(), _uhd_upstream_resume(), _uhd_wakeup(), uhc_connection_tree(), uhc_dev_reset(), uhc_enumeration_step13(), uhc_enumeration_step9(), uhc_get_device_number(), uhc_remotewakeup(), uhd_disable(), uhd_enable(), uhd_ep0_alloc(), uhd_ep_alloc(), uhd_ep_free(), uhd_ep_run(), uhd_get_frame_number(), uhd_get_speed(), uhd_is_suspend(), uhd_resume(), uhd_send_reset(), uhd_suspend(), uhd_suspend_lpm(), uhi_aoa_install(), uhi_aoa_mode_enable_step1(), uhi_cdc_install(), uhi_hid_mouse_install(), and uhi_vendor_install().
enum sleepmgr_mode sleep_mode[] |
Referenced by sleepmgr_enter_sleep(), sleepmgr_get_sleep_mode(), system_set_sleepmode(), udd_sleep_mode(), and uhd_sleep_mode().
|
static |
Flag to delay a suspend request after all on-going setup request.
Referenced by _uhd_ctrl_request_end(), uhd_enable(), and uhd_suspend().
uint8_t uhd_ctrl_buffer[64] |
Buffer to store the sent/received data on control endpoint.
Used to avoid a RAM buffer overflow when the payload buffer is smaller than control endpoint size. Also used when payload buffer is not word aligned.
Referenced by _uhd_ctrl_phase_data_in(), _uhd_ctrl_phase_data_in_start(), _uhd_ctrl_phase_data_out(), _uhd_ctrl_phase_setup(), _uhd_ctrl_phase_zlp_in(), and _uhd_ctrl_phase_zlp_out().
uint16_t uhd_ctrl_nb_trans |
Number of transfered byte on DATA phase of current setup request.
Referenced by _uhd_ctrl_phase_data_in(), _uhd_ctrl_phase_data_out(), _uhd_ctrl_phase_setup(), and _uhd_ctrl_request_end().
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)
Referenced by _uhd_ctrl_phase_setup(), _uhd_ctrl_request_end(), _uhd_sof_interrupt(), uhd_enable(), uhd_ep_free(), uhd_suspend(), and uhd_suspend_lpm().
Notify that USB Host is enter in suspend LPM state.
Referenced by _uhd_downstream_resume(), _uhd_ep0_transfer_complete(), _uhd_upstream_resume(), _uhd_wakeup(), and uhd_resume().
|
static |
Array to register a job on bulk/interrupt/isochronous endpoint.
|
static |
Referenced by _uhd_sof_interrupt(), and uhd_suspend().
|
static |
Store the callback to be called at the end of reset signal.
Referenced by _uhd_reset(), and uhd_send_reset().
|
static |
|
static |
Referenced by uhd_sleep_mode().
|
static |
Variables to manage the suspend/resume sequence.
Referenced by _uhd_connect(), _uhd_disconnect(), _uhd_sof_interrupt(), uhd_enable(), uhd_resume(), and uhd_suspend().