Guest User

usb_config.c

a guest
Nov 15th, 2012
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 23.32 KB | None | 0 0
  1. /*----------------------------------------------------------------------------
  2.  *      RL-ARM - USB
  3.  *----------------------------------------------------------------------------
  4.  *      Name:    usb_config.c
  5.  *      Purpose: System Configuration
  6.  *      Rev.:    V4.60
  7.  *----------------------------------------------------------------------------
  8.  *      This code is part of the RealView Run-Time Library.
  9.  *      Copyright (c) 2004-2012 KEIL - An ARM Company. All rights reserved.
  10.  *---------------------------------------------------------------------------*/
  11.  
  12. //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
  13.  
  14. /*----------------------------------------------------------------------------
  15.  *      USB Host Configuration
  16.  *---------------------------------------------------------------------------*/
  17.  
  18. // <h> USB Host
  19. //   <e> USB Host 0
  20. //     <i> Enable the USB Host 0 functionality
  21. //     <o1> Controller Interface
  22. //       <i> Selects the USB Host 0 controller interface
  23. //       <0=> Custom <1=> OHCI
  24. //   </e>
  25. #define USBH0_ENABLE                0
  26. #define USBH0_HC_IF                 0
  27.  
  28. //   <e> USB Host 1
  29. //     <i> Enable the USB Host 1 functionality
  30. //     <o1> Controller Interface
  31. //       <i> Selects the USB Host 1 controller interface
  32. //       <0=> Custom <1=> OHCI
  33. //   </e>
  34. #define USBH1_ENABLE                0
  35. #define USBH1_HC_IF                 0
  36.  
  37. //   <h> Class Configuration
  38. //     <i> Selects supported classes
  39. //     <e0.0> Mass Storage Device Class (MSC)
  40. //       <o1> Number of concurrent MSC Devices on single USB Host controller <0-15>
  41. //     </e>
  42. //     <e0.1> Human Interface Device Class (HID)
  43. //       <o2> Number of concurrent HID Devices on single USB Host controller <0-15>
  44. //     </e>
  45. //     <e0.2> USB Device Class
  46. //       <o3> Number of concurrent Custom Class Devices on single USB Host controller <0-15>
  47. //     </e>
  48. //   </h>
  49. #define USBH_CLASS                  0x0000
  50. #define USBH_MSC_NUM                0
  51. #define USBH_HID_NUM                0
  52. #define USBH_CLS_NUM                0
  53.  
  54. // </h>
  55.  
  56.  
  57. /*----------------------------------------------------------------------------
  58.  *      USB Device Configuration
  59.  *---------------------------------------------------------------------------*/
  60.  
  61. // <e> USB Device
  62. //   <i> Enable the USB Device functionality
  63. #define USBD_ENABLE                 1
  64.  
  65. //   <o0.0> High-speed
  66. //     <i> Enable high-speed functionality (if device supports it)
  67. #define USBD_HS_ENABLE              0
  68.  
  69. //   <h> Device Settings
  70. //     <i> These settings affect Device Descriptor
  71. //     <o0> Power
  72. //       <i> Default Power Setting
  73. //       <0=> Bus-powered
  74. //       <1=> Self-powered
  75. //     <o1> Max Endpoint 0 Packet Size
  76. //       <i> Maximum packet size for endpoint zero (bMaxPacketSize0)
  77. //       <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
  78. //     <o2.0..15> Vendor ID <0x0000-0xFFFF>
  79. //       <i> Vendor ID assigned by the USB-IF (idVendor)
  80. //     <o3.0..15> Product ID <0x0000-0xFFFF>
  81. //       <i> Product ID assigned by the manufacturer (idProduct)
  82. //     <o4.0..15> Device Release Number <0x0000-0xFFFF>
  83. //       <i> Device release number in binary-coded decimal (bcdDevice)
  84. //   </h>
  85. #define USBD_POWER                  0
  86. #define USBD_MAX_PACKET0            8
  87. #define USBD_DEVDESC_IDVENDOR       0xC251
  88. #define USBD_DEVDESC_IDPRODUCT      0x1605
  89. #define USBD_DEVDESC_BCDDEVICE      0x0100
  90.  
  91. //   <h> Configuration Settings
  92. //     <i> These settings affect Configuration Descriptor
  93. //     <o0.5> Remote Wakeup
  94. //       <i> Configuration support for remote wakeup (D5: of bmAttributes)
  95. //     <o1.0..7> Maximum Power Consumption (in mA) <0-510><#/2>
  96. //       <i> Maximum power consumption of the USB device
  97. //       <i> from the bus in this specific configuration
  98. //       <i> when the device is fully operational (bMaxPower)
  99. //   </h>
  100. #define USBD_CFGDESC_BMATTRIBUTES   0x80
  101. #define USBD_CFGDESC_BMAXPOWER      0x32
  102.  
  103. //   <h> String Settings
  104. //     <i> These settings affect String Descriptor
  105. //     <o0.0..15> Language ID <0x0000-0xFCFF>
  106. //       <i> English (United States) = 0x0409
  107. //     <s0.126> Manufacturer String
  108. //       <i> String descriptor describing manufacturer
  109. //     <s1.126> Product String
  110. //       <i> String descriptor describing product
  111. //     <e1.0> Serial Number
  112. //       <i> Enable serial number string
  113. //       <i> If disabled serial number string will not be assigned to the USB Device
  114. //       <s2.126> Serial Number String
  115. //         <i> String descriptor describing device's serial number
  116. //     </e>
  117. //   </h>
  118. #define USBD_STRDESC_LANGID         0x0409
  119. #define USBD_STRDESC_MAN            L"Keil Software"
  120. #define USBD_STRDESC_PROD           L"Keil CDC Device"
  121. #define USBD_STRDESC_SER_ENABLE     1
  122. #define USBD_STRDESC_SER            L"0001A0000000"
  123.  
  124. //   <e0> Class Support
  125. //     <i> Enables USB Device Class specific Requests
  126. #define USBD_CLASS_ENABLE           1
  127.  
  128. //     <e0.0> Human Interface Device (HID)
  129. //       <i> Enable class support for Human Interface Device (HID)
  130. //       <h> Interrupt Endpoint Settings
  131. //         <o1.0..4> Interrupt In Endpoint Number                  <1=>   1 <2=>   2 <3=>   3
  132. //                                                 <4=>   4        <5=>   5 <6=>   6 <7=>   7
  133. //                                                 <8=>   8        <9=>   9 <10=> 10 <11=> 11
  134. //                                                 <12=>  12       <13=> 13 <14=> 14 <15=> 15
  135. //         <o2.0..4> Interrupt Out Endpoint Number <0=>   Not used <1=>   1 <2=>   2 <3=>   3
  136. //                                                 <4=>   4        <5=>   5 <6=>   6 <7=>   7
  137. //                                                 <8=>   8        <9=>   9 <10=> 10 <11=> 11
  138. //                                                 <12=>  12       <13=> 13 <14=> 14 <15=> 15
  139. //           <i> If interrupt out endpoint is not used select "Not used"
  140. //         <h> Endpoint Settings
  141. //           <o3.0..7> Maximum Endpoint Packet Size (in bytes) <0-64>
  142. //           <o4.0..7> Endpoint polling Interval (in ms) <1-255>
  143. //           <e5> High-speed
  144. //             <i> If high-speed is enabled set endpoint settings for it
  145. //             <o6.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
  146. //             <o6.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
  147. //             <o7.0..7> Endpoint polling Interval (in ms) <1=>      1 <2=>      2 <3=>      4 <4=>      8
  148. //                                                         <5=>     16 <6=>     32 <7=>     64 <8=>    128
  149. //                                                         <9=>    256 <10=>   512 <11=>  1024 <12=>  2048
  150. //                                                         <13=>  4096 <14=>  8192 <15=> 16384 <16=> 32768
  151. //           </e>
  152. //         </h>
  153. //       </h>
  154. //       <h> Human Interface Device Settings
  155. //         <i> Device specific settings
  156. //         <s0.126> HID Interface String
  157. //         <o8.0..4> Number of Input Reports <1-32>
  158. //         <o9.0..4> Number of Output Reports <1-32>
  159. //         <o10.0..15> Maximum Input Report Size (in bytes) <1-65535>
  160. //         <o11.0..15> Maximum Output Report Size (in bytes) <1-65535>
  161. //         <o12.0..15> Maximum Feature Report Size (in bytes) <1-65535>
  162. //       </h>
  163. //     </e>
  164. #define USBD_HID_ENABLE             0
  165. #define USBD_HID_EP_INTIN           1
  166. #define USBD_HID_EP_INTOUT          1
  167. #define USBD_HID_WMAXPACKETSIZE     4
  168. #define USBD_HID_BINTERVAL          32
  169. #define USBD_HID_HS_ENABLE          0
  170. #define USBD_HID_HS_WMAXPACKETSIZE  4
  171. #define USBD_HID_HS_BINTERVAL       6
  172. #define USBD_HID_STRDESC            L"USB_HID"
  173. #define USBD_HID_INREPORT_NUM       1
  174. #define USBD_HID_OUTREPORT_NUM      1
  175. #define USBD_HID_INREPORT_MAX_SZ    1
  176. #define USBD_HID_OUTREPORT_MAX_SZ   1
  177. #define USBD_HID_FEATREPORT_MAX_SZ  1
  178.  
  179. //     <e0.0> Mass Storage Device (MSC)
  180. //       <i> Enable class support for Mass Storage Device (MSC)
  181. //       <h> Bulk Endpoint Settings
  182. //         <o1.0..4> Bulk In Endpoint Number                  <1=>   1 <2=>   2 <3=>   3
  183. //                                            <4=>   4        <5=>   5 <6=>   6 <7=>   7
  184. //                                            <8=>   8        <9=>   9 <10=> 10 <11=> 11
  185. //                                            <12=>  12       <13=> 13 <14=> 14 <15=> 15
  186. //         <o2.0..4> Bulk Out Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
  187. //                                            <4=>   4        <5=>   5 <6=>   6 <7=>   7
  188. //                                            <8=>   8        <9=>   9 <10=> 10 <11=> 11
  189. //                                            <12=>  12       <13=> 13 <14=> 14 <15=> 15
  190. //         <h> Endpoint Settings
  191. //           <o3> Maximum Packet Size <1-1024>
  192. //           <e4> High-speed
  193. //             <i> If high-speed is enabled set endpoint settings for it
  194. //             <o5> Maximum Packet Size <1-1024>
  195. //             <o6> Maximum NAK Rate <0-255>
  196. //           </e>
  197. //         </h>
  198. //       </h>
  199. //       <h> Mass Storage Device Settings
  200. //         <i> Device specific settings
  201. //         <s0.126> MSC Interface String
  202. //         <h> Inquiry Data
  203. //           <s1.8>  Vendor Identification
  204. //           <s2.16> Product Identification
  205. //           <s3.4>  Product Revision Level
  206. //         </h>
  207. //       </h>
  208. //     </e>
  209. #define USBD_MSC_ENABLE             0
  210. #define USBD_MSC_EP_BULKIN          3
  211. #define USBD_MSC_EP_BULKOUT         2
  212. #define USBD_MSC_WMAXPACKETSIZE     64
  213. #define USBD_MSC_HS_ENABLE          0
  214. #define USBD_MSC_HS_WMAXPACKETSIZE  512
  215. #define USBD_MSC_HS_BINTERVAL       0
  216. #define USBD_MSC_STRDESC            L"USB_MSC"
  217. #define USBD_MSC_INQUIRY_DATA       "Keil    "         \
  218.                                     "STR91x Disk     " \
  219.                                     "1.0 "
  220.  
  221. //     <e0.0> Audio Device (ADC)
  222. //       <i> Enable class support for Audio Device (ADC)
  223. //       <h> Isochronous Endpoint Settings
  224. //         <o1.0..4> Isochronous Out Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
  225. //                                                   <4=>   4        <5=>   5 <6=>   6 <7=>   7
  226. //                                                   <8=>   8        <9=>   9 <10=> 10 <11=> 11
  227. //                                                   <12=>  12       <13=> 13 <14=> 14 <15=> 15
  228. //         <h> Endpoint Settings
  229. //           <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
  230. //           <o3.0..10> Endpoint polling Interval (in ms) <1=>      1 <2=>      2 <3=>      4 <4=>      8
  231. //                                                        <5=>     16 <6=>     32 <7=>     64 <8=>    128
  232. //                                                        <9=>    256 <10=>   512 <11=>  1024 <12=>  2048
  233. //                                                        <13=>  4096 <14=>  8192 <15=> 16384 <16=> 32768
  234. //           <e4> High-speed
  235. //             <i> If high-speed is enabled set endpoint settings for it
  236. //             <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
  237. //             <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
  238. //           </e>
  239. //         </h>
  240. //       </h>
  241. //       <h> Audio Device Settings
  242. //         <i> Device specific settings
  243. //         <s0.126> Audio Control Interface String
  244. //         <s1.126> Audio Streaming (Zero Bandwidth) Interface String
  245. //         <s2.126> Audio Streaming (Operational) Interface String
  246. //         <o6.0..7> Audio Subframe Size (in bytes) <0-255>
  247. //         <o7.0..7> Sample Resolution (in bits) <0-255>
  248. //         <o8.0..23> Sample Frequency (in Hz) <0-16777215>
  249. //         <o9> Packet Size (in bytes) <1-256>
  250. //         <o10> Packet Count <1-16>
  251. //       </h>
  252. //     </e>
  253. #define USBD_ADC_ENABLE             0
  254. #define USBD_ADC_EP_ISOOUT          3
  255. #define USBD_ADC_WMAXPACKETSIZE     64
  256. #define USBD_ADC_BINTERVAL          1
  257. #define USBD_ADC_HS_ENABLE          0
  258. #define USBD_ADC_HS_WMAXPACKETSIZE  64
  259. #define USBD_ADC_CIF_STRDESC        L"USB_ADC"
  260. #define USBD_ADC_SIF1_STRDESC       L"USB_ADC1"
  261. #define USBD_ADC_SIF2_STRDESC       L"USB_ADC2"
  262. #define USBD_ADC_BSUBFRAMESIZE      2
  263. #define USBD_ADC_BBITRESOLUTION     16
  264. #define USBD_ADC_TSAMFREQ           32000
  265. #define USBD_ADC_CFG_P_S            32
  266. #define USBD_ADC_CFG_P_C            1
  267.  
  268. //     <e0> Communication Device (CDC)
  269. //       <i> Enable class support for Communication Device (CDC)
  270. //       <h> Interrupt Endpoint Settings
  271. //         <o1.0..4> Interrupt In Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
  272. //                                                <4=>   4        <5=>   5 <6=>   6 <7=>   7
  273. //                                                <8=>   8        <9=>   9 <10=> 10 <11=> 11
  274. //                                                <12=>  12       <13=> 13 <14=> 14 <15=> 15
  275. //         <h> Endpoint Settings
  276. //           <o2.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
  277. //           <o3.0..10> Endpoint polling Interval (in ms) <0-255>
  278. //           <e4> High-speed
  279. //             <i> If high-speed is enabled set endpoint settings for it
  280. //             <o5.0..10> Maximum Endpoint Packet Size (in bytes) <0-1024>
  281. //             <o5.11..12> Additional transactions per microframe <0=> None <1=> 1 additional <2=> 2 additional
  282. //             <o6.0..10> Endpoint polling Interval (in ms) <1=>      1 <2=>      2 <3=>      4 <4=>      8
  283. //                                                          <5=>     16 <6=>     32 <7=>     64 <8=>    128
  284. //                                                          <9=>    256 <10=>   512 <11=>  1024 <12=>  2048
  285. //                                                          <13=>  4096 <14=>  8192 <15=> 16384 <16=> 32768
  286. //           </e4>
  287. //         </h>
  288. //       </h>
  289. //       <h> Bulk Endpoint Settings
  290. //         <o7.0..4> Bulk In Endpoint Number                  <1=>   1 <2=>   2 <3=>   3
  291. //                                            <4=>   4        <5=>   5 <6=>   6 <7=>   7
  292. //                                            <8=>   8        <9=>   9 <10=> 10 <11=> 11
  293. //                                            <12=>  12       <13=> 13 <14=> 14 <15=> 15
  294. //         <o8.0..4> Bulk Out Endpoint Number                 <1=>   1 <2=>   2 <3=>   3
  295. //                                            <4=>   4        <5=>   5 <6=>   6 <7=>   7
  296. //                                            <8=>   8        <9=>   9 <10=> 10 <11=> 11
  297. //                                            <12=>  12       <13=> 13 <14=> 14 <15=> 15
  298. //         <h> Endpoint Settings
  299. //           <o9> Maximum Packet Size <1-1024>
  300. //           <e10> High-speed
  301. //             <i> If high-speed is enabled set endpoint settings for it
  302. //             <o11> Maximum Packet Size <1-1024>
  303. //             <o12> Maximum NAK Rate <0-255>
  304. //           </e10>
  305. //         </h>
  306. //       </h>
  307. //       <h> Communication Device Settings
  308. //         <i> Device specific settings
  309. //         <s0.126> Communication Class Interface String
  310. //         <s1.126> Data Class Interface String
  311. //         <o13> Maximum Communication Device Buffer Size
  312. //            <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
  313. //         <o14> Maximum Communication Device Output Buffer Size
  314. //            <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes <128=> 128 Bytes
  315. //       </h>
  316. //     </e>
  317. #define USBD_CDC_ENABLE             1
  318. #define USBD_CDC_EP_INTIN           1
  319. #define USBD_CDC_WMAXPACKETSIZE     16
  320. #define USBD_CDC_BINTERVAL          2
  321. #define USBD_CDC_HS_ENABLE          0
  322. #define USBD_CDC_HS_WMAXPACKETSIZE  16
  323. #define USBD_CDC_HS_BINTERVAL       2
  324. #define USBD_CDC_EP_BULKIN          2
  325. #define USBD_CDC_EP_BULKOUT         2
  326. #define USBD_CDC_WMAXPACKETSIZE1    64
  327. #define USBD_CDC_HS_ENABLE1         0
  328. #define USBD_CDC_HS_WMAXPACKETSIZE1 64
  329. #define USBD_CDC_HS_BINTERVAL1      0
  330. #define USBD_CDC_CIF_STRDESC        L"USB_CDC"
  331. #define USBD_CDC_DIF_STRDESC        L"USB_CDC1"
  332. #define USBD_CDC_BUFSIZE            64
  333. #define USBD_CDC_OUTBUFSIZE         128
  334.  
  335. //     <e0> Custom Class Device
  336. //       <i> Enables USB Custom Class Requests
  337. //       <i> Class IDs:
  338. //       <i> 0x00 - Class Reserved ID
  339. //       <i> 0x01 - Class Audio ID
  340. //       <i> 0x02 - Class Communications ID
  341. //       <i> 0x03 - Class Human Interface ID
  342. //       <i> 0x04 - Class Monitor ID
  343. //       <i> 0x05 - Class Physical Interface ID
  344. //       <i> 0x06 - Class Power ID
  345. //       <i> 0x07 - Class Printer ID
  346. //       <i> 0x08 - Class Storage ID
  347. //       <i> 0x09 - Class HUB ID
  348. //       <i> 0xEF - Class Miscellaneous ID
  349. //       <i> 0xFF - Class Vendor Specific ID
  350. //     </e>
  351. #define USBD_CLS_ENABLE             0
  352.  
  353. //   </e>
  354. // </e>
  355.  
  356.  
  357. /* USB Device Calculations --------------------------------------------------*/
  358.  
  359. #define USBD_IF_NUM                (USBD_HID_ENABLE+USBD_MSC_ENABLE+(USBD_ADC_ENABLE*2)+(USBD_CDC_ENABLE*2))
  360. #define USBD_MULTI_IF              (USBD_CDC_ENABLE*(USBD_HID_ENABLE|USBD_MSC_ENABLE|USBD_ADC_ENABLE))
  361. #define MAX(x, y)                (((x) < (y)) ? (y) : (x))
  362. #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)))
  363. #define USBD_EP_NUM_CALC1           MAX((USBD_MSC_ENABLE*(USBD_MSC_EP_BULKIN)), (USBD_MSC_ENABLE*(USBD_MSC_EP_BULKOUT)))
  364. #define USBD_EP_NUM_CALC2           MAX((USBD_ADC_ENABLE*(USBD_ADC_EP_ISOOUT)), (USBD_CDC_ENABLE*(USBD_CDC_EP_INTIN)))
  365. #define USBD_EP_NUM_CALC3           MAX((USBD_CDC_ENABLE*(USBD_CDC_EP_BULKIN)), (USBD_CDC_ENABLE*(USBD_CDC_EP_BULKOUT)))
  366. #define USBD_EP_NUM_CALC4           MAX(USBD_EP_NUM_CALC0, USBD_EP_NUM_CALC1)
  367. #define USBD_EP_NUM_CALC5           MAX(USBD_EP_NUM_CALC2, USBD_EP_NUM_CALC3)
  368. #define USBD_EP_NUM_CALC6           MAX(USBD_EP_NUM_CALC4, USBD_EP_NUM_CALC5)
  369. #define USBD_EP_NUM                (USBD_EP_NUM_CALC6)
  370.  
  371. #if    (USBD_HID_ENABLE)
  372. #if    (USBD_MSC_ENABLE)
  373. #if ((((USBD_HID_EP_INTIN   == USBD_MSC_EP_BULKIN)  || \
  374.        (USBD_HID_EP_INTIN   == USBD_MSC_EP_BULKIN)))|| \
  375.       ((USBD_HID_EP_INTOUT  != 0)                   && \
  376.        (USBD_HID_EP_INTOUT  == USBD_MSC_EP_BULKIN)  || \
  377.        (USBD_HID_EP_INTOUT  == USBD_MSC_EP_BULKOUT)))
  378. #error "HID and Mass Storage Device Interface can not use same Endpoints!"
  379. #endif
  380. #endif
  381. #if    (USBD_ADC_ENABLE)
  382. #if   ((USBD_HID_EP_INTIN   == USBD_ADC_EP_ISOOUT)  || \
  383.       ((USBD_HID_EP_INTOUT  != 0)                   && \
  384.        (USBD_HID_EP_INTOUT  == USBD_ADC_EP_ISOOUT)))
  385. #error "HID and Audio Device Interface can not use same Endpoints!"
  386. #endif
  387. #endif
  388. #if    (USBD_CDC_ENABLE)
  389. #if  (((USBD_HID_EP_INTIN   == USBD_CDC_EP_INTIN)   || \
  390.        (USBD_HID_EP_INTIN   == USBD_CDC_EP_BULKIN)  || \
  391.        (USBD_HID_EP_INTIN   == USBD_CDC_EP_BULKOUT))|| \
  392.       ((USBD_HID_EP_INTOUT  != 0)                   && \
  393.       ((USBD_HID_EP_INTOUT  == USBD_CDC_EP_INTIN)   || \
  394.        (USBD_HID_EP_INTOUT  == USBD_CDC_EP_BULKIN)  || \
  395.        (USBD_HID_EP_INTOUT  == USBD_CDC_EP_BULKOUT))))
  396. #error "HID and Communication Device Interface can not use same Endpoints!"
  397. #endif
  398. #endif
  399. #endif
  400.  
  401. #if    (USBD_MSC_ENABLE)
  402. #if    (USBD_ADC_ENABLE)
  403. #if   ((USBD_MSC_EP_BULKIN  == USBD_ADC_EP_ISOOUT)  || \
  404.        (USBD_MSC_EP_BULKOUT == USBD_ADC_EP_ISOOUT))
  405. #error "Mass Storage Device and Audio Device Interface can not use same Endpoints!"
  406. #endif
  407. #endif
  408. #if    (USBD_CDC_ENABLE)
  409. #if   ((USBD_MSC_EP_BULKIN  == USBD_CDC_EP_INTIN)   || \
  410.        (USBD_MSC_EP_BULKIN  == USBD_CDC_EP_BULKIN)  || \
  411.        (USBD_MSC_EP_BULKIN  == USBD_CDC_EP_BULKOUT) || \
  412.        (USBD_MSC_EP_BULKOUT == USBD_CDC_EP_INTIN)   || \
  413.        (USBD_MSC_EP_BULKOUT == USBD_CDC_EP_BULKIN)  || \
  414.        (USBD_MSC_EP_BULKOUT == USBD_CDC_EP_BULKOUT))
  415. #error "Mass Storage Device and Communication Device Interface can not use same Endpoints!"
  416. #endif
  417. #endif
  418. #endif
  419.  
  420. #if    (USBD_ADC_ENABLE)
  421. #if    (USBD_CDC_ENABLE)
  422. #if   ((USBD_ADC_EP_ISOOUT  == USBD_CDC_EP_INTIN)   || \
  423.        (USBD_ADC_EP_ISOOUT  == USBD_CDC_EP_BULKIN)  || \
  424.        (USBD_ADC_EP_ISOOUT  == USBD_CDC_EP_BULKOUT))
  425. #error "Audio Device and Communication Device Interface can not use same Endpoints!"
  426. #endif
  427. #endif
  428. #endif
  429.  
  430. #define USBD_CDC_CIF_NUM           (0)
  431. #define USBD_CDC_DIF_NUM           (1)
  432. #define USBD_ADC_CIF_NUM           (USBD_CDC_ENABLE*2+0)
  433. #define USBD_ADC_SIF1_NUM          (USBD_CDC_ENABLE*2+1)
  434. #define USBD_ADC_SIF2_NUM          (USBD_CDC_ENABLE*2+2)
  435. #define USBD_HID_IF_NUM            (USBD_CDC_ENABLE*2+USBD_ADC_ENABLE*2)
  436. #define USBD_MSC_IF_NUM            (USBD_CDC_ENABLE*2+USBD_ADC_ENABLE*2+USBD_HID_ENABLE)
  437.  
  438. #define USBD_CDC_CIF_STR_NUM       (0)
  439. #define USBD_CDC_DIF_STR_NUM       (1)
  440. #define USBD_ADC_CIF_STR_NUM       (USBD_CDC_ENABLE*2+0)
  441. #define USBD_ADC_SIF1_STR_NUM      (USBD_CDC_ENABLE*2+1)
  442. #define USBD_ADC_SIF2_STR_NUM      (USBD_CDC_ENABLE*2+2)
  443. #define USBD_HID_IF_STR_NUM        (USBD_CDC_ENABLE*2+USBD_ADC_ENABLE*3)
  444. #define USBD_MSC_IF_STR_NUM        (USBD_CDC_ENABLE*2+USBD_ADC_ENABLE*3+USBD_HID_ENABLE)
  445.  
  446. #if    (USBD_HID_ENABLE)
  447. #if    (USBD_HID_HS_ENABLE)
  448. #define USBD_HID_MAX_PACKET       ((USBD_HID_HS_WMAXPACKETSIZE > USBD_HID_WMAXPACKETSIZE) ? USBD_HID_HS_WMAXPACKETSIZE : USBD_HID_WMAXPACKETSIZE)
  449. #else
  450. #define USBD_HID_MAX_PACKET        (USBD_HID_WMAXPACKETSIZE)
  451. #endif
  452. #else
  453. #define USBD_HID_MAX_PACKET        (0)
  454. #endif
  455. #if    (USBD_MSC_ENABLE)
  456. #if    (USBD_MSC_HS_ENABLE)
  457. #define USBD_MSC_MAX_PACKET       ((USBD_MSC_HS_WMAXPACKETSIZE > USBD_MSC_WMAXPACKETSIZE) ? USBD_MSC_HS_WMAXPACKETSIZE : USBD_MSC_WMAXPACKETSIZE)
  458. #else
  459. #define USBD_MSC_MAX_PACKET        (USBD_MSC_WMAXPACKETSIZE)
  460. #endif
  461. #else
  462. #define USBD_MSC_MAX_PACKET        (0)
  463. #endif
  464. #if    (USBD_ADC_ENABLE)
  465. #if    (USBD_ADC_HS_ENABLE)
  466. #define USBD_ADC_MAX_PACKET       ((USBD_ADC_HS_WMAXPACKETSIZE > USBD_ADC_WMAXPACKETSIZE) ? USBD_ADC_HS_WMAXPACKETSIZE : USBD_ADC_WMAXPACKETSIZE)
  467. #else
  468. #define USBD_ADC_MAX_PACKET        (USBD_ADC_WMAXPACKETSIZE)
  469. #endif
  470. #else
  471. #define USBD_ADC_MAX_PACKET        (0)
  472. #endif
  473. #if    (USBD_CDC_ENABLE)
  474. #if    (USBD_CDC_HS_ENABLE)
  475. #define USBD_CDC_MAX_PACKET       ((USBD_CDC_HS_WMAXPACKETSIZE > USBD_CDC_WMAXPACKETSIZE) ? USBD_CDC_HS_WMAXPACKETSIZE : USBD_CDC_WMAXPACKETSIZE)
  476. #else
  477. #define USBD_CDC_MAX_PACKET        (USBD_CDC_WMAXPACKETSIZE)
  478. #endif
  479. #if    (USBD_CDC_HS_ENABLE1)
  480. #define USBD_CDC_MAX_PACKET1      ((USBD_CDC_HS_WMAXPACKETSIZE1 > USBD_CDC_WMAXPACKETSIZE1) ? USBD_CDC_HS_WMAXPACKETSIZE1 : USBD_CDC_WMAXPACKETSIZE1)
  481. #else
  482. #define USBD_CDC_MAX_PACKET1       (USBD_CDC_WMAXPACKETSIZE1)
  483. #endif
  484. #else
  485. #define USBD_CDC_MAX_PACKET        (0)
  486. #define USBD_CDC_MAX_PACKET1       (0)
  487. #endif
  488. #define USBD_MAX_PACKET_CALC0     ((USBD_HID_MAX_PACKET   > USBD_HID_MAX_PACKET  ) ? (USBD_HID_MAX_PACKET  ) : (USBD_HID_MAX_PACKET  ))
  489. #define USBD_MAX_PACKET_CALC1     ((USBD_ADC_MAX_PACKET   > USBD_CDC_MAX_PACKET  ) ? (USBD_ADC_MAX_PACKET  ) : (USBD_CDC_MAX_PACKET  ))
  490. #define USBD_MAX_PACKET_CALC2     ((USBD_MAX_PACKET_CALC0 > USBD_MAX_PACKET_CALC1) ? (USBD_MAX_PACKET_CALC0) : (USBD_MAX_PACKET_CALC1))
  491. #define USBD_MAX_PACKET           ((USBD_MAX_PACKET_CALC2 > USBD_CDC_MAX_PACKET1 ) ? (USBD_MAX_PACKET_CALC2) : (USBD_CDC_MAX_PACKET1 ))
  492.  
  493.  
  494. /*----------------------------------------------------------------------------
  495.  *      USB Config Functions
  496.  *---------------------------------------------------------------------------*/
  497.  
  498. #ifndef  __USB_CONFIG___
  499. #define  __USB_CONFIG__
  500.  
  501. #ifndef  __NO_USB_LIB_C
  502. #include <usb_lib.c>
  503. #endif
  504.  
  505. #endif  /* __USB_CONFIG__ */
Advertisement
Add Comment
Please, Sign In to add comment