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.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 #if (defined(WEBUSB_INTERFACE) || defined(WINUSB_INTERFACE) || defined(BULK_ENDPOINT))
00031 #define USBD_BOS_ENABLE             1
00032 #else
00033 #define USBD_BOS_ENABLE             0
00034 #endif
00035 //   <o0.0> High-speed
00036 //     <i> Enable high-speed functionality (if device supports it)
00037 #define USBD_HS_ENABLE              0
00038 
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            8
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 #ifndef BULK_ENDPOINT               //check if bulk endpoint is not enabled
00154 #define USBD_HID_EP_INTIN           1
00155 #define USBD_HID_EP_INTOUT          1
00156 #else                               //if bulk endpoint is enabled remove interrupt endpoints from the hid
00157 #define USBD_HID_EP_INTIN           0
00158 #define USBD_HID_EP_INTOUT          0
00159 #endif
00160 #define USBD_HID_ENABLE             HID_ENDPOINT
00161 #define USBD_HID_EP_INTIN_STACK     0
00162 #define USBD_HID_WMAXPACKETSIZE     64
00163 #define USBD_HID_BINTERVAL          1
00164 #define USBD_HID_HS_ENABLE          0
00165 #define USBD_HID_HS_WMAXPACKETSIZE  64
00166 #define USBD_HID_HS_BINTERVAL       6
00167 #define USBD_HID_STRDESC            L"CMSIS-DAP v1"
00168 #define USBD_WEBUSB_STRDESC         L"WebUSB: CMSIS-DAP"
00169 #define USBD_HID_INREPORT_NUM       1
00170 #define USBD_HID_OUTREPORT_NUM      1
00171 #define USBD_HID_INREPORT_MAX_SZ    64
00172 #define USBD_HID_OUTREPORT_MAX_SZ   64
00173 #define USBD_HID_FEATREPORT_MAX_SZ  1
00174 
00175 //     <e0.0> Mass Storage Device (MSC)
00176 //       <i> Enable class support for Mass Storage Device (MSC)
00177 //       <h> Bulk Endpoint Settings
00178 //         <o1.0..4> Bulk In 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 //         <o2.0..4> Bulk Out 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 //         <h> Endpoint Settings
00187 //           <o3> Maximum Packet Size <1-1024>
00188 //           <e4> High-speed
00189 //             <i> If high-speed is enabled set endpoint settings for it
00190 //             <o5> Maximum Packet Size <1-1024>
00191 //             <o6> Maximum NAK Rate <0-255>
00192 //           </e>
00193 //         </h>
00194 //       </h>
00195 //       <h> Mass Storage Device Settings
00196 //         <i> Device specific settings
00197 //         <s0.126> MSC Interface String
00198 //         <h> Inquiry Data
00199 //           <s1.8>  Vendor Identification
00200 //           <s2.16> Product Identification
00201 //           <s3.4>  Product Revision Level
00202 //         </h>
00203 //       </h>
00204 //     </e>
00205 #ifndef MSC_ENDPOINT
00206 #define MSC_ENDPOINT 0
00207 #else
00208 #define MSC_ENDPOINT 1
00209 #endif
00210 #define USBD_MSC_ENABLE             MSC_ENDPOINT
00211 #define USBD_MSC_EP_BULKIN          2
00212 #define USBD_MSC_EP_BULKOUT         2
00213 #define USBD_MSC_EP_BULKIN_STACK    0
00214 #define USBD_MSC_WMAXPACKETSIZE     64
00215 #define USBD_MSC_HS_ENABLE          0
00216 #define USBD_MSC_HS_WMAXPACKETSIZE  512
00217 #define USBD_MSC_HS_BINTERVAL       0
00218 #define USBD_MSC_STRDESC            L"USB_MSC"
00219 // Make sure changes to USBD_MSC_INQUIRY_DATA are coordinated with mbed-ls
00220 // since this is used to detect DAPLink drives
00221 #define USBD_MSC_INQUIRY_DATA       "MBED    "         \
00222                                     "VFS             " \
00223                                     "0.1"
00224 
00225 //     <e0.0> Audio Device (ADC)
00226 //       <i> Enable class support for Audio Device (ADC)
00227 //       <h> Isochronous Endpoint Settings
00228 //         <o1.0..4> Isochronous Out Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
00229 //                                                   <4=>   4        <5=>   5 <6=>   6 <7=>   7
00230 //                                                   <8=>   8        <9=>   9 <10=> 10 <11=> 11
00231 //                                                   <12=>  12       <13=> 13 <14=> 14 <15=> 15
00232 //         <h> Endpoint Settings
00233 //           <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
00234 //           <o3.0..10> Endpoint polling Interval (in ms) <1=>      1 <2=>      2 <3=>      4 <4=>      8
00235 //                                                        <5=>     16 <6=>     32 <7=>     64 <8=>    128
00236 //                                                        <9=>    256 <10=>   512 <11=>  1024 <12=>  2048
00237 //                                                        <13=>  4096 <14=>  8192 <15=> 16384 <16=> 32768
00238 //           <e4> High-speed
00239 //             <i> If high-speed is enabled set endpoint settings for it
00240 //             <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
00241 //             <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
00242 //           </e>
00243 //         </h>
00244 //       </h>
00245 //       <h> Audio Device Settings
00246 //         <i> Device specific settings
00247 //         <s0.126> Audio Control Interface String
00248 //         <s1.126> Audio Streaming (Zero Bandwidth) Interface String
00249 //         <s2.126> Audio Streaming (Operational) Interface String
00250 //         <o6.0..7> Audio Subframe Size (in bytes) <0-255>
00251 //         <o7.0..7> Sample Resolution (in bits) <0-255>
00252 //         <o8.0..23> Sample Frequency (in Hz) <0-16777215>
00253 //         <o9> Packet Size (in bytes) <1-256>
00254 //         <o10> Packet Count <1-16>
00255 //       </h>
00256 //     </e>
00257 #define USBD_ADC_ENABLE             0
00258 #define USBD_ADC_EP_ISOOUT          3
00259 #define USBD_ADC_WMAXPACKETSIZE     64
00260 #define USBD_ADC_BINTERVAL          1
00261 #define USBD_ADC_HS_ENABLE          0
00262 #define USBD_ADC_HS_WMAXPACKETSIZE  64
00263 #define USBD_ADC_CIF_STRDESC        L"USB_ADC"
00264 #define USBD_ADC_SIF1_STRDESC       L"USB_ADC1"
00265 #define USBD_ADC_SIF2_STRDESC       L"USB_ADC2"
00266 #define USBD_ADC_BSUBFRAMESIZE      2
00267 #define USBD_ADC_BBITRESOLUTION     16
00268 #define USBD_ADC_TSAMFREQ           32000
00269 #define USBD_ADC_CFG_P_S            32
00270 #define USBD_ADC_CFG_P_C            1
00271 
00272 //     <e0> Communication Device (CDC) - Abstract Control Model (ACM)
00273 //       <i> Enable class support for Communication Device (CDC) - Abstract Control Model (ACM)
00274 //       <h> Interrupt Endpoint Settings
00275 //         <o1.0..4> Interrupt In Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
00276 //                                                <4=>   4        <5=>   5 <6=>   6 <7=>   7
00277 //                                                <8=>   8        <9=>   9 <10=> 10 <11=> 11
00278 //                                                <12=>  12       <13=> 13 <14=> 14 <15=> 15
00279 //         <h> Endpoint Settings
00280 //           <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
00281 //           <o3.0..10> Endpoint polling Interval (in ms) <0-255>
00282 //           <e4> High-speed
00283 //             <i> If high-speed is enabled set endpoint settings for it
00284 //             <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
00285 //             <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
00286 //             <o6.0..10> Endpoint polling Interval (in ms) <1=>      1 <2=>      2 <3=>      4 <4=>      8
00287 //                                                          <5=>     16 <6=>     32 <7=>     64 <8=>    128
00288 //                                                          <9=>    256 <10=>   512 <11=>  1024 <12=>  2048
00289 //                                                          <13=>  4096 <14=>  8192 <15=> 16384 <16=> 32768
00290 //           </e4>
00291 //         </h>
00292 //       </h>
00293 //       <h> Bulk Endpoint Settings
00294 //         <o7.0..4> Bulk In 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 //         <o8.0..4> Bulk Out 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 //         <h> Endpoint Settings
00303 //           <o9> Maximum Packet Size <1-1024>
00304 //           <e10> High-speed
00305 //             <i> If high-speed is enabled set endpoint settings for it
00306 //             <o11> Maximum Packet Size <1-1024>
00307 //             <o12> Maximum NAK Rate <0-255>
00308 //           </e10>
00309 //         </h>
00310 //       </h>
00311 //       <h> Communication Device Settings
00312 //         <i> Device specific settings
00313 //         <s0.126> Communication Class Interface String
00314 //         <s1.126> Data Class Interface String
00315 //         <o13> Maximum Communication Device Send Buffer Size
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 //         <o14> Maximum Communication Device Receive Buffer Size
00319 //            <i> Minimum size must be as big as maximum packet size for Bulk Out Endpoint
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 //       </h>
00323 //     </e>
00324 
00325 #ifndef CDC_ENDPOINT
00326 #define CDC_ENDPOINT 0
00327 #else
00328 #define CDC_ENDPOINT 1
00329 #endif
00330 #define USBD_CDC_ACM_ENABLE             CDC_ENDPOINT
00331 #define USBD_CDC_ACM_EP_INTIN           3
00332 #define USBD_CDC_ACM_EP_INTIN_STACK     0
00333 #define USBD_CDC_ACM_WMAXPACKETSIZE     16
00334 #define USBD_CDC_ACM_BINTERVAL          32
00335 #define USBD_CDC_ACM_HS_ENABLE          0
00336 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE  16
00337 #define USBD_CDC_ACM_HS_BINTERVAL       2
00338 #define USBD_CDC_ACM_EP_BULKIN          4
00339 #define USBD_CDC_ACM_EP_BULKOUT         4
00340 #define USBD_CDC_ACM_EP_BULKIN_STACK    0
00341 #define USBD_CDC_ACM_WMAXPACKETSIZE1    64
00342 #define USBD_CDC_ACM_HS_ENABLE1         0
00343 #define USBD_CDC_ACM_HS_WMAXPACKETSIZE1 64
00344 #define USBD_CDC_ACM_HS_BINTERVAL1      0
00345 #define USBD_CDC_ACM_CIF_STRDESC        L"mbed Serial Port"
00346 #define USBD_CDC_ACM_DIF_STRDESC        L"mbed Serial Port"
00347 #define USBD_CDC_ACM_SENDBUF_SIZE       64
00348 #define USBD_CDC_ACM_RECEIVEBUF_SIZE    64
00349 #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))
00350 #error "Send Buffer size must be larger or equal to Bulk In maximum packet size!"
00351 #endif
00352 #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))
00353 #error "Receive Buffer size must be larger or equal to Bulk Out maximum packet size!"
00354 #endif
00355 
00356 //     <e0> Custom Class Device
00357 //       <i> Enables USB Custom Class Requests
00358 //       <i> Class IDs:
00359 //       <i> 0x00 - Class Reserved ID
00360 //       <i> 0x01 - Class Audio ID
00361 //       <i> 0x02 - Class Communications ID
00362 //       <i> 0x03 - Class Human Interface ID
00363 //       <i> 0x04 - Class Monitor ID
00364 //       <i> 0x05 - Class Physical Interface ID
00365 //       <i> 0x06 - Class Power ID
00366 //       <i> 0x07 - Class Printer ID
00367 //       <i> 0x08 - Class Storage ID
00368 //       <i> 0x09 - Class HUB ID
00369 //       <i> 0xEF - Class Miscellaneous ID
00370 //       <i> 0xFF - Class Vendor Specific ID
00371 //     </e>
00372 #define USBD_CLS_ENABLE             0
00373 
00374 //     WebUSB support
00375 #define USBD_WEBUSB_ENABLE          WEBUSB_INTERFACE
00376 #define USBD_WEBUSB_VENDOR_CODE     0x21
00377 #define USBD_WEBUSB_LANDING_URL     "os.mbed.com/webusb/landing-page/?bid="
00378 #define USBD_WEBUSB_ORIGIN_URL      "os.mbed.com/"
00379 
00380 //     Microsoft OS Descriptors 2.0 (WinUSB) support
00381 #define USBD_WINUSB_ENABLE          WINUSB_INTERFACE
00382 #define USBD_WINUSB_VENDOR_CODE     0x20
00383 //   </e>
00384 // </e>
00385 
00386 #ifndef BULK_ENDPOINT
00387 #define BULK_ENDPOINT 0
00388 #else
00389 #define BULK_ENDPOINT 1
00390 #endif
00391 //There are only 5 pyhical endpt so get the hid endpts
00392 #define USBD_BULK_ENABLE             BULK_ENDPOINT
00393 #define USBD_BULK_EP_BULKIN          1
00394 #define USBD_BULK_EP_BULKOUT         1
00395 #define USBD_BULK_WMAXPACKETSIZE     64
00396 #define USBD_BULK_HS_ENABLE          0
00397 #define USBD_BULK_HS_WMAXPACKETSIZE  512
00398 #define USBD_BULK_STRDESC            L"CMSIS-DAP v2"
00399 
00400 /* USB Device Calculations ---------------------------------------------------*/
00401 
00402 #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)
00403 #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))
00404 // #define MAX(x, y)                   (((x) < (y)) ? (y) : (x))
00405 #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)))
00406 #define USBD_EP_NUM_CALC1           MAX((USBD_MSC_ENABLE    *(USBD_MSC_EP_BULKIN    )), (USBD_MSC_ENABLE    *(USBD_MSC_EP_BULKOUT)))
00407 #define USBD_EP_NUM_CALC2           MAX((USBD_ADC_ENABLE    *(USBD_ADC_EP_ISOOUT    )), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_INTIN)))
00408 #define USBD_EP_NUM_CALC3           MAX((USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_BULKIN)), (USBD_CDC_ACM_ENABLE*(USBD_CDC_ACM_EP_BULKOUT)))
00409 #define USBD_EP_NUM_CALC4           MAX(USBD_EP_NUM_CALC0, USBD_EP_NUM_CALC1)
00410 #define USBD_EP_NUM_CALC5           MAX(USBD_EP_NUM_CALC2, USBD_EP_NUM_CALC3)
00411 #define USBD_EP_NUM_CALC6           MAX(USBD_EP_NUM_CALC4, USBD_EP_NUM_CALC5)
00412 #define USBD_EP_NUM_CALC7           MAX((USBD_BULK_ENABLE*(USBD_BULK_EP_BULKIN)), (USBD_BULK_ENABLE*(USBD_BULK_EP_BULKOUT)))
00413 #define USBD_EP_NUM                 MAX(USBD_EP_NUM_CALC6, USBD_EP_NUM_CALC7)
00414 
00415 #if (USBD_EP_NUM > 5)
00416 #error "Lpc11u35 only have 5 pyhsical endpoints including EP0!"
00417 #endif
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 
00483 #define USBD_ADC_CIF_STR_NUM       (3+USBD_STRDESC_SER_ENABLE+0)
00484 #define USBD_ADC_SIF1_STR_NUM      (3+USBD_STRDESC_SER_ENABLE+1)
00485 #define USBD_ADC_SIF2_STR_NUM      (3+USBD_STRDESC_SER_ENABLE+2)
00486 #define USBD_CDC_ACM_CIF_STR_NUM   (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+0)
00487 #define USBD_CDC_ACM_DIF_STR_NUM   (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+1)
00488 #define USBD_HID_IF_STR_NUM        (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2)
00489 #define USBD_WEBUSB_IF_STR_NUM     (3+USBD_STRDESC_SER_ENABLE+USBD_ADC_ENABLE*3+USBD_CDC_ACM_ENABLE*2+USBD_HID_ENABLE)
00490 #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)
00491 #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)
00492 
00493 #if    (USBD_HID_ENABLE)
00494 #if    (USBD_HID_HS_ENABLE)
00495 #define USBD_HID_MAX_PACKET       ((USBD_HID_HS_WMAXPACKETSIZE > USBD_HID_WMAXPACKETSIZE) ? USBD_HID_HS_WMAXPACKETSIZE : USBD_HID_WMAXPACKETSIZE)
00496 #else
00497 #define USBD_HID_MAX_PACKET        (USBD_HID_WMAXPACKETSIZE)
00498 #endif
00499 #else
00500 #define USBD_HID_MAX_PACKET        (0)
00501 #endif
00502 #if    (USBD_MSC_ENABLE)
00503 #if    (USBD_MSC_HS_ENABLE)
00504 #define USBD_MSC_MAX_PACKET       ((USBD_MSC_HS_WMAXPACKETSIZE > USBD_MSC_WMAXPACKETSIZE) ? USBD_MSC_HS_WMAXPACKETSIZE : USBD_MSC_WMAXPACKETSIZE)
00505 #else
00506 #define USBD_MSC_MAX_PACKET        (USBD_MSC_WMAXPACKETSIZE)
00507 #endif
00508 #else
00509 #define USBD_MSC_MAX_PACKET        (0)
00510 #endif
00511 #if    (USBD_ADC_ENABLE)
00512 #if    (USBD_ADC_HS_ENABLE)
00513 #define USBD_ADC_MAX_PACKET       ((USBD_ADC_HS_WMAXPACKETSIZE > USBD_ADC_WMAXPACKETSIZE) ? USBD_ADC_HS_WMAXPACKETSIZE : USBD_ADC_WMAXPACKETSIZE)
00514 #else
00515 #define USBD_ADC_MAX_PACKET        (USBD_ADC_WMAXPACKETSIZE)
00516 #endif
00517 #else
00518 #define USBD_ADC_MAX_PACKET        (0)
00519 #endif
00520 #if    (USBD_CDC_ACM_ENABLE)
00521 #if    (USBD_CDC_ACM_HS_ENABLE)
00522 #define USBD_CDC_ACM_MAX_PACKET   ((USBD_CDC_ACM_HS_WMAXPACKETSIZE > USBD_CDC_ACM_WMAXPACKETSIZE) ? USBD_CDC_ACM_HS_WMAXPACKETSIZE : USBD_CDC_ACM_WMAXPACKETSIZE)
00523 #else
00524 #define USBD_CDC_ACM_MAX_PACKET    (USBD_CDC_ACM_WMAXPACKETSIZE)
00525 #endif
00526 #if    (USBD_CDC_ACM_HS_ENABLE1)
00527 #define USBD_CDC_ACM_MAX_PACKET1  ((USBD_CDC_ACM_HS_WMAXPACKETSIZE1 > USBD_CDC_ACM_WMAXPACKETSIZE1) ? USBD_CDC_ACM_HS_WMAXPACKETSIZE1 : USBD_CDC_ACM_WMAXPACKETSIZE1)
00528 #else
00529 #define USBD_CDC_ACM_MAX_PACKET1   (USBD_CDC_ACM_WMAXPACKETSIZE1)
00530 #endif
00531 #else
00532 #define USBD_CDC_ACM_MAX_PACKET    (0)
00533 #define USBD_CDC_ACM_MAX_PACKET1   (0)
00534 #endif
00535 
00536 #if    (USBD_BULK_ENABLE)
00537 #if    (USBD_BULK_HS_ENABLE)
00538 #define USBD_BULK_MAX_PACKET       ((USBD_BULK_HS_WMAXPACKETSIZE > USBD_BULK_WMAXPACKETSIZE) ? USBD_BULK_HS_WMAXPACKETSIZE : USBD_BULK_WMAXPACKETSIZE)
00539 #else
00540 #define USBD_BULK_MAX_PACKET        (USBD_BULK_WMAXPACKETSIZE)
00541 #endif
00542 #else
00543 #define USBD_BULK_MAX_PACKET        (0)
00544 #endif
00545 
00546 #define USBD_MAX_PACKET_CALC0     ((USBD_HID_MAX_PACKET   > USBD_HID_MAX_PACKET      ) ? (USBD_HID_MAX_PACKET  ) : (USBD_HID_MAX_PACKET      ))
00547 #define USBD_MAX_PACKET_CALC1     ((USBD_ADC_MAX_PACKET   > USBD_CDC_ACM_MAX_PACKET  ) ? (USBD_ADC_MAX_PACKET  ) : (USBD_CDC_ACM_MAX_PACKET  ))
00548 #define USBD_MAX_PACKET_CALC2     ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1    ) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1    ))
00549 #define USBD_MAX_PACKET_CALC3     ((USBD_BULK_MAX_PACKET > USBD_CDC_ACM_MAX_PACKET1 ) ? (USBD_BULK_MAX_PACKET) : (USBD_CDC_ACM_MAX_PACKET1 ))
00550 #define USBD_MAX_PACKET           ((USBD_MAX_PACKET_CALC3 > USBD_MAX_PACKET_CALC2    ) ? (USBD_MAX_PACKET_CALC3) : (USBD_MAX_PACKET_CALC2    ))
00551 
00552 
00553 /*------------------------------------------------------------------------------
00554  *      USB Config Functions
00555  *----------------------------------------------------------------------------*/
00556 
00557 #ifndef  __USB_CONFIG___
00558 #define  __USB_CONFIG__
00559 
00560 #ifndef  __NO_USB_LIB_C
00561 #include "usb_lib.c"
00562 #endif
00563 
00564 #endif  /* __USB_CONFIG__ */