Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
usb_config.c
00001 /** 00002 * @file usb_config.c 00003 * @brief 00004 * 00005 * DAPLink Interface Firmware 00006 * Copyright (c) 2009-2019, ARM Limited, All Rights Reserved 00007 * SPDX-License-Identifier: Apache-2.0 00008 * 00009 * Licensed under the Apache License, Version 2.0 (the "License"); you may 00010 * not use this file except in compliance with the License. 00011 * You may obtain a copy of the License at 00012 * 00013 * http://www.apache.org/licenses/LICENSE-2.0 00014 * 00015 * Unless required by applicable law or agreed to in writing, software 00016 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 00017 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00018 * See the License for the specific language governing permissions and 00019 * limitations under the License. 00020 */ 00021 00022 // <e> USB Device 00023 // <i> Enable the USB Device functionality 00024 #define USBD_ENABLE 1 00025 #define USBD_RTX_CORE_STACK 0 00026 #define USBD_RTX_DEVICE_STACK 0 00027 #define USBD_RTX_ENDPOINT0_STACK 0 00028 00029 // <o0.0> High-speed 00030 // <i> Enable high-speed functionality (if device supports it) 00031 #define USBD_HS_ENABLE 1 00032 #if (defined(WEBUSB_INTERFACE) || defined(WINUSB_INTERFACE) || defined(BULK_ENDPOINT)) 00033 #define USBD_BOS_ENABLE 1 00034 #else 00035 #define USBD_BOS_ENABLE 0 00036 #endif 00037 // <h> Device Settings 00038 // <i> These settings affect Device Descriptor 00039 // <o0> Power 00040 // <i> Default Power Setting 00041 // <0=> Bus-powered 00042 // <1=> Self-powered 00043 // <o1> Max Endpoint 0 Packet Size 00044 // <i> Maximum packet size for endpoint zero (bMaxPacketSize0) 00045 // <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes 00046 // <o2.0..15> Vendor ID <0x0000-0xFFFF> 00047 // <i> Vendor ID assigned by the USB-IF (idVendor) 00048 // <o3.0..15> Product ID <0x0000-0xFFFF> 00049 // <i> Product ID assigned by the manufacturer (idProduct) 00050 // <o4.0..15> Device Release Number <0x0000-0xFFFF> 00051 // <i> Device release number in binary-coded decimal (bcdDevice) 00052 // </h> 00053 #define USBD_POWER 0 00054 #define USBD_MAX_PACKET0 64 00055 #define USBD_DEVDESC_IDVENDOR 0x0D28 00056 #define USBD_DEVDESC_IDPRODUCT 0x0204 00057 #define USBD_DEVDESC_BCDDEVICE 0x0100 00058 00059 // <h> Configuration Settings 00060 // <i> These settings affect Configuration Descriptor 00061 // <o0.5> Remote Wakeup 00062 // <i> Configuration support for remote wakeup (D5: of bmAttributes) 00063 // <o1.0..7> Maximum Power Consumption (in mA) <0-510><#/2> 00064 // <i> Maximum power consumption of the USB device 00065 // <i> from the bus in this specific configuration 00066 // <i> when the device is fully operational (bMaxPower) 00067 // </h> 00068 #define USBD_CFGDESC_BMATTRIBUTES 0x80 00069 #define USBD_CFGDESC_BMAXPOWER 0xFA 00070 00071 // <h> String Settings 00072 // <i> These settings affect String Descriptor 00073 // <o0.0..15> Language ID <0x0000-0xFCFF> 00074 // <i> English (United States) = 0x0409 00075 // <s0.126> Manufacturer String 00076 // <i> String descriptor describing manufacturer 00077 // <s1.126> Product String 00078 // <i> String descriptor describing product 00079 // <e1.0> Serial Number 00080 // <i> Enable serial number string 00081 // <i> If disabled serial number string will not be assigned to the USB Device 00082 // <s2.126> Serial Number String 00083 // <i> String descriptor describing device's serial number 00084 // </e> 00085 // </h> 00086 #define USBD_STRDESC_LANGID 0x0409 00087 #define USBD_STRDESC_MAN L"ARM" 00088 #ifndef USB_PROD_STR 00089 #define USBD_STRDESC_PROD L"DAPLink CMSIS-DAP" 00090 #else 00091 #define _TOWIDE(x) L ## #x 00092 #define TOWIDE(x) _TOWIDE(x) 00093 #define USBD_STRDESC_PROD TOWIDE(USB_PROD_STR) 00094 #endif 00095 #define USBD_STRDESC_SER_ENABLE 1 00096 #define USBD_STRDESC_SER L"0001A0000000" 00097 00098 // <e0> Class Support 00099 // <i> Enables USB Device Class specific Requests 00100 #define USBD_CLASS_ENABLE 1 00101 00102 // <e0.0> Human Interface Device (HID) 00103 // <i> Enable class support for Human Interface Device (HID) 00104 // <h> Interrupt Endpoint Settings 00105 // <o1.0..4> Interrupt In Endpoint Number <1=> 1 <2=> 2 <3=> 3 00106 // <4=> 4 <5=> 5 <6=> 6 <7=> 7 00107 // <8=> 8 <9=> 9 <10=> 10 <11=> 11 00108 // <12=> 12 <13=> 13 <14=> 14 <15=> 15 00109 // <o2.0..4> Interrupt Out Endpoint Number <0=> Not used <1=> 1 <2=> 2 <3=> 3 00110 // <4=> 4 <5=> 5 <6=> 6 <7=> 7 00111 // <8=> 8 <9=> 9 <10=> 10 <11=> 11 00112 // <12=> 12 <13=> 13 <14=> 14 <15=> 15 00113 // <i> If interrupt out endpoint is not used select "Not used" 00114 // <h> Endpoint Settings 00115 // <o3.0..7> Maximum Endpoint Packet Size (in bytes) <0-64> 00116 // <o4.0..7> Endpoint polling Interval (in ms) <1-255> 00117 // <e5> High-speed 00118 // <i> If high-speed is enabled set endpoint settings for it 00119 // <o6.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024> 00120 // <o6.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional 00121 // <o7.0..7> Endpoint polling Interval (in ms) <1=> 1 <2=> 2 <3=> 4 <4=> 8 00122 // <5=> 16 <6=> 32 <7=> 64 <8=> 128 00123 // <9=> 256 <10=> 512 <11=> 1024 <12=> 2048 00124 // <13=> 4096 <14=> 8192 <15=> 16384 <16=> 32768 00125 // </e> 00126 // </h> 00127 // </h> 00128 // <h> Human Interface Device Settings 00129 // <i> Device specific settings 00130 // <s0.126> HID Interface String 00131 // <o8.0..4> Number of Input Reports <1-32> 00132 // <o9.0..4> Number of Output Reports <1-32> 00133 // <o10.0..15> Maximum Input Report Size (in bytes) <1-65535> 00134 // <o11.0..15> Maximum Output Report Size (in bytes) <1-65535> 00135 // <o12.0..15> Maximum Feature Report Size (in bytes) <1-65535> 00136 // </h> 00137 // </e> 00138 #ifndef HID_ENDPOINT 00139 #define HID_ENDPOINT 0 00140 #else 00141 #define HID_ENDPOINT 1 00142 #endif 00143 00144 #ifndef WEBUSB_INTERFACE 00145 #define WEBUSB_INTERFACE 0 00146 #else 00147 #define WEBUSB_INTERFACE 1 00148 #endif 00149 00150 #define USBD_HID_ENABLE HID_ENDPOINT 00151 #define USBD_HID_EP_INTIN 3 00152 #define USBD_HID_EP_INTIN_STACK 0 00153 #define USBD_HID_EP_INTOUT 0 00154 #define USBD_HID_EP_INTOUT_STACK 0 00155 #define USBD_HID_WMAXPACKETSIZE 64 00156 #define USBD_HID_BINTERVAL 1 00157 #define USBD_HID_HS_ENABLE 1 00158 #define USBD_HID_HS_WMAXPACKETSIZE 64 00159 #define USBD_HID_HS_BINTERVAL 1 00160 #define USBD_HID_STRDESC L"CMSIS-DAP v1" 00161 #define USBD_WEBUSB_STRDESC L"WebUSB: CMSIS-DAP" 00162 #define USBD_HID_INREPORT_NUM 1 00163 #define USBD_HID_OUTREPORT_NUM 1 00164 #define USBD_HID_INREPORT_MAX_SZ 64 00165 #define USBD_HID_OUTREPORT_MAX_SZ 64 00166 #define USBD_HID_FEATREPORT_MAX_SZ 1 00167 00168 // <e0.0> Mass Storage Device (MSC) 00169 // <i> Enable class support for Mass Storage Device (MSC) 00170 // <h> Bulk Endpoint Settings 00171 // <o1.0..4> Bulk In Endpoint Number <1=> 1 <2=> 2 <3=> 3 00172 // <4=> 4 <5=> 5 <6=> 6 <7=> 7 00173 // <8=> 8 <9=> 9 <10=> 10 <11=> 11 00174 // <12=> 12 <13=> 13 <14=> 14 <15=> 15 00175 // <o2.0..4> Bulk Out Endpoint Number <1=> 1 <2=> 2 <3=> 3 00176 // <4=> 4 <5=> 5 <6=> 6 <7=> 7 00177 // <8=> 8 <9=> 9 <10=> 10 <11=> 11 00178 // <12=> 12 <13=> 13 <14=> 14 <15=> 15 00179 // <h> Endpoint Settings 00180 // <o3> Maximum Packet Size <1-1024> 00181 // <e4> High-speed 00182 // <i> If high-speed is enabled set endpoint settings for it 00183 // <o5> Maximum Packet Size <1-1024> 00184 // <o6> Maximum NAK Rate <0-255> 00185 // </e> 00186 // </h> 00187 // </h> 00188 // <h> Mass Storage Device Settings 00189 // <i> Device specific settings 00190 // <s0.126> MSC Interface String 00191 // <h> Inquiry Data 00192 // <s1.8> Vendor Identification 00193 // <s2.16> Product Identification 00194 // <s3.4> Product Revision Level 00195 // </h> 00196 // </h> 00197 // </e> 00198 #ifndef MSC_ENDPOINT 00199 #define MSC_ENDPOINT 0 00200 #else 00201 #define MSC_ENDPOINT 1 00202 #endif 00203 #define USBD_MSC_ENABLE MSC_ENDPOINT 00204 #define USBD_MSC_EP_BULKIN 1 00205 #define USBD_MSC_EP_BULKIN_STACK 0 00206 #define USBD_MSC_EP_BULKOUT 2 00207 #define USBD_MSC_EP_BULKOUT_STACK 0 00208 #define USBD_MSC_WMAXPACKETSIZE 64 00209 #define USBD_MSC_HS_ENABLE 1 00210 #define USBD_MSC_HS_WMAXPACKETSIZE 512 00211 #define USBD_MSC_HS_BINTERVAL 0 00212 #define USBD_MSC_STRDESC L"USB_MSC" 00213 // Make sure changes to USBD_MSC_INQUIRY_DATA are coordinated with mbed-ls 00214 // since this is used to detect DAPLink drives 00215 #define USBD_MSC_INQUIRY_DATA "MBED " \ 00216 "VFS " \ 00217 "0.1" 00218 00219 // <e0.0> Audio Device (ADC) 00220 // <i> Enable class support for Audio Device (ADC) 00221 // <h> Isochronous Endpoint Settings 00222 // <o1.0..4> Isochronous Out Endpoint Number <1=> 1 <2=> 2 <3=> 3 00223 // <4=> 4 <5=> 5 <6=> 6 <7=> 7 00224 // <8=> 8 <9=> 9 <10=> 10 <11=> 11 00225 // <12=> 12 <13=> 13 <14=> 14 <15=> 15 00226 // <h> Endpoint Settings 00227 // <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024> 00228 // <o3.0..10> Endpoint polling Interval (in ms) <1=> 1 <2=> 2 <3=> 4 <4=> 8 00229 // <5=> 16 <6=> 32 <7=> 64 <8=> 128 00230 // <9=> 256 <10=> 512 <11=> 1024 <12=> 2048 00231 // <13=> 4096 <14=> 8192 <15=> 16384 <16=> 32768 00232 // <e4> High-speed 00233 // <i> If high-speed is enabled set endpoint settings for it 00234 // <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024> 00235 // <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional 00236 // </e> 00237 // </h> 00238 // </h> 00239 // <h> Audio Device Settings 00240 // <i> Device specific settings 00241 // <s0.126> Audio Control Interface String 00242 // <s1.126> Audio Streaming (Zero Bandwidth) Interface String 00243 // <s2.126> Audio Streaming (Operational) Interface String 00244 // <o6.0..7> Audio Subframe Size (in bytes) <0-255> 00245 // <o7.0..7> Sample Resolution (in bits) <0-255> 00246 // <o8.0..23> Sample Frequency (in Hz) <0-16777215> 00247 // <o9> Packet Size (in bytes) <1-256> 00248 // <o10> Packet Count <1-16> 00249 // </h> 00250 // </e> 00251 #define USBD_ADC_ENABLE 0 00252 #define USBD_ADC_EP_ISOOUT 3 00253 #define USBD_ADC_WMAXPACKETSIZE 64 00254 #define USBD_ADC_BINTERVAL 1 00255 #define USBD_ADC_HS_ENABLE 0 00256 #define USBD_ADC_HS_WMAXPACKETSIZE 64 00257 #define USBD_ADC_CIF_STRDESC L"USB_ADC" 00258 #define USBD_ADC_SIF1_STRDESC L"USB_ADC1" 00259 #define USBD_ADC_SIF2_STRDESC L"USB_ADC2" 00260 #define USBD_ADC_BSUBFRAMESIZE 2 00261 #define USBD_ADC_BBITRESOLUTION 16 00262 #define USBD_ADC_TSAMFREQ 32000 00263 #define USBD_ADC_CFG_P_S 32 00264 #define USBD_ADC_CFG_P_C 1 00265 00266 // <e0> Communication Device (CDC) - Abstract Control Model (ACM) 00267 // <i> Enable class support for Communication Device (CDC) - Abstract Control Model (ACM) 00268 // <h> Interrupt Endpoint Settings 00269 // <o1.0..4> Interrupt In Endpoint Number <1=> 1 <2=> 2 <3=> 3 00270 // <4=> 4 <5=> 5 <6=> 6 <7=> 7 00271 // <8=> 8 <9=> 9 <10=> 10 <11=> 11 00272 // <12=> 12 <13=> 13 <14=> 14 <15=> 15 00273 // <h> Endpoint Settings 00274 // <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024> 00275 // <o3.0..10> Endpoint polling Interval (in ms) <0-255> 00276 // <e4> High-speed 00277 // <i> If high-speed is enabled set endpoint settings for it 00278 // <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024> 00279 // <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional 00280 // <o6.0..10> Endpoint polling Interval (in ms) <1=> 1 <2=> 2 <3=> 4 <4=> 8 00281 // <5=> 16 <6=> 32 <7=> 64 <8=> 128 00282 // <9=> 256 <10=> 512 <11=> 1024 <12=> 2048 00283 // <13=> 4096 <14=> 8192 <15=> 16384 <16=> 32768 00284 // </e4> 00285 // </h> 00286 // </h> 00287 // <h> Bulk Endpoint Settings 00288 // <o7.0..4> Bulk In Endpoint Number <1=> 1 <2=> 2 <3=> 3 00289 // <4=> 4 <5=> 5 <6=> 6 <7=> 7 00290 // <8=> 8 <9=> 9 <10=> 10 <11=> 11 00291 // <12=> 12 <13=> 13 <14=> 14 <15=> 15 00292 // <o8.0..4> Bulk Out Endpoint Number <1=> 1 <2=> 2 <3=> 3 00293 // <4=> 4 <5=> 5 <6=> 6 <7=> 7 00294 // <8=> 8 <9=> 9 <10=> 10 <11=> 11 00295 // <12=> 12 <13=> 13 <14=> 14 <15=> 15 00296 // <h> Endpoint Settings 00297 // <o9> Maximum Packet Size <1-1024> 00298 // <e10> High-speed 00299 // <i> If high-speed is enabled set endpoint settings for it 00300 // <o11> Maximum Packet Size <1-1024> 00301 // <o12> Maximum NAK Rate <0-255> 00302 // </e10> 00303 // </h> 00304 // </h> 00305 // <h> Communication Device Settings 00306 // <i> Device specific settings 00307 // <s0.126> Communication Class Interface String 00308 // <s1.126> Data Class Interface String 00309 // <o13> Maximum Communication Device Send Buffer Size 00310 // <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes <128=> 128 Bytes 00311 // <256=> 256 Bytes <512=> 512 Bytes <1024=> 1024 Bytes 00312 // <o14> Maximum Communication Device Receive Buffer Size 00313 // <i> Minimum size must be as big as maximum packet size for Bulk Out Endpoint 00314 // <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes <128=> 128 Bytes 00315 // <256=> 256 Bytes <512=> 512 Bytes <1024=> 1024 Bytes 00316 // </h> 00317 // </e> 00318 #ifndef CDC_ENDPOINT 00319 #define CDC_ENDPOINT 0 00320 #else 00321 #define CDC_ENDPOINT 1 00322 #endif 00323 #define USBD_CDC_ACM_ENABLE CDC_ENDPOINT 00324 #define USBD_CDC_ACM_EP_INTIN 4 00325 #define USBD_CDC_ACM_EP_INTIN_STACK 0 00326 #define USBD_CDC_ACM_WMAXPACKETSIZE 16 00327 #define USBD_CDC_ACM_BINTERVAL 32 00328 #define USBD_CDC_ACM_HS_ENABLE 1 00329 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE 64 00330 #define USBD_CDC_ACM_HS_BINTERVAL 2 00331 #define USBD_CDC_ACM_EP_BULKIN 6 00332 #define USBD_CDC_ACM_EP_BULKIN_STACK 0 00333 #define USBD_CDC_ACM_EP_BULKOUT 5 00334 #define USBD_CDC_ACM_EP_BULKOUT_STACK 0 00335 #define USBD_CDC_ACM_WMAXPACKETSIZE1 64 00336 #define USBD_CDC_ACM_HS_ENABLE1 1 00337 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE1 512 00338 #define USBD_CDC_ACM_HS_BINTERVAL1 1 00339 #define USBD_CDC_ACM_CIF_STRDESC L"mbed Serial Port" 00340 #define USBD_CDC_ACM_DIF_STRDESC L"mbed Serial Port" 00341 #define USBD_CDC_ACM_SENDBUF_SIZE USBD_CDC_ACM_HS_WMAXPACKETSIZE1 00342 #define USBD_CDC_ACM_RECEIVEBUF_SIZE USBD_CDC_ACM_HS_WMAXPACKETSIZE1 00343 #if (((USBD_CDC_ACM_HS_ENABLE1) && (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_HS_WMAXPACKETSIZE1)) || (USBD_CDC_ACM_SENDBUF_SIZE < USBD_CDC_ACM_WMAXPACKETSIZE1)) 00344 #error "Send Buffer size must be larger or equal to Bulk In maximum packet size!" 00345 #endif 00346 #if (((USBD_CDC_ACM_HS_ENABLE1) && (USBD_CDC_ACM_RECEIVEBUF_SIZE < USBD_CDC_ACM_HS_WMAXPACKETSIZE1)) || (USBD_CDC_ACM_RECEIVEBUF_SIZE < USBD_CDC_ACM_WMAXPACKETSIZE1)) 00347 #error "Receive Buffer size must be larger or equal to Bulk Out maximum packet size!" 00348 #endif 00349 00350 // <e0> Custom Class Device 00351 // <i> Enables USB Custom Class Requests 00352 // <i> Class IDs: 00353 // <i> 0x00 - Class Reserved ID 00354 // <i> 0x01 - Class Audio ID 00355 // <i> 0x02 - Class Communications ID 00356 // <i> 0x03 - Class Human Interface ID 00357 // <i> 0x04 - Class Monitor ID 00358 // <i> 0x05 - Class Physical Interface ID 00359 // <i> 0x06 - Class Power ID 00360 // <i> 0x07 - Class Printer ID 00361 // <i> 0x08 - Class Storage ID 00362 // <i> 0x09 - Class HUB ID 00363 // <i> 0xEF - Class Miscellaneous ID 00364 // <i> 0xFF - Class Vendor Specific ID 00365 // </e> 00366 #define USBD_CLS_ENABLE 0 00367 00368 // WebUSB support 00369 #define USBD_WEBUSB_ENABLE WEBUSB_INTERFACE 00370 #define USBD_WEBUSB_VENDOR_CODE 0x21 00371 #define USBD_WEBUSB_LANDING_URL "os.mbed.com/webusb/landing-page/?bid=" 00372 #define USBD_WEBUSB_ORIGIN_URL "os.mbed.com/" 00373 00374 // Microsoft OS Descriptors 2.0 (WinUSB) support 00375 #define USBD_WINUSB_ENABLE WINUSB_INTERFACE 00376 #define USBD_WINUSB_VENDOR_CODE 0x20 00377 // </e> 00378 // </e> 00379 00380 #ifndef BULK_ENDPOINT 00381 #define BULK_ENDPOINT 0 00382 #else 00383 #define BULK_ENDPOINT 1 00384 #endif 00385 #define USBD_BULK_ENABLE BULK_ENDPOINT //no endpts left 00386 #define USBD_BULK_EP_BULKIN 7 00387 #define USBD_BULK_EP_BULKOUT 8 00388 #define USBD_BULK_WMAXPACKETSIZE 64 00389 #define USBD_BULK_HS_ENABLE 1 00390 #define USBD_BULK_HS_WMAXPACKETSIZE 512 00391 #define USBD_BULK_STRDESC L"CMSIS-DAP v2" 00392 00393 00394 /* USB Device Calculations ---------------------------------------------------*/ 00395 00396 #define USBD_IF_NUM_MAX (USBD_BULK_ENABLE+USBD_WEBUSB_ENABLE+USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ACM_ENABLE*2)+USBD_CLS_ENABLE) 00397 #define USBD_MULTI_IF (USBD_CDC_ACM_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE|USBD_CLS_ENABLE|USBD_WEBUSB_ENABLE|USBD_BULK_ENABLE)) 00398 #define MAX(x, y) (((x) < (y)) ? (y) : (x)) 00399 #define USBD_EP_NUM_CALC0 MAX((USBD_HID_ENABLE *(USBD_HID_EP_INTIN )), (USBD_HID_ENABLE *(USBD_HID_EP_INTOUT!=0)*(USBD_HID_EP_INTOUT))) 00400 #define USBD_EP_NUM_CALC1 MAX((USBD_MSC_ENABLE *(USBD_MSC_EP_BULKIN )), (USBD_MSC_ENABLE *(USBD_MSC_EP_BULKOUT))) 00401 #define USBD_EP_NUM_CALC2 MAX((USBD_ADC_ENABLE *(USBD_ADC_EP_ISOOUT )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN))) 00402 #define USBD_EP_NUM_CALC3 MAX((USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_BULKIN)), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_BULKOUT))) 00403 #define USBD_EP_NUM_CALC4 MAX(USBD_EP_NUM_CALC0, USBD_EP_NUM_CALC1) 00404 #define USBD_EP_NUM_CALC5 MAX(USBD_EP_NUM_CALC2, USBD_EP_NUM_CALC3) 00405 #define USBD_EP_NUM_CALC6 MAX(USBD_EP_NUM_CALC4, USBD_EP_NUM_CALC5) 00406 #define USBD_EP_NUM_CALC7 MAX((USBD_BULK_ENABLE*(USBD_BULK_EP_BULKIN)), (USBD_BULK_ENABLE*(USBD_BULK_EP_BULKOUT))) 00407 #define USBD_EP_NUM MAX(USBD_EP_NUM_CALC6, USBD_EP_NUM_CALC7) 00408 00409 #if (USBD_EP_NUM > 6) 00410 #error "SAM3U only have 7 endpoints including EP0!" 00411 #endif 00412 00413 #if (USBD_HID_ENABLE) 00414 #if (USBD_MSC_ENABLE) 00415 #if ((((USBD_HID_EP_INTIN == USBD_MSC_EP_BULKIN) || \ 00416 (USBD_HID_EP_INTIN == USBD_MSC_EP_BULKOUT))) || \ 00417 ((USBD_HID_EP_INTOUT != 0) && \ 00418 (USBD_HID_EP_INTOUT == USBD_MSC_EP_BULKIN) || \ 00419 (USBD_HID_EP_INTOUT == USBD_MSC_EP_BULKOUT))) 00420 #error "HID and Mass Storage Device Interface can not use same Endpoints!" 00421 #endif 00422 #endif 00423 #if (USBD_ADC_ENABLE) 00424 #if ((USBD_HID_EP_INTIN == USBD_ADC_EP_ISOOUT) || \ 00425 ((USBD_HID_EP_INTOUT != 0) && \ 00426 (USBD_HID_EP_INTOUT == USBD_ADC_EP_ISOOUT))) 00427 #error "HID and Audio Device Interface can not use same Endpoints!" 00428 #endif 00429 #endif 00430 #if (USBD_CDC_ACM_ENABLE) 00431 #if (((USBD_HID_EP_INTIN == USBD_CDC_ACM_EP_INTIN) || \ 00432 (USBD_HID_EP_INTIN == USBD_CDC_ACM_EP_BULKIN) || \ 00433 (USBD_HID_EP_INTIN == USBD_CDC_ACM_EP_BULKOUT))|| \ 00434 ((USBD_HID_EP_INTOUT != 0) && \ 00435 ((USBD_HID_EP_INTOUT == USBD_CDC_ACM_EP_INTIN) || \ 00436 (USBD_HID_EP_INTOUT == USBD_CDC_ACM_EP_BULKIN) || \ 00437 (USBD_HID_EP_INTOUT == USBD_CDC_ACM_EP_BULKOUT)))) 00438 #error "HID and Communication Device Interface can not use same Endpoints!" 00439 #endif 00440 #endif 00441 #endif 00442 00443 #if (USBD_MSC_ENABLE) 00444 #if (USBD_ADC_ENABLE) 00445 #if ((USBD_MSC_EP_BULKIN == USBD_ADC_EP_ISOOUT) || \ 00446 (USBD_MSC_EP_BULKOUT == USBD_ADC_EP_ISOOUT)) 00447 #error "Mass Storage Device and Audio Device Interface can not use same Endpoints!" 00448 #endif 00449 #endif 00450 #if (USBD_CDC_ACM_ENABLE) 00451 #if ((USBD_MSC_EP_BULKIN == USBD_CDC_ACM_EP_INTIN) || \ 00452 (USBD_MSC_EP_BULKIN == USBD_CDC_ACM_EP_BULKIN) || \ 00453 (USBD_MSC_EP_BULKIN == USBD_CDC_ACM_EP_BULKOUT) || \ 00454 (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_INTIN) || \ 00455 (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_BULKIN) || \ 00456 (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_BULKOUT)) 00457 #error "Mass Storage Device and Communication Device Interface can not use same Endpoints!" 00458 #endif 00459 #endif 00460 #endif 00461 00462 #if (USBD_ADC_ENABLE) 00463 #if (USBD_CDC_ACM_ENABLE) 00464 #if ((USBD_ADC_EP_ISOOUT == USBD_CDC_ACM_EP_INTIN) || \ 00465 (USBD_ADC_EP_ISOOUT == USBD_CDC_ACM_EP_BULKIN) || \ 00466 (USBD_ADC_EP_ISOOUT == USBD_CDC_ACM_EP_BULKOUT)) 00467 #error "Audio Device and Communication Device Interface can not use same Endpoints!" 00468 #endif 00469 #endif 00470 #endif 00471 00472 #define USBD_ADC_CIF_NUM (0) 00473 #define USBD_ADC_SIF1_NUM (1) 00474 #define USBD_ADC_SIF2_NUM (2) 00475 00476 #define USBD_ADC_CIF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+0) 00477 #define USBD_ADC_SIF1_STR_NUM (3+USBD_STRDESC_SER_ENABLE+1) 00478 #define USBD_ADC_SIF2_STR_NUM (3+USBD_STRDESC_SER_ENABLE+2) 00479 #define USBD_CDC_ACM_CIF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+0) 00480 #define USBD_CDC_ACM_DIF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+1) 00481 #define USBD_HID_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2) 00482 #define USBD_WEBUSB_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE) 00483 #define USBD_MSC_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE) 00484 #define USBD_BULK_IF_STR_NUM (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE+USBD_WEBUSB_ENABLE+USBD_BULK_ENABLE) 00485 00486 #if (USBD_HID_ENABLE) 00487 #if (USBD_HID_HS_ENABLE) 00488 #define USBD_HID_MAX_PACKET ((USBD_HID_HS_WMAXPACKETSIZE > USBD_HID_WMAXPACKETSIZE) ? USBD_HID_HS_WMAXPACKETSIZE : USBD_HID_WMAXPACKETSIZE) 00489 #else 00490 #define USBD_HID_MAX_PACKET (USBD_HID_WMAXPACKETSIZE) 00491 #endif 00492 #else 00493 #define USBD_HID_MAX_PACKET (0) 00494 #endif 00495 #if (USBD_MSC_ENABLE) 00496 #if (USBD_MSC_HS_ENABLE) 00497 #define USBD_MSC_MAX_PACKET ((USBD_MSC_HS_WMAXPACKETSIZE > USBD_MSC_WMAXPACKETSIZE) ? USBD_MSC_HS_WMAXPACKETSIZE : USBD_MSC_WMAXPACKETSIZE) 00498 #else 00499 #define USBD_MSC_MAX_PACKET (USBD_MSC_WMAXPACKETSIZE) 00500 #endif 00501 #else 00502 #define USBD_MSC_MAX_PACKET (0) 00503 #endif 00504 #if (USBD_ADC_ENABLE) 00505 #if (USBD_ADC_HS_ENABLE) 00506 #define USBD_ADC_MAX_PACKET ((USBD_ADC_HS_WMAXPACKETSIZE > USBD_ADC_WMAXPACKETSIZE) ? USBD_ADC_HS_WMAXPACKETSIZE : USBD_ADC_WMAXPACKETSIZE) 00507 #else 00508 #define USBD_ADC_MAX_PACKET (USBD_ADC_WMAXPACKETSIZE) 00509 #endif 00510 #else 00511 #define USBD_ADC_MAX_PACKET (0) 00512 #endif 00513 #if (USBD_CDC_ACM_ENABLE) 00514 #if (USBD_CDC_ACM_HS_ENABLE) 00515 #define USBD_CDC_ACM_MAX_PACKET ((USBD_CDC_ACM_HS_WMAXPACKETSIZE > USBD_CDC_ACM_WMAXPACKETSIZE) ? USBD_CDC_ACM_HS_WMAXPACKETSIZE : USBD_CDC_ACM_WMAXPACKETSIZE) 00516 #else 00517 #define USBD_CDC_ACM_MAX_PACKET (USBD_CDC_ACM_WMAXPACKETSIZE) 00518 #endif 00519 #if (USBD_CDC_ACM_HS_ENABLE1) 00520 #define USBD_CDC_ACM_MAX_PACKET1 ((USBD_CDC_ACM_HS_WMAXPACKETSIZE1 > USBD_CDC_ACM_WMAXPACKETSIZE1) ? USBD_CDC_ACM_HS_WMAXPACKETSIZE1 : USBD_CDC_ACM_WMAXPACKETSIZE1) 00521 #else 00522 #define USBD_CDC_ACM_MAX_PACKET1 (USBD_CDC_ACM_WMAXPACKETSIZE1) 00523 #endif 00524 #else 00525 #define USBD_CDC_ACM_MAX_PACKET (0) 00526 #define USBD_CDC_ACM_MAX_PACKET1 (0) 00527 #endif 00528 #if (USBD_BULK_ENABLE) 00529 #if (USBD_BULK_HS_ENABLE) 00530 #define USBD_BULK_MAX_PACKET ((USBD_BULK_HS_WMAXPACKETSIZE > USBD_BULK_WMAXPACKETSIZE) ? USBD_BULK_HS_WMAXPACKETSIZE : USBD_BULK_WMAXPACKETSIZE) 00531 #else 00532 #define USBD_BULK_MAX_PACKET (USBD_BULK_WMAXPACKETSIZE) 00533 #endif 00534 #else 00535 #define USBD_BULK_MAX_PACKET (0) 00536 #endif 00537 #define USBD_MAX_PACKET_CALC0 ((USBD_HID_MAX_PACKET > USBD_HID_MAX_PACKET ) ? (USBD_HID_MAX_PACKET ) : (USBD_HID_MAX_PACKET )) 00538 #define USBD_MAX_PACKET_CALC1 ((USBD_ADC_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET ) ? (USBD_ADC_MAX_PACKET ) : (USBD_CDC_ACM_MAX_PACKET )) 00539 #define USBD_MAX_PACKET_CALC2 ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1 ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1 )) 00540 #define USBD_MAX_PACKET_CALC3 ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 )) 00541 #define USBD_MAX_PACKET ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2 ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2 )) 00542 00543 00544 /*------------------------------------------------------------------------------ 00545 * USB Config Functions 00546 *----------------------------------------------------------------------------*/ 00547 00548 #ifndef __USB_CONFIG___ 00549 #define __USB_CONFIG__ 00550 00551 #ifndef __NO_USB_LIB_C 00552 #include "usb_lib.c" 00553 #endif 00554 00555 #endif /* __USB_CONFIG__ */
Generated on Tue Jul 12 2022 15:37:26 by
