Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers usb_config.c Source File

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 // <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      0x1000 //was 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_EP_INTIN_STACK     0
00157 #define USBD_HID_WMAXPACKETSIZE     64
00158 #define USBD_HID_BINTERVAL          1
00159 #define USBD_HID_HS_ENABLE          0
00160 #define USBD_HID_HS_WMAXPACKETSIZE  64
00161 #define USBD_HID_HS_BINTERVAL       6
00162 #define USBD_HID_STRDESC            L"CMSIS-DAP v1"
00163 #define USBD_WEBUSB_STRDESC         L"WebUSB: CMSIS-DAP"
00164 #define USBD_HID_INREPORT_NUM       1
00165 #define USBD_HID_OUTREPORT_NUM      1
00166 #define USBD_HID_INREPORT_MAX_SZ    64
00167 #define USBD_HID_OUTREPORT_MAX_SZ   64
00168 #define USBD_HID_FEATREPORT_MAX_SZ  1
00169 
00170 //     <e0.0> Mass Storage Device (MSC)
00171 //       <i> Enable class support for Mass Storage Device (MSC)
00172 //       <h> Bulk Endpoint Settings
00173 //         <o1.0..4> Bulk In Endpoint Number                  <1=>   1 <2=>   2 <3=>   3
00174 //                                            <4=>   4        <5=>   5 <6=>   6 <7=>   7
00175 //                                            <8=>   8        <9=>   9 <10=> 10 <11=> 11
00176 //                                            <12=>  12       <13=> 13 <14=> 14 <15=> 15
00177 //         <o2.0..4> Bulk Out Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
00178 //                                            <4=>   4        <5=>   5 <6=>   6 <7=>   7
00179 //                                            <8=>   8        <9=>   9 <10=> 10 <11=> 11
00180 //                                            <12=>  12       <13=> 13 <14=> 14 <15=> 15
00181 //         <h> Endpoint Settings
00182 //           <o3> Maximum Packet Size <1-1024>
00183 //           <e4> High-speed
00184 //             <i> If high-speed is enabled set endpoint settings for it
00185 //             <o5> Maximum Packet Size <1-1024>
00186 //             <o6> Maximum NAK Rate <0-255>
00187 //           </e>
00188 //         </h>
00189 //       </h>
00190 //       <h> Mass Storage Device Settings
00191 //         <i> Device specific settings
00192 //         <s0.126> MSC Interface String
00193 //         <h> Inquiry Data
00194 //           <s1.8>  Vendor Identification
00195 //           <s2.16> Product Identification
00196 //           <s3.4>  Product Revision Level
00197 //         </h>
00198 //       </h>
00199 //     </e>
00200 #ifndef MSC_ENDPOINT
00201 #define MSC_ENDPOINT 0
00202 #else
00203 #define MSC_ENDPOINT 1
00204 #endif
00205 #define USBD_MSC_ENABLE             MSC_ENDPOINT
00206 #define USBD_MSC_EP_BULKIN          2
00207 #define USBD_MSC_EP_BULKOUT         2
00208 #define USBD_MSC_EP_BULKIN_STACK    0
00209 #define USBD_MSC_WMAXPACKETSIZE     64
00210 #define USBD_MSC_HS_ENABLE          0
00211 #define USBD_MSC_HS_WMAXPACKETSIZE  512
00212 #define USBD_MSC_HS_BINTERVAL       0
00213 #define USBD_MSC_STRDESC            L"USB_MSC"
00214 // Make sure changes to USBD_MSC_INQUIRY_DATA are coordinated with mbed-ls
00215 // since this is used to detect DAPLink drives
00216 #define USBD_MSC_INQUIRY_DATA       "MBED    "         \
00217                                     "VFS             " \
00218                                     "0.1"
00219 
00220 //     <e0.0> Audio Device (ADC)
00221 //       <i> Enable class support for Audio Device (ADC)
00222 //       <h> Isochronous Endpoint Settings
00223 //         <o1.0..4> Isochronous Out Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
00224 //                                                   <4=>   4        <5=>   5 <6=>   6 <7=>   7
00225 //                                                   <8=>   8        <9=>   9 <10=> 10 <11=> 11
00226 //                                                   <12=>  12       <13=> 13 <14=> 14 <15=> 15
00227 //         <h> Endpoint Settings
00228 //           <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
00229 //           <o3.0..10> Endpoint polling Interval (in ms) <1=>      1 <2=>      2 <3=>      4 <4=>      8
00230 //                                                        <5=>     16 <6=>     32 <7=>     64 <8=>    128
00231 //                                                        <9=>    256 <10=>   512 <11=>  1024 <12=>  2048
00232 //                                                        <13=>  4096 <14=>  8192 <15=> 16384 <16=> 32768
00233 //           <e4> High-speed
00234 //             <i> If high-speed is enabled set endpoint settings for it
00235 //             <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
00236 //             <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
00237 //           </e>
00238 //         </h>
00239 //       </h>
00240 //       <h> Audio Device Settings
00241 //         <i> Device specific settings
00242 //         <s0.126> Audio Control Interface String
00243 //         <s1.126> Audio Streaming (Zero Bandwidth) Interface String
00244 //         <s2.126> Audio Streaming (Operational) Interface String
00245 //         <o6.0..7> Audio Subframe Size (in bytes) <0-255>
00246 //         <o7.0..7> Sample Resolution (in bits) <0-255>
00247 //         <o8.0..23> Sample Frequency (in Hz) <0-16777215>
00248 //         <o9> Packet Size (in bytes) <1-256>
00249 //         <o10> Packet Count <1-16>
00250 //       </h>
00251 //     </e>
00252 #define USBD_ADC_ENABLE             0
00253 #define USBD_ADC_EP_ISOOUT          3
00254 #define USBD_ADC_WMAXPACKETSIZE     64
00255 #define USBD_ADC_BINTERVAL          1
00256 #define USBD_ADC_HS_ENABLE          0
00257 #define USBD_ADC_HS_WMAXPACKETSIZE  64
00258 #define USBD_ADC_CIF_STRDESC        L"USB_ADC"
00259 #define USBD_ADC_SIF1_STRDESC       L"USB_ADC1"
00260 #define USBD_ADC_SIF2_STRDESC       L"USB_ADC2"
00261 #define USBD_ADC_BSUBFRAMESIZE      2
00262 #define USBD_ADC_BBITRESOLUTION     16
00263 #define USBD_ADC_TSAMFREQ           32000
00264 #define USBD_ADC_CFG_P_S            32
00265 #define USBD_ADC_CFG_P_C            1
00266 
00267 //     <e0> Communication Device (CDC) - Abstract Control Model (ACM)
00268 //       <i> Enable class support for Communication Device (CDC) - Abstract Control Model (ACM)
00269 //       <h> Interrupt Endpoint Settings
00270 //         <o1.0..4> Interrupt In Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
00271 //                                                <4=>   4        <5=>   5 <6=>   6 <7=>   7
00272 //                                                <8=>   8        <9=>   9 <10=> 10 <11=> 11
00273 //                                                <12=>  12       <13=> 13 <14=> 14 <15=> 15
00274 //         <h> Endpoint Settings
00275 //           <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
00276 //           <o3.0..10> Endpoint polling Interval (in ms) <0-255>
00277 //           <e4> High-speed
00278 //             <i> If high-speed is enabled set endpoint settings for it
00279 //             <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
00280 //             <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
00281 //             <o6.0..10> Endpoint polling Interval (in ms) <1=>      1 <2=>      2 <3=>      4 <4=>      8
00282 //                                                          <5=>     16 <6=>     32 <7=>     64 <8=>    128
00283 //                                                          <9=>    256 <10=>   512 <11=>  1024 <12=>  2048
00284 //                                                          <13=>  4096 <14=>  8192 <15=> 16384 <16=> 32768
00285 //           </e4>
00286 //         </h>
00287 //       </h>
00288 //       <h> Bulk Endpoint Settings
00289 //         <o7.0..4> Bulk In Endpoint Number                  <1=>   1 <2=>   2 <3=>   3
00290 //                                            <4=>   4        <5=>   5 <6=>   6 <7=>   7
00291 //                                            <8=>   8        <9=>   9 <10=> 10 <11=> 11
00292 //                                            <12=>  12       <13=> 13 <14=> 14 <15=> 15
00293 //         <o8.0..4> Bulk Out Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
00294 //                                            <4=>   4        <5=>   5 <6=>   6 <7=>   7
00295 //                                            <8=>   8        <9=>   9 <10=> 10 <11=> 11
00296 //                                            <12=>  12       <13=> 13 <14=> 14 <15=> 15
00297 //         <h> Endpoint Settings
00298 //           <o9> Maximum Packet Size <1-1024>
00299 //           <e10> High-speed
00300 //             <i> If high-speed is enabled set endpoint settings for it
00301 //             <o11> Maximum Packet Size <1-1024>
00302 //             <o12> Maximum NAK Rate <0-255>
00303 //           </e10>
00304 //         </h>
00305 //       </h>
00306 //       <h> Communication Device Settings
00307 //         <i> Device specific settings
00308 //         <s0.126> Communication Class Interface String
00309 //         <s1.126> Data Class Interface String
00310 //         <o13> Maximum Communication Device Send Buffer Size
00311 //            <8=>     8 Bytes <16=>   16 Bytes <32=>     32 Bytes <64=>  64 Bytes <128=> 128 Bytes
00312 //            <256=> 256 Bytes <512=> 512 Bytes <1024=> 1024 Bytes
00313 //         <o14> Maximum Communication Device Receive Buffer Size
00314 //            <i> Minimum size must be as big as maximum packet size for Bulk Out Endpoint
00315 //            <8=>     8 Bytes <16=>   16 Bytes <32=>     32 Bytes <64=>  64 Bytes <128=> 128 Bytes
00316 //            <256=> 256 Bytes <512=> 512 Bytes <1024=> 1024 Bytes
00317 //       </h>
00318 //     </e>
00319 
00320 #ifndef CDC_ENDPOINT
00321 #define CDC_ENDPOINT 0
00322 #else
00323 #define CDC_ENDPOINT 1
00324 #endif
00325 #define USBD_CDC_ACM_ENABLE             CDC_ENDPOINT
00326 #define USBD_CDC_ACM_EP_INTIN           3
00327 #define USBD_CDC_ACM_EP_INTIN_STACK     0
00328 #define USBD_CDC_ACM_WMAXPACKETSIZE     16
00329 #define USBD_CDC_ACM_BINTERVAL          32
00330 #define USBD_CDC_ACM_HS_ENABLE          0
00331 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE  16
00332 #define USBD_CDC_ACM_HS_BINTERVAL       2
00333 #define USBD_CDC_ACM_EP_BULKIN          4
00334 #define USBD_CDC_ACM_EP_BULKOUT         4
00335 #define USBD_CDC_ACM_EP_BULKIN_STACK    0
00336 #define USBD_CDC_ACM_WMAXPACKETSIZE1    64
00337 #define USBD_CDC_ACM_HS_ENABLE1         0
00338 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE1 64
00339 #define USBD_CDC_ACM_HS_BINTERVAL1      0
00340 #define USBD_CDC_ACM_CIF_STRDESC        L"mbed Serial Port"
00341 #define USBD_CDC_ACM_DIF_STRDESC        L"mbed Serial Port"
00342 #define USBD_CDC_ACM_SENDBUF_SIZE       64
00343 #define USBD_CDC_ACM_RECEIVEBUF_SIZE    64
00344 #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))
00345 #error "Send Buffer size must be larger or equal to Bulk In maximum packet size!"
00346 #endif
00347 #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))
00348 #error "Receive Buffer size must be larger or equal to Bulk Out maximum packet size!"
00349 #endif
00350 
00351 //     <e0> Custom Class Device
00352 //       <i> Enables USB Custom Class Requests
00353 //       <i> Class IDs:
00354 //       <i> 0x00 - Class Reserved ID
00355 //       <i> 0x01 - Class Audio ID
00356 //       <i> 0x02 - Class Communications ID
00357 //       <i> 0x03 - Class Human Interface ID
00358 //       <i> 0x04 - Class Monitor ID
00359 //       <i> 0x05 - Class Physical Interface ID
00360 //       <i> 0x06 - Class Power ID
00361 //       <i> 0x07 - Class Printer ID
00362 //       <i> 0x08 - Class Storage ID
00363 //       <i> 0x09 - Class HUB ID
00364 //       <i> 0xEF - Class Miscellaneous ID
00365 //       <i> 0xFF - Class Vendor Specific ID
00366 //     </e>
00367 #define USBD_CLS_ENABLE             0
00368 
00369 //     WebUSB support
00370 #define USBD_WEBUSB_ENABLE          WEBUSB_INTERFACE
00371 #define USBD_WEBUSB_VENDOR_CODE     0x21
00372 #define USBD_WEBUSB_LANDING_URL     "os.mbed.com/webusb/landing-page/?bid="
00373 #define USBD_WEBUSB_ORIGIN_URL      "os.mbed.com/"
00374 
00375 //     Microsoft OS Descriptors 2.0 (WinUSB) support
00376 #define USBD_WINUSB_ENABLE          WINUSB_INTERFACE
00377 #define USBD_WINUSB_VENDOR_CODE     0x20
00378 //   </e>
00379 // </e>
00380 
00381 #ifndef BULK_ENDPOINT
00382 #define BULK_ENDPOINT 0
00383 #else
00384 #define BULK_ENDPOINT 1
00385 #endif
00386 #define USBD_BULK_ENABLE             BULK_ENDPOINT
00387 #define USBD_BULK_EP_BULKIN          5
00388 #define USBD_BULK_EP_BULKOUT         5
00389 #define USBD_BULK_WMAXPACKETSIZE     64
00390 #define USBD_BULK_HS_ENABLE          0
00391 #define USBD_BULK_HS_WMAXPACKETSIZE  512
00392 #define USBD_BULK_STRDESC            L"CMSIS-DAP v2"
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_HID_ENABLE)
00410 #if    (USBD_MSC_ENABLE)
00411 #if ((((USBD_HID_EP_INTIN   == USBD_MSC_EP_BULKIN)      || \
00412        (USBD_HID_EP_INTIN   == USBD_MSC_EP_BULKOUT)))   || \
00413       ((USBD_HID_EP_INTOUT  != 0)                       && \
00414        (USBD_HID_EP_INTOUT  == USBD_MSC_EP_BULKIN)      || \
00415        (USBD_HID_EP_INTOUT  == USBD_MSC_EP_BULKOUT)))
00416 #error "HID and Mass Storage Device Interface can not use same Endpoints!"
00417 #endif
00418 #endif
00419 #if    (USBD_ADC_ENABLE)
00420 #if   ((USBD_HID_EP_INTIN   == USBD_ADC_EP_ISOOUT)  || \
00421       ((USBD_HID_EP_INTOUT  != 0)                   && \
00422        (USBD_HID_EP_INTOUT  == USBD_ADC_EP_ISOOUT)))
00423 #error "HID and Audio Device Interface can not use same Endpoints!"
00424 #endif
00425 #endif
00426 #if    (USBD_CDC_ACM_ENABLE)
00427 #if  (((USBD_HID_EP_INTIN   == USBD_CDC_ACM_EP_INTIN)   || \
00428        (USBD_HID_EP_INTIN   == USBD_CDC_ACM_EP_BULKIN)  || \
00429        (USBD_HID_EP_INTIN   == USBD_CDC_ACM_EP_BULKOUT))|| \
00430       ((USBD_HID_EP_INTOUT  != 0)                       && \
00431       ((USBD_HID_EP_INTOUT  == USBD_CDC_ACM_EP_INTIN)   || \
00432        (USBD_HID_EP_INTOUT  == USBD_CDC_ACM_EP_BULKIN)  || \
00433        (USBD_HID_EP_INTOUT  == USBD_CDC_ACM_EP_BULKOUT))))
00434 #error "HID and Communication Device Interface can not use same Endpoints!"
00435 #endif
00436 #endif
00437 #endif
00438 
00439 #if    (USBD_MSC_ENABLE)
00440 #if    (USBD_ADC_ENABLE)
00441 #if   ((USBD_MSC_EP_BULKIN  == USBD_ADC_EP_ISOOUT)  || \
00442        (USBD_MSC_EP_BULKOUT == USBD_ADC_EP_ISOOUT))
00443 #error "Mass Storage Device and Audio Device Interface can not use same Endpoints!"
00444 #endif
00445 #endif
00446 #if    (USBD_CDC_ACM_ENABLE)
00447 #if   ((USBD_MSC_EP_BULKIN  == USBD_CDC_ACM_EP_INTIN)   || \
00448        (USBD_MSC_EP_BULKIN  == USBD_CDC_ACM_EP_BULKIN)  || \
00449        (USBD_MSC_EP_BULKIN  == USBD_CDC_ACM_EP_BULKOUT) || \
00450        (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_INTIN)   || \
00451        (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_BULKIN)  || \
00452        (USBD_MSC_EP_BULKOUT == USBD_CDC_ACM_EP_BULKOUT))
00453 #error "Mass Storage Device and Communication Device Interface can not use same Endpoints!"
00454 #endif
00455 #endif
00456 #endif
00457 
00458 #if    (USBD_ADC_ENABLE)
00459 #if    (USBD_CDC_ACM_ENABLE)
00460 #if   ((USBD_ADC_EP_ISOOUT  == USBD_CDC_ACM_EP_INTIN)   || \
00461        (USBD_ADC_EP_ISOOUT  == USBD_CDC_ACM_EP_BULKIN)  || \
00462        (USBD_ADC_EP_ISOOUT  == USBD_CDC_ACM_EP_BULKOUT))
00463 #error "Audio Device and Communication Device Interface can not use same Endpoints!"
00464 #endif
00465 #endif
00466 #endif
00467 
00468 #define USBD_ADC_CIF_NUM           (0)
00469 #define USBD_ADC_SIF1_NUM          (1)
00470 #define USBD_ADC_SIF2_NUM          (2)
00471 
00472 #define USBD_ADC_CIF_STR_NUM       (3+USBD_STRDESC_SER_ENABLE+0)
00473 #define USBD_ADC_SIF1_STR_NUM      (3+USBD_STRDESC_SER_ENABLE+1)
00474 #define USBD_ADC_SIF2_STR_NUM      (3+USBD_STRDESC_SER_ENABLE+2)
00475 #define USBD_CDC_ACM_CIF_STR_NUM   (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+0)
00476 #define USBD_CDC_ACM_DIF_STR_NUM   (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+1)
00477 #define USBD_HID_IF_STR_NUM        (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2)
00478 #define USBD_WEBUSB_IF_STR_NUM     (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE)
00479 #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)
00480 #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)
00481 
00482 #if    (USBD_HID_ENABLE)
00483 #if    (USBD_HID_HS_ENABLE)
00484 #define USBD_HID_MAX_PACKET       ((USBD_HID_HS_WMAXPACKETSIZE > USBD_HID_WMAXPACKETSIZE) ? USBD_HID_HS_WMAXPACKETSIZE : USBD_HID_WMAXPACKETSIZE)
00485 #else
00486 #define USBD_HID_MAX_PACKET        (USBD_HID_WMAXPACKETSIZE)
00487 #endif
00488 #else
00489 #define USBD_HID_MAX_PACKET        (0)
00490 #endif
00491 #if    (USBD_MSC_ENABLE)
00492 #if    (USBD_MSC_HS_ENABLE)
00493 #define USBD_MSC_MAX_PACKET       ((USBD_MSC_HS_WMAXPACKETSIZE > USBD_MSC_WMAXPACKETSIZE) ? USBD_MSC_HS_WMAXPACKETSIZE : USBD_MSC_WMAXPACKETSIZE)
00494 #else
00495 #define USBD_MSC_MAX_PACKET        (USBD_MSC_WMAXPACKETSIZE)
00496 #endif
00497 #else
00498 #define USBD_MSC_MAX_PACKET        (0)
00499 #endif
00500 #if    (USBD_ADC_ENABLE)
00501 #if    (USBD_ADC_HS_ENABLE)
00502 #define USBD_ADC_MAX_PACKET       ((USBD_ADC_HS_WMAXPACKETSIZE > USBD_ADC_WMAXPACKETSIZE) ? USBD_ADC_HS_WMAXPACKETSIZE : USBD_ADC_WMAXPACKETSIZE)
00503 #else
00504 #define USBD_ADC_MAX_PACKET        (USBD_ADC_WMAXPACKETSIZE)
00505 #endif
00506 #else
00507 #define USBD_ADC_MAX_PACKET        (0)
00508 #endif
00509 #if    (USBD_CDC_ACM_ENABLE)
00510 #if    (USBD_CDC_ACM_HS_ENABLE)
00511 #define USBD_CDC_ACM_MAX_PACKET   ((USBD_CDC_ACM_HS_WMAXPACKETSIZE > USBD_CDC_ACM_WMAXPACKETSIZE) ? USBD_CDC_ACM_HS_WMAXPACKETSIZE : USBD_CDC_ACM_WMAXPACKETSIZE)
00512 #else
00513 #define USBD_CDC_ACM_MAX_PACKET    (USBD_CDC_ACM_WMAXPACKETSIZE)
00514 #endif
00515 #if    (USBD_CDC_ACM_HS_ENABLE1)
00516 #define USBD_CDC_ACM_MAX_PACKET1  ((USBD_CDC_ACM_HS_WMAXPACKETSIZE1 > USBD_CDC_ACM_WMAXPACKETSIZE1) ? USBD_CDC_ACM_HS_WMAXPACKETSIZE1 : USBD_CDC_ACM_WMAXPACKETSIZE1)
00517 #else
00518 #define USBD_CDC_ACM_MAX_PACKET1   (USBD_CDC_ACM_WMAXPACKETSIZE1)
00519 #endif
00520 #else
00521 #define USBD_CDC_ACM_MAX_PACKET    (0)
00522 #define USBD_CDC_ACM_MAX_PACKET1   (0)
00523 #endif
00524 #if    (USBD_BULK_ENABLE)
00525 #if    (USBD_BULK_HS_ENABLE)
00526 #define USBD_BULK_MAX_PACKET       ((USBD_BULK_HS_WMAXPACKETSIZE > USBD_BULK_WMAXPACKETSIZE) ? USBD_BULK_HS_WMAXPACKETSIZE : USBD_BULK_WMAXPACKETSIZE)
00527 #else
00528 #define USBD_BULK_MAX_PACKET        (USBD_BULK_WMAXPACKETSIZE)
00529 #endif
00530 #else
00531 #define USBD_BULK_MAX_PACKET        (0)
00532 #endif
00533 #define USBD_MAX_PACKET_CALC0     ((USBD_HID_MAX_PACKET   > USBD_HID_MAX_PACKET      ) ? (USBD_HID_MAX_PACKET  ) : (USBD_HID_MAX_PACKET      ))
00534 #define USBD_MAX_PACKET_CALC1     ((USBD_ADC_MAX_PACKET   > USBD_CDC_ACM_MAX_PACKET  ) ? (USBD_ADC_MAX_PACKET  ) : (USBD_CDC_ACM_MAX_PACKET  ))
00535 #define USBD_MAX_PACKET_CALC2     ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1    ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1    ))
00536 #define USBD_MAX_PACKET_CALC3     ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 ))
00537 #define USBD_MAX_PACKET           ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2    ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2    ))
00538 
00539 
00540 
00541 /*------------------------------------------------------------------------------
00542  *      USB Config Functions
00543  *----------------------------------------------------------------------------*/
00544 
00545 #ifndef  __USB_CONFIG___
00546 #define  __USB_CONFIG__
00547 
00548 #ifndef  __NO_USB_LIB_C
00549 #include "usb_lib.c"
00550 #endif
00551 
00552 #endif  /* __USB_CONFIG__ */