Modules | |
Host controller states | |
Defines for device state coding. | |
Data Structures | |
struct | S_pipe_int |
Macros | |
#define | Host_ack_request_resume() (request_resume = false) |
Private ack for resume software event. More... | |
#define | Host_request_resume() (request_resume = true) |
Should be called to request the host controller to resume the USB bus. More... | |
#define | Host_request_suspend() (device_state = DEVICE_SUSPENDED) |
Should be called to make the host controller enter USB suspend mode. More... | |
#define | Is_host_addressed() (device_state >= DEVICE_ADDRESSED) |
Check if there is a device addressed by the host. More... | |
#define | Is_host_attached() (device_state >= DEVICE_ATTACHED) |
Check if there is a device attached to the host. More... | |
#define | Is_host_error() (device_state == DEVICE_ERROR) |
Check if there is an error. More... | |
#define | Is_host_powered() (device_state >= DEVICE_POWERED) |
Check if there is a device powered by the host. More... | |
#define | Is_host_ready() (device_state == DEVICE_READY) |
Returns true when device connected and correctly enumerated. More... | |
#define | Is_host_request_resume() (request_resume == true) |
Private check for resume sequence. More... | |
#define | Is_host_suspended() |
Check if host controller is in suspend mode. More... | |
#define | PIPE_CRC16 0x10 |
#define | PIPE_DATA_PID 0x02 |
#define | PIPE_DATA_TOGGLE 0x01 |
#define | PIPE_DELAY_TIMEOUT 0x80 |
#define | PIPE_GOOD 0x00 |
#define | PIPE_NAK_TIMEOUT 0x40 |
#define | PIPE_PID 0x04 |
#define | PIPE_STALL 0x20 |
#define | PIPE_TIMEOUT 0x08 |
Typedefs | |
typedef void | Pipe_handler (Status_t status, U16 nb_byte) |
Functions | |
Status_t | host_get_data (U8 pipe, U16 *nb_data, void *ptr_buf) |
This function receives nb_data bytes pointed to by ptr_buf on the specified pipe. More... | |
bool | host_get_data_interrupt (U8 pipe, U16 nb_data, void *ptr_buf, Pipe_handler *handler) |
This function receives nb_data bytes pointed to by ptr_buf on the specified pipe. More... | |
Status_t | host_send_data (U8 pipe, U16 nb_data, const void *ptr_buf) |
This function sends nb_data bytes pointed to by ptr_buf on the specified pipe. More... | |
bool | host_send_data_interrupt (U8 pipe, U16 nb_data, const void *ptr_buf, Pipe_handler *handler) |
This function sends nb_data bytes pointed to by ptr_buf on the specified pipe. More... | |
bool | is_any_interrupt_pipe_active (void) |
void | reset_it_pipe_str (void) |
void | usb_host_task (void) |
Entry point of the USB host management. More... | |
void | usb_host_task_init (void) |
This function initializes the USB host controller. More... | |
void | usb_pipe_interrupt (U8 pipe) |
USB pipe interrupt subroutine. More... | |
Variables | |
U8 | data_stage [SIZEOF_DATA_STAGE] |
Public: U8 data_stage[SIZEOF_DATA_STAGE] Internal RAM buffer for USB data stage content This buffer is required to setup host enumeration process It contains the device descriptors received. More... | |
volatile U8 | device_state |
Public: U8 device_state Its value represents the current state of the device connected to the USB host controller Value can be: More... | |
volatile U8 | device_status |
volatile bool | request_resume |
volatile S_usb_setup_data | usb_request |
For control requests management over control pipe. More... | |
#define Host_ack_request_resume | ( | ) | (request_resume = false) |
Private ack for resume software event.
Referenced by usb_host_task(), and usb_host_task_init().
#define Host_request_resume | ( | ) | (request_resume = true) |
Should be called to request the host controller to resume the USB bus.
Referenced by host_template_task(), and ushell_cmdusb_resume().
#define Host_request_suspend | ( | ) | (device_state = DEVICE_SUSPENDED) |
Should be called to make the host controller enter USB suspend mode.
Referenced by host_template_task(), and ushell_cmdusb_suspend().
#define Is_host_addressed | ( | ) | (device_state >= DEVICE_ADDRESSED) |
Check if there is a device addressed by the host.
#define Is_host_attached | ( | ) | (device_state >= DEVICE_ATTACHED) |
Check if there is a device attached to the host.
Referenced by ai_usb_ms_get_device_status(), and usb_general_interrupt().
#define Is_host_error | ( | ) | (device_state == DEVICE_ERROR) |
Check if there is an error.
Referenced by ai_usb_ms_get_device_status().
#define Is_host_powered | ( | ) | (device_state >= DEVICE_POWERED) |
Check if there is a device powered by the host.
Referenced by ai_usb_ms_get_device_status().
#define Is_host_ready | ( | ) | (device_state == DEVICE_READY) |
Returns true when device connected and correctly enumerated.
The host high-level application should test this before performing any applicative request.
Referenced by host_cdc_task(), host_mass_storage_task(), host_mouse_hid_task(), host_template_task(), and ushell_cmdusb_suspend().
#define Is_host_request_resume | ( | ) | (request_resume == true) |
Private check for resume sequence.
Referenced by usb_host_task().
#define Is_host_suspended | ( | ) |
Check if host controller is in suspend mode.
Referenced by host_template_task(), and ushell_cmdusb_resume().
#define PIPE_CRC16 0x10 |
#define PIPE_DATA_PID 0x02 |
#define PIPE_DATA_TOGGLE 0x01 |
#define PIPE_DELAY_TIMEOUT 0x80 |
Referenced by host_get_data(), host_send_data(), and usb_general_interrupt().
#define PIPE_GOOD 0x00 |
#define PIPE_NAK_TIMEOUT 0x40 |
Referenced by host_get_data(), host_send_data(), and usb_pipe_interrupt().
#define PIPE_PID 0x04 |
#define PIPE_STALL 0x20 |
#define PIPE_TIMEOUT 0x08 |
This function receives nb_data bytes pointed to by ptr_buf on the specified pipe.
*nb_data is updated with the final number of data bytes received.
pipe | |
nb_data | |
ptr_buf |
References Disable_global_interrupt, Enable_global_interrupt, EVT_HOST_SOF, Host_ack_all_errors, Host_ack_in_received, Host_ack_nak_received, Host_ack_sof, Host_ack_stall, Host_byte_count, Host_configure_pipe_token, Host_disable_sof_interrupt, Host_enable_continuous_in_mode, Host_enable_sof_interrupt, Host_error_status, Host_free_in, Host_freeze_pipe, Host_get_pipe_size, host_read_p_rxpacket(), Host_reset_pipe, Host_reset_pipe_fifo_access, Host_unfreeze_pipe, i, Is_global_interrupt_enabled, Is_host_emergency_exit, Is_host_in_received, Is_host_nak_received, Is_host_pipe_error, Is_host_sof_interrupt_enabled, Is_host_stall, Is_usb_event, Is_usb_low_speed_mode, n, NAK_RECEIVE_TIMEOUT, PIPE_DELAY_TIMEOUT, PIPE_GOOD, PIPE_NAK_TIMEOUT, PIPE_STALL, private_sof_counter, status, TIMEOUT_DELAY, TOKEN_IN, and Usb_ack_event.
Referenced by host_ms_inquiry(), host_ms_request_sense(), host_ms_stall_management(), host_read_10_extram(), host_read_10_ram(), host_read_10_ram_stop(), host_read_capacity(), host_template_task(), host_test_unit_ready(), host_wr_protect(), and host_write_10_extram().
bool host_get_data_interrupt | ( | U8 | pipe, |
U16 | nb_data, | ||
void * | ptr_buf, | ||
Pipe_handler * | handler | ||
) |
This function receives nb_data bytes pointed to by ptr_buf on the specified pipe.
*nb_data is updated with the final number of data bytes received.
pipe | |
nb_data | |
ptr_buf | |
handler | Call-back function pointer |
References Disable_global_interrupt, S_pipe_int::enable, Enable_global_interrupt, g_sav_int_sof_enable, S_pipe_int::handler, Host_ack_in_received, Host_ack_nak_received, Host_ack_stall, Host_configure_pipe_token, Host_enable_continuous_in_mode, Host_enable_in_received_interrupt, Host_enable_nak_received_interrupt, Host_enable_pipe_error_interrupt, Host_enable_pipe_interrupt, Host_enable_sof_interrupt, Host_enable_stall_interrupt, Host_reset_pipe, Host_unfreeze_pipe, is_any_interrupt_pipe_active(), Is_global_interrupt_enabled, Is_host_nak_received, Is_host_sof_interrupt_enabled, NAK_RECEIVE_TIMEOUT, S_pipe_int::nak_timeout, S_pipe_int::nb_byte_processed, S_pipe_int::nb_byte_to_process, private_sof_counter, S_pipe_int::ptr_buf, S_pipe_int::timeout, and TOKEN_IN.
Referenced by host_send_data_callback().
This function sends nb_data bytes pointed to by ptr_buf on the specified pipe.
pipe | |
nb_data | |
ptr_buf |
References Disable_global_interrupt, Enable_global_interrupt, Host_ack_all_errors, Host_ack_nak_received, Host_ack_out_ready, Host_ack_out_ready_send, Host_ack_stall, Host_configure_pipe_token, Host_disable_sof_interrupt, Host_enable_sof_interrupt, Host_error_status, Host_freeze_pipe, Host_nb_busy_bank, Host_reset_pipe, Host_reset_pipe_fifo_access, Host_unfreeze_pipe, host_write_p_txpacket(), Is_global_interrupt_enabled, Is_host_emergency_exit, Is_host_nak_received, Is_host_out_ready, Is_host_pipe_error, Is_host_sof_interrupt_enabled, Is_host_stall, NAK_SEND_TIMEOUT, PIPE_DELAY_TIMEOUT, PIPE_GOOD, PIPE_NAK_TIMEOUT, PIPE_STALL, private_sof_counter, status, TIMEOUT_DELAY, and TOKEN_OUT.
Referenced by cdc_pipe_out_usb_flush(), host_ms_inquiry(), host_ms_request_sense(), host_read_10_extram(), host_read_10_ram(), host_read_capacity(), host_template_task(), host_test_unit_ready(), host_wr_protect(), and host_write_10_extram().
bool host_send_data_interrupt | ( | U8 | pipe, |
U16 | nb_data, | ||
const void * | ptr_buf, | ||
Pipe_handler * | handler | ||
) |
This function sends nb_data bytes pointed to by ptr_buf on the specified pipe.
pipe | |
nb_data | |
ptr_buf | |
handler | Call-back function pointer |
References Disable_global_interrupt, S_pipe_int::enable, Enable_global_interrupt, g_sav_int_sof_enable, S_pipe_int::handler, Host_ack_nak_received, Host_ack_out_ready, Host_ack_stall, Host_configure_pipe_token, Host_enable_nak_received_interrupt, Host_enable_out_ready_interrupt, Host_enable_pipe_error_interrupt, Host_enable_pipe_interrupt, Host_enable_sof_interrupt, Host_enable_stall_interrupt, Host_reset_pipe, Host_reset_pipe_fifo_access, Host_send_out, Host_unfreeze_pipe, host_write_p_txpacket(), is_any_interrupt_pipe_active(), Is_global_interrupt_enabled, Is_host_nak_received, Is_host_resetting_pipe, Is_host_sof_interrupt_enabled, NAK_SEND_TIMEOUT, S_pipe_int::nak_timeout, S_pipe_int::nb_byte_on_going, S_pipe_int::nb_byte_processed, S_pipe_int::nb_byte_to_process, NULL, private_sof_counter, S_pipe_int::ptr_buf, S_pipe_int::timeout, and TOKEN_OUT.
Referenced by host_template_task().
bool is_any_interrupt_pipe_active | ( | void | ) |
References i, and MAX_PEP_NB.
Referenced by host_get_data_interrupt(), host_send_data_interrupt(), usb_general_interrupt(), and usb_pipe_interrupt().
void reset_it_pipe_str | ( | void | ) |
References S_pipe_int::enable, i, MAX_PEP_NB, and S_pipe_int::timeout.
Referenced by usb_general_interrupt(), and usb_host_task_init().
void usb_host_task | ( | void | ) |
Entry point of the USB host management.
The aim is to manage the target device connection and enumeration. Depending on device_state, the function performs the required operations to get the device enumerated and configured. Once the device is operational, device_state is DEVICE_READY. This state should be tested by the host task before sending any applicative request to the device. This function is called from the usb_task function depending on the USB operating mode (device or host) currently engaged.
The aim is to manage the target device connection and enumeration. Depending on device_state, the function performs the required operations to get the device enumerated and configured. Once the device is operational, device_state is DEVICE_READY. This state should be tested by the host task before sending any applicative request to the device. This function is called from the usb_task function depending on the USB operating mode (device or host) currently engaged.
References configTSK_USB_HST_PERIOD, CONTROL_GOOD, data_stage, DEVICE_ADDRESS, DEVICE_ADDRESSED, DEVICE_ATTACHED, DEVICE_CONFIGURED, DEVICE_DEFAULT, DEVICE_ERROR, DEVICE_POWERED, DEVICE_READY, device_state, DEVICE_SUSPENDED, DEVICE_UNATTACHED, DEVICE_WAIT_RESUME, Disable_global_interrupt, Enable_global_interrupt, EP_CONTROL, EVT_HOST_HWUP, EVT_HOST_SOF, Host_ack_device_connection, Host_ack_device_disconnection, Host_ack_down_stream_resume, Host_ack_hwup, Host_ack_remote_wakeup, Host_ack_request_resume, Host_ack_reset_sent, Host_ack_sof, host_check_class(), host_check_VID_PID(), Host_clear_device_status, Host_configure_address, Host_configure_pipe, Host_device_class_not_supported_action, Host_device_connection_action, Host_device_error_action, Host_device_not_supported_action, Host_device_supported_action, host_disable_all_pipes(), Host_disable_device_disconnection_interrupt, Host_disable_hwup_interrupt, Host_disable_pipe, Host_disable_sof, Host_disable_sof_interrupt, Host_enable_device_disconnection_interrupt, Host_enable_hwup_interrupt, Host_enable_pipe, Host_enable_sof, Host_enable_sof_interrupt, host_get_configuration_descriptor, host_get_device_descriptor, host_get_device_descriptor_incomplete, Host_new_device_connection_action, Host_send_reset, Host_send_resume, host_set_address, host_set_configuration, Host_set_configured, Host_set_device_supported, host_set_feature_remote_wakeup, Host_stop_sending_reset, Host_suspend_action, Host_unallocate_memory, Is_device_supports_remote_wakeup, Is_host_configured, Is_host_device_connection, Is_host_device_disconnection, Is_host_down_stream_resume, Is_host_emergency_exit, Is_host_hwup_interrupt_enabled, Is_host_request_resume, Is_host_sending_reset, Is_host_sof_interrupt_enabled, Is_usb_bconnection_error_interrupt, Is_usb_clock_frozen, Is_usb_event, Is_usb_vbus_error_interrupt, Is_usb_vbus_high, Is_usb_vbus_low, log_device_connected, log_device_enumerated, LOG_STR, log_unsupported_device, log_usb_resumed, log_usb_suspended, MAX_PEP_NB, nb_interface_supported, OFFSET_FIELD_MAXPACKETSIZE, P_CONTROL, SINGLE_BANK, sof_cnt, TOKEN_SETUP, TYPE_CONTROL, Usb_ack_bconnection_error_interrupt, Usb_ack_event, Usb_ack_vbus_error_interrupt, Usb_clear_all_event, Usb_enable_vbus, Usb_freeze_clock, Usb_unfreeze_clock, User_configure_endpoint, vTaskDelayUntil(), and xTaskGetTickCount().
Referenced by usb_host_task_init(), and usb_task().
void usb_host_task_init | ( | void | ) |
This function initializes the USB host controller.
This function enables the USB controller for host-mode operation.
References configTSK_USB_HST_NAME, configTSK_USB_HST_PRIORITY, configTSK_USB_HST_STACK_SIZE, device_state, DEVICE_UNATTACHED, Disable_global_interrupt, Enable_global_interrupt, Host_ack_request_resume, Host_clear_device_status, Host_enable_device_disconnection_interrupt, Is_usb_clock_frozen, Is_usb_enabled, NULL, reset_it_pipe_str(), sof_cnt, Usb_disable, Usb_disable_otg_pad, Usb_disable_vbus_hw_control, Usb_enable, Usb_enable_otg_pad, usb_host_task(), Usb_output_vbof_pin, Usb_set_vbof_active_high, Usb_set_vbof_active_low, Usb_unfreeze_clock, and xTaskCreate.
Referenced by usb_task().
void usb_pipe_interrupt | ( | U8 | pipe | ) |
USB pipe interrupt subroutine.
pipe |
References callback, S_pipe_int::enable, g_sav_int_sof_enable, S_pipe_int::handler, Host_ack_all_errors, Host_ack_in_received, Host_ack_nak_received, Host_ack_out_ready, Host_byte_count, Host_disable_sof_interrupt, Host_error_status, Host_free_in, Host_freeze_pipe, Host_get_pipe_size, Host_get_pipe_type, host_read_p_rxpacket(), Host_reset_pipe, Host_reset_pipe_fifo_access, Host_send_out, Host_unfreeze_pipe, host_write_p_txpacket(), i, is_any_interrupt_pipe_active(), Is_host_in_received, Is_host_nak_received, Is_host_out_ready, Is_host_pipe_error, Is_host_stall, n, NAK_RECEIVE_TIMEOUT, NAK_SEND_TIMEOUT, S_pipe_int::nak_timeout, S_pipe_int::nb_byte_on_going, S_pipe_int::nb_byte_processed, S_pipe_int::nb_byte_to_process, NULL, PIPE_GOOD, PIPE_NAK_TIMEOUT, PIPE_STALL, private_sof_counter, S_pipe_int::status, status, S_pipe_int::timeout, and TYPE_INTERRUPT.
Referenced by usb_general_interrupt().
U8 data_stage[SIZEOF_DATA_STAGE] |
Public: U8 data_stage[SIZEOF_DATA_STAGE] Internal RAM buffer for USB data stage content This buffer is required to setup host enumeration process It contains the device descriptors received.
Depending on the device descriptors length, its size can be optimized with the SIZEOF_DATA_STAGE define of conf_usb.h file
Referenced by host_cdc_get_encapsulated_response(), host_cdc_get_line_coding(), host_cdc_send_encapsulated_command(), host_cdc_set_line_coding(), host_check_class(), host_check_VID_PID(), host_get_lun(), host_hid_get_descriptor(), host_hid_get_idle(), host_hid_get_protocol(), host_hid_get_report(), host_hid_set_descriptor(), host_hid_set_idle(), host_hid_set_protocol(), host_hid_set_report(), and usb_host_task().
volatile U8 device_state |
Public: U8 device_state Its value represents the current state of the device connected to the USB host controller Value can be:
Referenced by host_mass_storage_task(), usb_general_interrupt(), usb_host_task(), and usb_host_task_init().
volatile U8 device_status |
Referenced by usb_clear_feature(), usb_get_status(), and usb_set_feature().
volatile bool request_resume |
volatile S_usb_setup_data usb_request |
For control requests management over control pipe.
Referenced by host_cdc_get_encapsulated_response(), host_cdc_get_line_coding(), host_cdc_send_encapsulated_command(), host_cdc_set_line_coding(), host_hid_get_descriptor(), host_hid_get_idle(), host_hid_get_protocol(), host_hid_get_report(), host_hid_set_descriptor(), host_hid_set_idle(), host_hid_set_protocol(), host_hid_set_report(), and host_transfer_control().