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