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