Harald Welte | 34a8706 | 2019-04-19 22:33:36 +0200 | [diff] [blame] | 1 | #include "usbd_config.h" |
| 2 | #include "usbdc.h" |
| 3 | #include "usb_protocol.h" |
| 4 | #include "usb_protocol_cdc.h" |
| 5 | #include "ccid_proto.h" |
| 6 | #include "cdcdf_acm_desc.h" |
Eric Wild | ff5c390 | 2019-10-17 20:21:44 +0200 | [diff] [blame^] | 7 | #include "usb_descriptors.h" |
Harald Welte | 34a8706 | 2019-04-19 22:33:36 +0200 | [diff] [blame] | 8 | |
Harald Welte | 34a8706 | 2019-04-19 22:33:36 +0200 | [diff] [blame] | 9 | |
Harald Welte | 34a8706 | 2019-04-19 22:33:36 +0200 | [diff] [blame] | 10 | |
Eric Wild | ff5c390 | 2019-10-17 20:21:44 +0200 | [diff] [blame^] | 11 | const struct usb_desc_collection usb_fs_descs = { |
Harald Welte | 34a8706 | 2019-04-19 22:33:36 +0200 | [diff] [blame] | 12 | .dev = { |
| 13 | .bLength = sizeof(struct usb_dev_desc), |
| 14 | .bDescriptorType = USB_DT_DEVICE, |
| 15 | .bcdUSB = USB_V2_0, |
| 16 | .bDeviceClass = 0x02, |
| 17 | .bDeviceSubClass = 0, |
| 18 | .bDeviceProtocol = 0, |
| 19 | .bMaxPacketSize0 = CONF_USB_CDCD_ACM_BMAXPKSZ0, |
| 20 | .idVendor = CONF_USB_CDCD_ACM_IDVENDER, |
| 21 | .idProduct = CONF_USB_CDCD_ACM_IDPRODUCT, |
| 22 | .iManufacturer = STR_DESC_MANUF, |
| 23 | .iProduct = STR_DESC_PRODUCT, |
| 24 | .iSerialNumber = STR_DESC_SERIAL, |
| 25 | .bNumConfigurations = 1, |
| 26 | }, |
| 27 | .cfg = { |
| 28 | .bLength = sizeof(struct usb_config_desc), |
| 29 | .bDescriptorType = USB_DT_CONFIG, |
| 30 | .wTotalLength = sizeof(usb_fs_descs.cfg) + |
| 31 | sizeof(usb_fs_descs.cdc) + |
| 32 | sizeof(usb_fs_descs.ccid), |
| 33 | .bNumInterfaces = 3, |
| 34 | .bConfigurationValue = CONF_USB_CDCD_ACM_BCONFIGVAL, |
| 35 | .iConfiguration = STR_DESC_CONFIG, |
| 36 | .bmAttributes = CONF_USB_CDCD_ACM_BMATTRI, |
| 37 | .bMaxPower = CONF_USB_CDCD_ACM_BMAXPOWER, |
| 38 | }, |
| 39 | .cdc = { |
| 40 | .comm = { |
| 41 | .iface = { |
| 42 | .bLength = sizeof(struct usb_iface_desc), |
| 43 | .bDescriptorType = USB_DT_INTERFACE, |
| 44 | .bInterfaceNumber = CONF_USB_CDCD_ACM_COMM_BIFCNUM, |
| 45 | .bAlternateSetting = CONF_USB_CDCD_ACM_COMM_BALTSET, |
| 46 | .bNumEndpoints = 1, |
| 47 | .bInterfaceClass = CDC_CLASS_COMM, |
| 48 | .bInterfaceSubClass = CDC_SUBCLASS_ACM, |
| 49 | .bInterfaceProtocol = 0x00, |
| 50 | .iInterface = STR_DESC_INTF_ACM_COMM, |
| 51 | }, |
| 52 | .cdc_hdr = { |
| 53 | .bFunctionLength = sizeof(struct usb_cdc_hdr_desc), |
| 54 | .bDescriptorType = CDC_CS_INTERFACE, |
| 55 | .bDescriptorSubtype = CDC_SCS_HEADER, |
| 56 | .bcdCDC = LE16(0x1001), |
| 57 | }, |
| 58 | .cdc_call_mgmt = { |
| 59 | .bFunctionLength = sizeof(struct usb_cdc_call_mgmt_desc), |
| 60 | .bDescriptorType = CDC_CS_INTERFACE, |
| 61 | .bDescriptorSubtype = CDC_SCS_CALL_MGMT, |
| 62 | .bmCapabilities = 0x01, |
| 63 | .bDataInterface = 0x00, |
| 64 | }, |
| 65 | .cdc_acm = { |
| 66 | .bFunctionLength = sizeof(struct usb_cdc_acm_desc), |
| 67 | .bDescriptorType = CDC_CS_INTERFACE, |
| 68 | .bDescriptorSubtype = CDC_SCS_ACM, |
| 69 | .bmCapabilities = 0x02, |
| 70 | }, |
| 71 | .cdc_union = { |
| 72 | .bFunctionLength = sizeof(struct usb_cdc_union_desc), |
| 73 | .bDescriptorType = CDC_CS_INTERFACE, |
| 74 | .bDescriptorSubtype = CDC_SCS_UNION, |
| 75 | .bMasterInterface = CONF_USB_CDCD_ACM_COMM_BIFCNUM, |
| 76 | .bSlaveInterface0 = 0x01, |
| 77 | }, |
| 78 | .ep = { |
| 79 | { |
| 80 | .bLength = sizeof(struct usb_ep_desc), |
| 81 | .bDescriptorType = USB_DT_ENDPOINT, |
| 82 | .bEndpointAddress = CONF_USB_CDCD_ACM_COMM_INT_EPADDR, |
| 83 | .bmAttributes = USB_EP_TYPE_INTERRUPT, |
| 84 | .wMaxPacketSize = CONF_USB_CDCD_ACM_COMM_INT_MAXPKSZ, |
| 85 | .bInterval = CONF_USB_CDCD_ACM_COMM_INT_INTERVAL, |
| 86 | }, |
| 87 | }, |
| 88 | }, |
| 89 | .data = { |
| 90 | .iface = { |
| 91 | .bLength = sizeof(struct usb_iface_desc), |
| 92 | .bDescriptorType = USB_DT_INTERFACE, |
| 93 | .bInterfaceNumber = CONF_USB_CDCD_ACM_DATA_BIFCNUM, |
| 94 | .bAlternateSetting = CONF_USB_CDCD_ACM_DATA_BALTSET, |
| 95 | .bNumEndpoints = 2, |
| 96 | .bInterfaceClass = CDC_CLASS_DATA, |
| 97 | .bInterfaceSubClass = 0x00, |
| 98 | .bInterfaceProtocol = 0x00, |
| 99 | .iInterface = STR_DESC_INTF_ACM_DATA, |
| 100 | }, |
| 101 | .ep = { |
| 102 | { |
| 103 | .bLength = sizeof(struct usb_ep_desc), |
| 104 | .bDescriptorType = USB_DT_ENDPOINT, |
| 105 | .bEndpointAddress = CONF_USB_CDCD_ACM_DATA_BULKOUT_EPADDR, |
| 106 | .bmAttributes = USB_EP_TYPE_BULK, |
| 107 | .wMaxPacketSize = CONF_USB_CDCD_ACM_DATA_BULKOUT_MAXPKSZ, |
| 108 | .bInterval = 0, |
| 109 | }, |
| 110 | { |
| 111 | .bLength = sizeof(struct usb_ep_desc), |
| 112 | .bDescriptorType = USB_DT_ENDPOINT, |
| 113 | .bEndpointAddress = CONF_USB_CDCD_ACM_DATA_BULKIN_EPADDR, |
| 114 | .bmAttributes = USB_EP_TYPE_BULK, |
| 115 | .wMaxPacketSize = CONF_USB_CDCD_ACM_DATA_BULKIN_MAXPKSZ, |
| 116 | .bInterval = 0, |
| 117 | }, |
| 118 | }, |
| 119 | }, |
| 120 | }, |
| 121 | .ccid = { |
| 122 | .iface = { |
| 123 | .bLength = sizeof(struct usb_iface_desc), |
| 124 | .bDescriptorType = USB_DT_INTERFACE, |
Eric Wild | 7603390 | 2019-10-01 15:04:01 +0200 | [diff] [blame] | 125 | .bInterfaceNumber = 0, |
Harald Welte | 34a8706 | 2019-04-19 22:33:36 +0200 | [diff] [blame] | 126 | .bAlternateSetting = 0, |
| 127 | .bNumEndpoints = 3, |
| 128 | .bInterfaceClass = 11, |
| 129 | .bInterfaceSubClass = 0, |
| 130 | .bInterfaceProtocol = 0, |
| 131 | .iInterface = STR_DESC_INTF_CCID, |
| 132 | }, |
| 133 | .class = { |
| 134 | .bLength = sizeof(struct usb_ccid_class_descriptor), |
| 135 | .bDescriptorType = 33, |
| 136 | .bcdCCID = LE16(0x0110), |
| 137 | .bMaxSlotIndex = 7, |
Eric Wild | 7603390 | 2019-10-01 15:04:01 +0200 | [diff] [blame] | 138 | .bVoltageSupport = 0x07, /* 5/3/1.8V */ |
Eric Wild | ff5c390 | 2019-10-17 20:21:44 +0200 | [diff] [blame^] | 139 | // .dwProtocols = 0x03, |
| 140 | .dwProtocols = 0x01, |
Harald Welte | 34a8706 | 2019-04-19 22:33:36 +0200 | [diff] [blame] | 141 | .dwDefaultClock = LE32(2500), |
| 142 | .dwMaximumClock = LE32(20000), |
Eric Wild | ff5c390 | 2019-10-17 20:21:44 +0200 | [diff] [blame^] | 143 | .bNumClockSupported = CCID_NUM_CLK_SUPPORTED, |
Harald Welte | 34a8706 | 2019-04-19 22:33:36 +0200 | [diff] [blame] | 144 | .dwDataRate = LE32(9600), |
| 145 | .dwMaxDataRate = LE32(921600), |
| 146 | .bNumDataRatesSupported = 0, |
| 147 | .dwMaxIFSD = LE32(0), |
| 148 | .dwSynchProtocols = LE32(0), |
| 149 | .dwMechanical = LE32(0), |
Eric Wild | ff5c390 | 2019-10-17 20:21:44 +0200 | [diff] [blame^] | 150 | .dwFeatures = LE32(0x10 | 0x00010080), |
| 151 | // .dwFeatures = LE32(0x2 | 0x40), |
Harald Welte | 34a8706 | 2019-04-19 22:33:36 +0200 | [diff] [blame] | 152 | .dwMaxCCIDMessageLength = 272, |
| 153 | .bClassGetResponse = 0xff, |
| 154 | .bClassEnvelope = 0xff, |
| 155 | .wLcdLayout = LE16(0), |
| 156 | .bPINSupport = 0, |
| 157 | .bMaxCCIDBusySlots = 8, |
| 158 | }, |
| 159 | .ep = { |
| 160 | { /* Bulk-OUT descriptor */ |
| 161 | .bLength = sizeof(struct usb_ep_desc), |
| 162 | .bDescriptorType = USB_DT_ENDPOINT, |
| 163 | .bEndpointAddress = 0x02, |
| 164 | .bmAttributes = USB_EP_TYPE_BULK, |
| 165 | .wMaxPacketSize = 64, |
| 166 | .bInterval = 0, |
| 167 | }, |
| 168 | { /* Bulk-IN descriptor */ |
| 169 | .bLength = sizeof(struct usb_ep_desc), |
| 170 | .bDescriptorType = USB_DT_ENDPOINT, |
| 171 | .bEndpointAddress = 0x83, |
| 172 | .bmAttributes = USB_EP_TYPE_BULK, |
| 173 | .wMaxPacketSize = 64, |
| 174 | .bInterval = 0, |
| 175 | }, |
| 176 | { /* Interrupt dscriptor */ |
| 177 | .bLength = sizeof(struct usb_ep_desc), |
| 178 | .bDescriptorType = USB_DT_ENDPOINT, |
| 179 | .bEndpointAddress = 0x84, |
| 180 | .bmAttributes = USB_EP_TYPE_INTERRUPT, |
| 181 | .wMaxPacketSize = 64, |
| 182 | .bInterval = 0x10, |
| 183 | }, |
| 184 | }, |
| 185 | }, |
| 186 | //DFURT_IF_DESCRIPTOR, |
| 187 | .str = { |
| 188 | #if 0 |
| 189 | CDCD_ACM_STR_DESCES |
| 190 | #else |
| 191 | 4, 3, 0x09, 0x04, |
| 192 | 18, 3, 's',0, 'y',0, 's',0, 'm',0, 'o',0, 'c',0, 'o',0, 'm',0, |
| 193 | 24, 3, 's',0, 'y',0, 's',0, 'm',0, 'o',0, 'O',0, 'C',0, 'T',0, 'S',0, 'I',0, 'M',0, |
| 194 | 4, 3, 'A', 0, |
| 195 | 22, 3, 'd',0, 'e',0, 'b',0, 'u',0, 'g',0, ' ',0, 'U',0, 'A',0, 'R',0, 'T',0, |
| 196 | 22, 3, 'd',0, 'e',0, 'b',0, 'u',0, 'g',0, ' ',0, 'U',0, 'A',0, 'R',0, 'T',0, |
| 197 | 10, 3, 'C',0, 'C',0, 'I',0, 'D',0, |
| 198 | 12, 3, 'F',0, 'I',0, 'X',0, 'M',0, 'E',0, |
| 199 | #endif |
| 200 | } |
| 201 | }; |
| 202 | |
| 203 | const struct usbd_descriptors usb_descs[] |
| 204 | = {{ (uint8_t *)&usb_fs_descs, (uint8_t *)&usb_fs_descs + sizeof(usb_fs_descs) }}; |