93 #ifdef USB_DEVICE_MANUFACTURE_NAME 94 static uint8_t udc_string_manufacturer_name[] = USB_DEVICE_MANUFACTURE_NAME;
95 # define USB_DEVICE_MANUFACTURE_NAME_SIZE \ 96 (sizeof(udc_string_manufacturer_name)-1) 98 # define USB_DEVICE_MANUFACTURE_NAME_SIZE 0 106 #ifdef USB_DEVICE_PRODUCT_NAME 107 static uint8_t udc_string_product_name[] = USB_DEVICE_PRODUCT_NAME;
108 # define USB_DEVICE_PRODUCT_NAME_SIZE (sizeof(udc_string_product_name)-1) 110 # define USB_DEVICE_PRODUCT_NAME_SIZE 0 122 #if defined USB_DEVICE_GET_SERIAL_NAME_POINTER 123 static const uint8_t *udc_get_string_serial_name(
void)
125 return (
const uint8_t *)USB_DEVICE_GET_SERIAL_NAME_POINTER;
127 # define USB_DEVICE_SERIAL_NAME_SIZE \ 128 USB_DEVICE_GET_SERIAL_NAME_LENGTH 129 #elif defined USB_DEVICE_SERIAL_NAME 130 static const uint8_t *udc_get_string_serial_name(
void)
132 return (
const uint8_t *)USB_DEVICE_SERIAL_NAME;
134 # define USB_DEVICE_SERIAL_NAME_SIZE \ 135 (sizeof(USB_DEVICE_SERIAL_NAME)-1) 137 # define USB_DEVICE_SERIAL_NAME_SIZE 0 149 COMPILER_WORD_ALIGNED
172 #if (0!=USB_DEVICE_MAX_EP) 193 while (ptr_eof_desc > desc) {
199 if (desc_id == desc->bDescriptorType) {
237 while (ptr_end_desc >
277 #if (0!=USB_DEVICE_MAX_EP) 292 if (
NULL == ep_desc) {
296 udd_ep_free(ep_desc->bEndpointAddress);
323 #if (0!=USB_DEVICE_MAX_EP) 337 if (!udd_ep_alloc(ep_desc->bEndpointAddress,
338 ep_desc->bmAttributes,
340 (ep_desc->wMaxPacketSize))) {
380 #if (USB_CONFIG_ATTR_REMOTE_WAKEUP \ 381 == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP)) 384 UDC_REMOTEWAKEUP_DISABLE();
388 #if (USB_DEVICE_ATTR & USB_CONFIG_ATTR_SELF_POWERED) 422 sizeof(udc_device_status));
426 #if (0!=USB_DEVICE_MAX_EP) 432 static bool udc_req_std_ep_get_status(
void)
434 static le16_t udc_ep_status;
444 sizeof(udc_ep_status));
462 #if (USB_CONFIG_ATTR_REMOTE_WAKEUP \ 463 == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP)) 464 UDC_REMOTEWAKEUP_DISABLE();
471 #if (0!=USB_DEVICE_MAX_EP) 477 static bool udc_req_std_ep_clear_feature(
void)
504 #if (USB_CONFIG_ATTR_REMOTE_WAKEUP \ 505 == (USB_DEVICE_ATTR & USB_CONFIG_ATTR_REMOTE_WAKEUP)) 507 UDC_REMOTEWAKEUP_ENABLE();
513 #ifdef USB_DEVICE_HS_SUPPORT 557 #if (0!=USB_DEVICE_MAX_EP) 558 static bool udc_req_std_ep_set_feature(
void)
605 const uint8_t *str=
NULL;
606 uint8_t str_length = 0;
612 sizeof(udc_string_desc_languageid));
615 #ifdef USB_DEVICE_MANUFACTURE_NAME 618 str = udc_string_manufacturer_name;
621 #ifdef USB_DEVICE_PRODUCT_NAME 624 str = udc_string_product_name;
627 #if defined USB_DEVICE_SERIAL_NAME || defined USB_DEVICE_GET_SERIAL_NAME_POINTER 630 str = udc_get_string_serial_name();
634 #ifdef UDC_GET_EXTRA_STRING 635 if (UDC_GET_EXTRA_STRING()) {
643 for(i = 0; i < str_length; i++) {
649 (uint8_t *) &udc_string_desc,
671 #ifdef USB_DEVICE_HS_SUPPORT 687 #ifdef USB_DEVICE_HS_SUPPORT 713 #ifdef USB_DEVICE_HS_SUPPORT 806 #ifdef USB_DEVICE_HS_SUPPORT 832 #ifdef USB_DEVICE_HS_SUPPORT 898 uint8_t iface_num, setting_num;
955 #if (0!=USB_DEVICE_MAX_EP) 960 return udc_req_std_ep_get_status();
996 #if (0!=USB_DEVICE_MAX_EP) 1001 return udc_req_std_ep_clear_feature();
1003 return udc_req_std_ep_set_feature();
1045 return udi_api->
setup();
1072 if (udi_api->setup()) {
1127 #ifdef USB_DEVICE_SPECIFIC_REQUEST 1129 return USB_DEVICE_SPECIFIC_REQUEST();
#define USB_DEVICE_PRODUCT_NAME_SIZE
USB device product name storage String is allocated only if USB_DEVICE_PRODUCT_NAME is declared by us...
static bool udc_req_std_dev_set_address(void)
Standard device request to set device address.
static void udc_valid_address(void)
Standard endpoint request to halt an endpoint.
#define USB_DEVICE_MANUFACTURE_NAME_SIZE
USB device manufacture name storage String is allocated only if USB_DEVICE_MANUFACTURE_NAME is declar...
void udd_test_mode_packet(void)
Common API for USB Device Interface.
Common API for USB Device Drivers (UDD)
A standard USB string descriptor structure.
USB configuration file for CDC application.
void udd_disable(void)
Disables the USB Device mode.
Interface of the USB Device Controller (UDC)
le16_t string[Max(Max(USB_DEVICE_MANUFACTURE_NAME_SIZE, USB_DEVICE_PRODUCT_NAME_SIZE), USB_DEVICE_SERIAL_NAME_SIZE)]
usb_iface_desc_t UDC_DESC_STORAGE * udc_get_interface_desc(void)
Returns a pointer on the current interface descriptor.
USB protocol definitions.
Common API for USB Device Interface.
void udd_test_mode_se0_nak(void)
#define USB_REQ_TYPE_STANDARD
USB request types (bmRequestType)
Standard USB configuration descriptor structure.
UDC_DESC_STORAGE udc_config_t udc_config
Add all information about USB Device in global structure for UDC.
static bool udc_req_std_iface_set_setting(void)
Standard interface request to set an alternate setting of an interface.
static bool udc_req_std_iface_get_setting(void)
Standard interface request to get the alternate setting number of an interface.
void udd_test_mode_k(void)
#define Udd_setup_recipient()
Return the recipient of the SETUP request udd_g_ctrlreq.
void(* callback)(void)
Callback called after reception of ZLP from setup request.
void udc_stop(void)
Stop the USB Device stack.
#define Udd_setup_is_in()
Return true if the setup request udd_g_ctrlreq indicates IN data transfer.
Configuration descriptor and UDI link for one USB speed.
bool udd_is_high_speed(void)
Test whether the USB Device Controller is running at high speed or not.
#define Max(a, b)
Takes the maximal value of a and b.
static bool udc_reqstd(void)
Main routine to manage the standard USB SETUP request.
void udc_start(void)
Start the USB Device stack.
#define USB_REQ_RECIP_ENDPOINT
Recipient endpoint.
bool(* enable)(void)
Enable the interface.
static usb_conf_desc_t UDC_DESC_STORAGE * udc_get_eof_conf(void)
Returns a value to check the end of USB Configuration descriptor.
void udd_enable(void)
Enables the USB Device mode.
static bool udc_req_std_dev_get_str_desc(void)
Standard device request to get device string descriptor.
void(* sof_notify)(void)
To signal that a SOF is occurred.
Standard USB interface descriptor structure.
void udd_set_address(uint8_t address)
Changes the USB address of device.
static COMPILER_WORD_ALIGNED uint8_t udc_num_configuration
Device Configuration number selected by the USB host.
static bool udc_req_std_dev_get_descriptor(void)
Standard device request to get descriptors about USB device.
static COMPILER_WORD_ALIGNED UDC_DESC_STORAGE struct udc_string_desc_t udc_string_desc
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.
#define USB_DEVICE_SERIAL_NAME_SIZE
Get USB device serial number.
static bool udc_req_std_dev_get_status(void)
Standard device request to get device status.
USB device string descriptor Structure used to transfer ASCII strings to USB String descriptor struct...
static udc_config_speed_t UDC_DESC_STORAGE * udc_ptr_conf
Pointer on the selected speed device configuration.
udc_config_speed_t UDC_DESC_STORAGE * conf_lsfs
USB configuration descriptor and UDI API pointers for low or full speed.
bool(* setup)(void)
Handle a control request directed at an interface.
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)
static le16_t udc_device_status
Device status state (see enum usb_device_status in usb_protocol.h)
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 s...
uint8_t bAlternateSetting
static bool udc_req_std_dev_set_configuration(void)
Standard device request to enable a configuration.
static bool udc_iface_disable(uint8_t iface_num)
Disables an usb device interface (UDI) This routine call the UDI corresponding to interface number...
static bool udc_req_std_dev_set_feature(void)
Standard device request to set a feature.
udi_api_t UDC_DESC_STORAGE *UDC_DESC_STORAGE * udi_apis
Array of UDI API pointer.
bool udc_process_setup(void)
Main routine to manage the USB SETUP request.
#define Udd_setup_type()
Return the type of the SETUP request udd_g_ctrlreq.
static bool udc_req_ep(void)
Send the SETUP interface request to UDI.
Standard USB endpoint descriptor structure.
static bool udc_req_std_dev_get_configuration(void)
Standard device request to get configuration number.
uint8_t bNumConfigurations
uint8_t udd_getaddress(void)
Returns the USB address of device.
udd_ctrl_request_t udd_g_ctrlreq
Global variable to give and record information about setup request management.
usb_dev_desc_t UDC_DESC_STORAGE * confdev_lsfs
USB device descriptor for low or full speed.
static bool udc_req_iface(void)
Send the SETUP interface request to UDI.
#define UDC_DESC_STORAGE
Defines the memory's location of USB descriptors.
usb_conf_desc_t UDC_DESC_STORAGE * desc
USB configuration descriptor.
static bool udc_req_std_dev_clear_feature(void)
Standard device request to change device status.
#define USB_REQ_RECIP_DEVICE
USB recipient codes (bmRequestType)
static usb_iface_desc_t UDC_DESC_STORAGE * udc_ptr_iface
Pointer on interface descriptor used by SETUP request.
static COMPILER_WORD_ALIGNED uint8_t udc_iface_setting
Device interface setting value.
void udd_set_setup_payload(uint8_t *payload, uint16_t payload_size)
Load setup payload.
bool(* over_under_run)(void)
usb_dev_bos_desc_t UDC_DESC_STORAGE * conf_bos
void udc_sof_notify(void)
To signal that a SOF is occurred.
uint16_t payload_size
Size of buffer to send or fill, and content the number of byte transfered.
uint8_t bNumConfigurations
void udd_test_mode_j(void)
void udc_reset(void)
Reset the current configuration of the USB device, This routines can be called by UDD when a RESET on...
#define USB_REQ_RECIP_INTERFACE
Recipient interface.