#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "usb_specific_request.h"
#include "usb_task.h"
Macros | |
#define | USB_REMOTE_WAKEUP_FEATURE false |
Functions | |
static void | usb_clear_feature (void) |
This function manages the CLEAR FEATURE request. More... | |
static void | usb_get_configuration (void) |
This function manages the GET CONFIGURATION request. More... | |
static void | usb_get_descriptor (void) |
This function manages the GET DESCRIPTOR request. More... | |
static bool | usb_get_interface (void) |
This function manages the SETUP_GET_INTERFACE request. More... | |
static void | usb_get_status (void) |
This function manages the GET STATUS request. More... | |
void | usb_process_request (void) |
This function reads the SETUP request sent to the default control endpoint and calls the appropriate function. More... | |
static void | usb_set_address (void) |
This function manages the SET ADDRESS request. More... | |
static void | usb_set_configuration (void) |
This function manages the SET CONFIGURATION request. More... | |
static void | usb_set_feature (void) |
This function manages the SET FEATURE request. More... | |
static void | usb_set_interface (void) |
This function manages the SET INTERFACE request. More... | |
Variables | |
static U8 | bmRequestType |
U16 | data_to_transfer |
static U8 | device_status = DEVICE_STATUS |
const void * | pbuffer |
U8 | remote_wakeup_feature |
volatile U8 | usb_configuration_nb |
volatile bool | usb_connected |
Public : (bool) usb_connected usb_connected is set to true when VBus has been detected usb_connected is set to false otherwise. More... | |
static U8 | usb_interface_status [NB_INTERFACE] |
const S_usb_user_configuration_descriptor | usb_user_configuration_descriptor |
const S_usb_device_descriptor | usb_user_device_descriptor |
#define USB_REMOTE_WAKEUP_FEATURE false |
|
static |
This function manages the CLEAR FEATURE request.
< dummy read (MSB of wValue)
References bmRequestType, device_status, EP_CONTROL, FEATURE_DEVICE_REMOTE_WAKEUP, FEATURE_ENDPOINT_HALT, Get_desc_ep_nbr, Is_usb_endpoint_enabled, remote_wakeup_feature, Usb_ack_control_in_ready_send, Usb_ack_setup_received_free, USB_DEV_STATUS_REMOTEWAKEUP, Usb_disable_stall_handshake, Usb_enable_stall_handshake, Usb_read_endpoint_data, Usb_reset_data_toggle, Usb_reset_endpoint, USB_SETUP_SET_STAND_DEVICE, USB_SETUP_SET_STAND_ENDPOINT, and USB_SETUP_SET_STAND_INTERFACE.
Referenced by usb_process_request().
|
static |
This function manages the GET CONFIGURATION request.
The current configuration number is returned.
References EP_CONTROL, Is_usb_control_out_received, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_ack_setup_received_free, usb_configuration_nb, Usb_reset_endpoint_fifo_access, and Usb_write_endpoint_data.
Referenced by usb_process_request().
|
static |
This function manages the GET DESCRIPTOR request.
The device descriptor, the configuration descriptor and the device qualifier are supported. All other descriptors must be supported by the usb_user_get_descriptor function. Only 1 configuration is supported.
< sizeof(usb_dev_desc);
< sizeof(usb_conf_desc);
< read wIndex and wLength with a 32-bit access since this access is aligned with a 32-bit boundary from the beginning of the endpoint
< ignore wIndex, keep and format wLength
< clear the setup received flag
< zero length packet condition
< send only requested number of data bytes
< Send data until necessary
References CONFIGURATION_DESCRIPTOR, data_to_transfer, DEVICE_DESCRIPTOR, DEVICE_QUALIFIER_DESCRIPTOR, EP_CONTROL, EP_CONTROL_LENGTH, Is_usb_control_in_ready, Is_usb_control_out_received, Is_usb_full_speed_mode, Is_usb_nak_out, OTHER_SPEED_CONFIGURATION_DESCRIPTOR, pbuffer, Union32::u16, Union32::u32, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_ack_nak_out, Usb_ack_setup_received_free, Usb_enable_stall_handshake, usb_format_usb_to_mcu_data, Usb_get_conf_desc_fs_length, Usb_get_conf_desc_fs_pointer, Usb_get_conf_desc_hs_length, Usb_get_conf_desc_hs_pointer, Usb_get_conf_desc_length, Usb_get_conf_desc_pointer, Usb_get_dev_desc_length, Usb_get_dev_desc_pointer, Usb_get_qualifier_desc_length, Usb_get_qualifier_desc_pointer, Usb_read_endpoint_data, Usb_reset_endpoint_fifo_access, usb_user_get_descriptor(), and usb_write_ep_txpacket().
Referenced by usb_process_request().
|
static |
This function manages the SETUP_GET_INTERFACE request.
References EP_CONTROL, Is_usb_control_out_received, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_ack_setup_received_free, usb_format_usb_to_mcu_data, usb_interface_status, Usb_read_endpoint_data, Usb_reset_endpoint_fifo_access, and Usb_write_endpoint_data.
Referenced by usb_process_request().
|
static |
This function manages the GET STATUS request.
The device, interface or endpoint status is returned.
< dummy read (wValue)
References bmRequestType, device_status, EP_CONTROL, Get_desc_ep_nbr, INTERFACE_STATUS, Is_usb_control_out_received, Is_usb_endpoint_stall_requested, REQUEST_DEVICE_STATUS, REQUEST_ENDPOINT_STATUS, REQUEST_INTERFACE_STATUS, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_ack_setup_received_free, Usb_enable_stall_handshake, Usb_read_endpoint_data, Usb_reset_endpoint_fifo_access, and Usb_write_endpoint_data.
Referenced by usb_process_request().
|
static |
This function manages the SET ADDRESS request.
When complete, the device will filter the requests using the new address.
< send a ZLP for STATUS phase
< waits for status phase done before using the new address
References EP_CONTROL, Is_usb_control_in_ready, Usb_ack_control_in_ready_send, Usb_ack_setup_received_free, Usb_configure_address, Usb_enable_address, and Usb_read_endpoint_data.
Referenced by usb_process_request().
|
static |
This function manages the SET CONFIGURATION request.
If the selected configuration is valid, this function call the usb_user_endpoint_init() function that will configure the endpoints following the configuration number.
< endpoint configuration
< send a ZLP for STATUS phase
< keep that order (set StallRq/clear RxSetup) or a OUT request following the SETUP may be acknowledged
References EP_CONTROL, NB_CONFIGURATION, NB_INTERFACE, Usb_ack_control_in_ready_send, Usb_ack_setup_received_free, usb_configuration_nb, Usb_enable_stall_handshake, usb_interface_status, Usb_read_endpoint_data, Usb_set_configuration_action, and usb_user_endpoint_init().
Referenced by usb_process_request().
|
static |
This function manages the SET FEATURE request.
The USB test modes are supported by this function.
References AVR32_USBB_udcon, bmRequestType, device_status, DEVICE_TYPE, DIRECTION_IN, ENDPOINT_TYPE, EP_CONTROL, FEATURE_DEVICE_REMOTE_WAKEUP, FEATURE_ENDPOINT_HALT, FEATURE_TEST_MODE, Get_desc_ep_nbr, Is_usb_control_in_ready, Is_usb_endpoint_enabled, remote_wakeup_feature, Set_bits, SINGLE_BANK, TEST_FORCE_ENABLE, TEST_J, TEST_K, TEST_PACKET, TEST_SE0_NAK, TYPE_BULK, Usb_ack_control_in_ready_send, Usb_ack_setup_received_free, Usb_configure_endpoint, USB_DEV_STATUS_REMOTEWAKEUP, Usb_disable_endpoint, Usb_enable_stall_handshake, usb_format_usb_to_mcu_data, Usb_read_endpoint_data, Usb_reset_endpoint, Usb_send_in, USB_SETUP_SET_STAND_DEVICE, Usb_unallocate_memory, usb_write_ep_txpacket(), and Wr_bitfield.
Referenced by usb_process_request().
|
static |
This function manages the SET INTERFACE request.
< sizeof(usb_conf_desc);
References CONFIGURATION_DESCRIPTOR, data_to_transfer, ENDPOINT_DESCRIPTOR, EP_CONTROL, INTERFACE_DESCRIPTOR, Is_usb_control_in_ready, Is_usb_full_speed_mode, MSK_EP_DIR, pbuffer, Usb_ack_control_in_ready_send, Usb_ack_setup_received_free, usb_configuration_nb, Usb_disable_stall_handshake, Usb_enable_stall_handshake, usb_format_usb_to_mcu_data, Usb_get_conf_desc_fs_length, Usb_get_conf_desc_fs_pointer, Usb_get_conf_desc_hs_length, Usb_get_conf_desc_hs_pointer, Usb_get_conf_desc_length, Usb_get_conf_desc_pointer, usb_interface_status, Usb_read_endpoint_data, Usb_reset_data_toggle, and Usb_reset_endpoint.
Referenced by usb_process_request().
|
static |
Referenced by usb_clear_feature(), usb_get_status(), usb_process_request(), and usb_set_feature().
U16 data_to_transfer |
Referenced by hid_get_descriptor(), hid_report_in(), usb_get_descriptor(), usb_set_interface(), and usb_user_get_descriptor().
|
static |
Referenced by usb_clear_feature(), usb_get_status(), and usb_set_feature().
const void* pbuffer |
Referenced by hid_get_descriptor(), usb_get_descriptor(), usb_set_interface(), and usb_user_get_descriptor().
U8 remote_wakeup_feature |
Referenced by usb_clear_feature(), and usb_set_feature().
volatile bool usb_connected |
Public : (bool) usb_connected usb_connected is set to true when VBus has been detected usb_connected is set to false otherwise.
|
static |
Referenced by usb_get_interface(), usb_set_configuration(), and usb_set_interface().
const S_usb_user_configuration_descriptor usb_user_configuration_descriptor |
const S_usb_device_descriptor usb_user_device_descriptor |