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... | |
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... | |
void | usb_host_task (void *pvParameters) |
Entry point of the USB host management. More... | |
void | usb_host_task_init (void) |
This function initializes the USB host controller. 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.
#define Host_request_suspend | ( | ) | (device_state = DEVICE_SUSPENDED) |
Should be called to make the host controller enter USB suspend mode.
#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 usb_general_interrupt_non_naked().
#define Is_host_error | ( | ) | (device_state == DEVICE_ERROR) |
Check if there is an error.
#define Is_host_powered | ( | ) | (device_state >= DEVICE_POWERED) |
Check if there is a device powered by the host.
#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_mouse_hid_task().
#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.
#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_non_naked().
#define PIPE_GOOD 0x00 |
Referenced by host_get_data(), and host_send_data().
#define PIPE_NAK_TIMEOUT 0x40 |
Referenced by host_get_data(), and host_send_data().
#define PIPE_PID 0x04 |
#define PIPE_STALL 0x20 |
Referenced by host_get_data(), and host_send_data().
#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, 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, NAK_RECEIVE_TIMEOUT, PIPE_DELAY_TIMEOUT, PIPE_GOOD, PIPE_NAK_TIMEOUT, PIPE_STALL, private_sof_counter, TIMEOUT_DELAY, TOKEN_IN, and Usb_ack_event.
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, TIMEOUT_DELAY, and TOKEN_OUT.
void usb_host_task | ( | void * | pvParameters | ) |
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, vTaskDelayUntil(), and xTaskGetTickCount().
Referenced by usb_host_task_init().
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, sof_cnt, Usb_disable, Usb_disable_otg_pad, Usb_disable_vbus_hw_control, Usb_enable, Usb_enable_otg_pad, usb_host_task(), usb_host_tsk, Usb_output_vbof_pin, Usb_set_vbof_active_high, Usb_set_vbof_active_low, Usb_unfreeze_clock, and xTaskCreate.
Referenced by usb_task().
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_check_class(), host_check_VID_PID(), 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 usb_general_interrupt_non_naked(), usb_host_task(), and usb_host_task_init().
volatile U8 device_status |
volatile bool request_resume |
volatile S_usb_setup_data usb_request |
For control requests management over control pipe.
Referenced by 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().