Internal implementation.
Data Structures | |
struct | udc_string_desc_t |
USB device string descriptor Structure used to transfer ASCII strings to USB String descriptor structure. More... | |
Functions | |
static usb_conf_desc_t UDC_DESC_STORAGE * | udc_get_eof_conf (void) |
Returns a value to check the end of USB Configuration descriptor. More... | |
usb_iface_desc_t UDC_DESC_STORAGE * | udc_get_interface_desc (void) |
Returns a pointer on the current interface descriptor. More... | |
static bool | udc_iface_disable (uint8_t iface_num) |
Disables an usb device interface (UDI) This routine call the UDI corresponding to interface number. More... | |
static bool | udc_iface_enable (uint8_t iface_num, uint8_t setting_num) |
Enables an usb device interface (UDI) This routine calls the UDI corresponding to the interface and setting number. More... | |
bool | udc_process_setup (void) |
Main routine to manage the USB SETUP request. More... | |
static bool | udc_req_ep (void) |
Send the SETUP interface request to UDI. More... | |
static bool | udc_req_iface (void) |
Send the SETUP interface request to UDI. More... | |
static bool | udc_req_std_dev_clear_feature (void) |
Standard device request to change device status. More... | |
static bool | udc_req_std_dev_get_configuration (void) |
Standard device request to get configuration number. More... | |
static bool | udc_req_std_dev_get_descriptor (void) |
Standard device request to get descriptors about USB device. More... | |
static bool | udc_req_std_dev_get_status (void) |
Standard device request to get device status. More... | |
static bool | udc_req_std_dev_get_str_desc (void) |
Standard device request to get device string descriptor. More... | |
static bool | udc_req_std_dev_set_address (void) |
Standard device request to set device address. More... | |
static bool | udc_req_std_dev_set_configuration (void) |
Standard device request to enable a configuration. More... | |
static bool | udc_req_std_dev_set_feature (void) |
Standard device request to set a feature. More... | |
static bool | udc_req_std_iface_get_setting (void) |
Standard interface request to get the alternate setting number of an interface. More... | |
static bool | udc_req_std_iface_set_setting (void) |
Standard interface request to set an alternate setting of an interface. More... | |
static bool | udc_reqstd (void) |
Main routine to manage the standard USB SETUP request. More... | |
void | udc_reset (void) |
Reset the current configuration of the USB device, This routines can be called by UDD when a RESET on the USB line occurs. More... | |
void | udc_sof_notify (void) |
To signal that a SOF is occurred. More... | |
void | udc_start (void) |
Start the USB Device stack. More... | |
void | udc_stop (void) |
Stop the USB Device stack. More... | |
static bool | udc_update_iface_desc (uint8_t iface_num, uint8_t setting_num) |
Search an interface descriptor This routine updates the internal pointer udc_ptr_iface. More... | |
static void | udc_valid_address (void) |
Standard endpoint request to halt an endpoint. More... | |
Internal variables to manage the USB device | |
static le16_t | udc_device_status |
Device status state (see enum usb_device_status in usb_protocol.h) More... | |
static COMPILER_WORD_ALIGNED uint8_t | udc_iface_setting = 0 |
Device interface setting value. More... | |
static COMPILER_WORD_ALIGNED uint8_t | udc_num_configuration = 0 |
Device Configuration number selected by the USB host. More... | |
static udc_config_speed_t UDC_DESC_STORAGE * | udc_ptr_conf |
Pointer on the selected speed device configuration. More... | |
static usb_iface_desc_t UDC_DESC_STORAGE * | udc_ptr_iface |
Pointer on interface descriptor used by SETUP request. More... | |
Internal structure to store the USB device main strings | |
static COMPILER_WORD_ALIGNED UDC_DESC_STORAGE usb_str_lgid_desc_t | udc_string_desc_languageid |
Language ID of USB device (US ID by default) More... | |
static COMPILER_WORD_ALIGNED UDC_DESC_STORAGE struct udc_string_desc_t | udc_string_desc |
#define | USB_DEVICE_MANUFACTURE_NAME_SIZE 0 |
USB device manufacture name storage String is allocated only if USB_DEVICE_MANUFACTURE_NAME is declared by usb application configuration. More... | |
#define | USB_DEVICE_PRODUCT_NAME_SIZE 0 |
USB device product name storage String is allocated only if USB_DEVICE_PRODUCT_NAME is declared by usb application configuration. More... | |
#define | USB_DEVICE_SERIAL_NAME_SIZE 0 |
Get USB device serial number. More... | |
#define USB_DEVICE_MANUFACTURE_NAME_SIZE 0 |
USB device manufacture name storage String is allocated only if USB_DEVICE_MANUFACTURE_NAME is declared by usb application configuration.
Referenced by udc_req_std_dev_get_str_desc().
#define USB_DEVICE_PRODUCT_NAME_SIZE 0 |
USB device product name storage String is allocated only if USB_DEVICE_PRODUCT_NAME is declared by usb application configuration.
Referenced by udc_req_std_dev_get_str_desc().
#define USB_DEVICE_SERIAL_NAME_SIZE 0 |
Get USB device serial number.
Use the define USB_DEVICE_SERIAL_NAME to set static serial number.
For dynamic serial number set the define USB_DEVICE_GET_SERIAL_NAME_POINTER to a suitable pointer. This will also require the serial number length define USB_DEVICE_GET_SERIAL_NAME_LENGTH.
Referenced by udc_req_std_dev_get_str_desc().
|
static |
Returns a value to check the end of USB Configuration descriptor.
References udc_config_speed_t::desc, le16_to_cpu, UDC_DESC_STORAGE, udc_ptr_conf, and usb_conf_desc_t::wTotalLength.
Referenced by udc_update_iface_desc().
usb_iface_desc_t UDC_DESC_STORAGE* udc_get_interface_desc | ( | void | ) |
Returns a pointer on the current interface descriptor.
References udc_ptr_iface.
Referenced by udi_hid_reqstdifaceget_descriptor(), and udi_vendor_enable().
|
static |
Disables an usb device interface (UDI) This routine call the UDI corresponding to interface number.
iface_num | Interface number to disable |
References NULL, UDC_DESC_STORAGE, udc_ptr_conf, udc_ptr_iface, udc_update_iface_desc(), udd_ep_free(), udc_config_speed_t::udi_apis, and USB_DT_ENDPOINT.
Referenced by udc_req_std_iface_set_setting(), and udc_reset().
|
static |
Enables an usb device interface (UDI) This routine calls the UDI corresponding to the interface and setting number.
iface_num | Interface number to enable |
setting_num | Setting number to enable |
References udi_api_t::enable, le16_to_cpu, NULL, UDC_DESC_STORAGE, udc_ptr_conf, udc_ptr_iface, udc_update_iface_desc(), udd_ep_alloc(), udc_config_speed_t::udi_apis, and USB_DT_ENDPOINT.
Referenced by udc_req_std_dev_set_configuration(), and udc_req_std_iface_set_setting().
bool udc_process_setup | ( | void | ) |
Main routine to manage the USB SETUP request.
Decodes and manages a setup request.
This function parses a USB SETUP request and submits an appropriate response back to the host or, in the case of SETUP OUT requests with data, sets up a buffer for receiving the data payload.
The main standard requests defined by the USB 2.0 standard are handled internally. The interface requests are sent to UDI, and the specific request sent to a specific application callback.
References udd_ctrl_request_t::callback, NULL, udd_ctrl_request_t::over_under_run, udd_ctrl_request_t::payload_size, udd_ctrl_request_t::req, udc_req_ep(), udc_req_iface(), udc_reqstd(), udd_g_ctrlreq, Udd_setup_is_in, Udd_setup_recipient, Udd_setup_type, USB_REQ_RECIP_ENDPOINT, USB_REQ_RECIP_INTERFACE, USB_REQ_TYPE_STANDARD, and usb_setup_req_t::wLength.
|
static |
Send the SETUP interface request to UDI.
References usb_conf_desc_t::bNumInterfaces, udc_config_speed_t::desc, udd_ctrl_request_t::req, UDC_DESC_STORAGE, udc_num_configuration, udc_ptr_conf, udc_update_iface_desc(), udd_g_ctrlreq, udc_config_speed_t::udi_apis, and usb_setup_req_t::wIndex.
Referenced by udc_process_setup().
|
static |
Send the SETUP interface request to UDI.
References usb_conf_desc_t::bNumInterfaces, udc_config_speed_t::desc, udd_ctrl_request_t::req, udi_api_t::setup, UDC_DESC_STORAGE, udc_num_configuration, udc_ptr_conf, udc_update_iface_desc(), udd_g_ctrlreq, udc_config_speed_t::udi_apis, and usb_setup_req_t::wIndex.
Referenced by udc_process_setup().
|
static |
Standard device request to change device status.
References CPU_TO_LE16, udd_ctrl_request_t::req, udc_device_status, UDC_REMOTEWAKEUP_DISABLE, udd_g_ctrlreq, USB_DEV_FEATURE_REMOTE_WAKEUP, USB_DEV_STATUS_REMOTEWAKEUP, usb_setup_req_t::wLength, and usb_setup_req_t::wValue.
Referenced by udc_reqstd().
|
static |
Standard device request to get configuration number.
References udd_ctrl_request_t::req, udc_num_configuration, udd_g_ctrlreq, udd_set_setup_payload(), and usb_setup_req_t::wLength.
Referenced by udc_reqstd().
|
static |
Standard device request to get descriptors about USB device.
References usb_dev_desc_t::bLength, udc_config_t::conf_bos, udc_config_t::conf_lsfs, udc_config_t::confdev_lsfs, udc_config_speed_t::desc, le16_to_cpu, NULL, udd_ctrl_request_t::payload, udd_ctrl_request_t::payload_size, udd_ctrl_request_t::req, udc_config, udc_req_std_dev_get_str_desc(), udd_g_ctrlreq, udd_is_high_speed(), udd_set_setup_payload(), USB_DT_BOS, USB_DT_CONFIGURATION, USB_DT_DEVICE, USB_DT_DEVICE_QUALIFIER, USB_DT_OTHER_SPEED_CONFIGURATION, USB_DT_STRING, usb_setup_req_t::wLength, usb_dev_bos_desc_t::wTotalLength, usb_conf_desc_t::wTotalLength, and usb_setup_req_t::wValue.
Referenced by udc_reqstd().
|
static |
Standard device request to get device status.
References udd_ctrl_request_t::req, udc_device_status, udd_g_ctrlreq, udd_set_setup_payload(), and usb_setup_req_t::wLength.
Referenced by udc_reqstd().
|
static |
Standard device request to get device string descriptor.
References usb_str_desc_t::bLength, cpu_to_le16, udc_string_desc_t::header, i, udd_ctrl_request_t::req, udc_string_desc_t::string, UDC_GET_EXTRA_STRING, udc_string_desc_languageid, udd_g_ctrlreq, udd_set_setup_payload(), USB_DEVICE_MANUFACTURE_NAME_SIZE, USB_DEVICE_PRODUCT_NAME_SIZE, USB_DEVICE_SERIAL_NAME_SIZE, and usb_setup_req_t::wValue.
Referenced by udc_req_std_dev_get_descriptor().
|
static |
Standard device request to set device address.
References udd_ctrl_request_t::callback, udd_ctrl_request_t::req, udc_valid_address(), udd_g_ctrlreq, and usb_setup_req_t::wLength.
Referenced by udc_reqstd().
|
static |
Standard device request to enable a configuration.
References usb_dev_desc_t::bNumConfigurations, usb_conf_desc_t::bNumInterfaces, udc_config_t::conf_lsfs, udc_config_t::confdev_lsfs, udc_config_speed_t::desc, udd_ctrl_request_t::req, udc_config, udc_iface_enable(), udc_num_configuration, udc_ptr_conf, udc_reset(), udd_g_ctrlreq, udd_getaddress(), udd_is_high_speed(), usb_setup_req_t::wLength, and usb_setup_req_t::wValue.
Referenced by udc_reqstd().
|
static |
Standard device request to set a feature.
References udd_ctrl_request_t::callback, CPU_TO_LE16, udd_ctrl_request_t::req, udc_device_status, UDC_REMOTEWAKEUP_ENABLE, udc_reset(), udd_g_ctrlreq, udd_is_high_speed(), udd_test_mode_j(), udd_test_mode_k(), udd_test_mode_packet(), udd_test_mode_se0_nak(), USB_DEV_FEATURE_REMOTE_WAKEUP, USB_DEV_FEATURE_TEST_MODE, USB_DEV_STATUS_REMOTEWAKEUP, USB_DEV_TEST_MODE_FORCE_ENABLE, USB_DEV_TEST_MODE_J, USB_DEV_TEST_MODE_K, USB_DEV_TEST_MODE_PACKET, USB_DEV_TEST_MODE_SE0_NAK, usb_setup_req_t::wIndex, usb_setup_req_t::wLength, and usb_setup_req_t::wValue.
Referenced by udc_reqstd().
|
static |
Standard interface request to get the alternate setting number of an interface.
References usb_conf_desc_t::bNumInterfaces, udc_config_speed_t::desc, udd_ctrl_request_t::req, UDC_DESC_STORAGE, udc_iface_setting, udc_num_configuration, udc_ptr_conf, udc_update_iface_desc(), udd_g_ctrlreq, udd_set_setup_payload(), udc_config_speed_t::udi_apis, usb_setup_req_t::wIndex, and usb_setup_req_t::wLength.
Referenced by udc_reqstd().
|
static |
Standard interface request to set an alternate setting of an interface.
References udd_ctrl_request_t::req, udc_iface_disable(), udc_iface_enable(), udc_num_configuration, udd_g_ctrlreq, usb_setup_req_t::wIndex, usb_setup_req_t::wLength, and usb_setup_req_t::wValue.
Referenced by udc_reqstd().
|
static |
Main routine to manage the standard USB SETUP request.
References usb_setup_req_t::bRequest, udd_ctrl_request_t::req, udc_req_std_dev_clear_feature(), udc_req_std_dev_get_configuration(), udc_req_std_dev_get_descriptor(), udc_req_std_dev_get_status(), udc_req_std_dev_set_address(), udc_req_std_dev_set_configuration(), udc_req_std_dev_set_feature(), udc_req_std_iface_get_setting(), udc_req_std_iface_set_setting(), udd_g_ctrlreq, Udd_setup_is_in, Udd_setup_recipient, USB_REQ_CLEAR_FEATURE, USB_REQ_GET_CONFIGURATION, USB_REQ_GET_DESCRIPTOR, USB_REQ_GET_INTERFACE, USB_REQ_GET_STATUS, USB_REQ_RECIP_DEVICE, USB_REQ_RECIP_ENDPOINT, USB_REQ_RECIP_INTERFACE, USB_REQ_SET_ADDRESS, USB_REQ_SET_CONFIGURATION, USB_REQ_SET_DESCRIPTOR, USB_REQ_SET_FEATURE, USB_REQ_SET_INTERFACE, and usb_setup_req_t::wLength.
Referenced by udc_process_setup().
void udc_reset | ( | void | ) |
Reset the current configuration of the USB device, This routines can be called by UDD when a RESET on the USB line occurs.
Reset the UDC.
References usb_conf_desc_t::bNumInterfaces, CPU_TO_LE16, udc_config_speed_t::desc, udc_device_status, udc_iface_disable(), udc_num_configuration, udc_ptr_conf, UDC_REMOTEWAKEUP_DISABLE, USB_DEV_STATUS_BUS_POWERED, USB_DEV_STATUS_REMOTEWAKEUP, and USB_DEV_STATUS_SELF_POWERED.
void udc_sof_notify | ( | void | ) |
To signal that a SOF is occurred.
The UDC must send the signal to all UDIs enabled
References usb_conf_desc_t::bNumInterfaces, udc_config_speed_t::desc, NULL, udi_api_t::sof_notify, udc_num_configuration, udc_ptr_conf, and udc_config_speed_t::udi_apis.
void udc_start | ( | void | ) |
Start the USB Device stack.
References udd_enable().
void udc_stop | ( | void | ) |
Stop the USB Device stack.
References udc_reset(), and udd_disable().
|
static |
Search an interface descriptor This routine updates the internal pointer udc_ptr_iface.
iface_num | Interface number to find in Configuration Descriptor |
setting_num | Setting number of interface to find |
References usb_iface_desc_t::bAlternateSetting, usb_iface_desc_t::bDescriptorType, usb_iface_desc_t::bInterfaceNumber, usb_iface_desc_t::bLength, usb_conf_desc_t::bNumInterfaces, udc_config_speed_t::desc, UDC_DESC_STORAGE, udc_get_eof_conf(), udc_num_configuration, udc_ptr_conf, udc_ptr_iface, and USB_DT_INTERFACE.
Referenced by udc_iface_disable(), udc_iface_enable(), udc_req_ep(), udc_req_iface(), and udc_req_std_iface_get_setting().
|
static |
Standard endpoint request to halt an endpoint.
References udd_ctrl_request_t::req, udd_g_ctrlreq, udd_set_address(), and usb_setup_req_t::wValue.
Referenced by udc_req_std_dev_set_address().
|
static |
Device status state (see enum usb_device_status in usb_protocol.h)
Referenced by udc_req_std_dev_clear_feature(), udc_req_std_dev_get_status(), udc_req_std_dev_set_feature(), and udc_reset().
|
static |
Device interface setting value.
Referenced by udc_req_std_iface_get_setting().
|
static |
Device Configuration number selected by the USB host.
Referenced by udc_req_ep(), udc_req_iface(), udc_req_std_dev_get_configuration(), udc_req_std_dev_set_configuration(), udc_req_std_iface_get_setting(), udc_req_std_iface_set_setting(), udc_reset(), udc_sof_notify(), and udc_update_iface_desc().
|
static |
Pointer on the selected speed device configuration.
Referenced by udc_get_eof_conf(), udc_iface_disable(), udc_iface_enable(), udc_req_ep(), udc_req_iface(), udc_req_std_dev_set_configuration(), udc_req_std_iface_get_setting(), udc_reset(), udc_sof_notify(), and udc_update_iface_desc().
|
static |
Pointer on interface descriptor used by SETUP request.
Referenced by udc_get_interface_desc(), udc_iface_disable(), udc_iface_enable(), and udc_update_iface_desc().
|
static |
|
static |
Language ID of USB device (US ID by default)
Referenced by udc_req_std_dev_get_str_desc().