You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

399 satır
15KB

  1. /* Teensyduino Core Library
  2. * http://www.pjrc.com/teensy/
  3. * Copyright (c) 2013 PJRC.COM, LLC.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining
  6. * a copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sublicense, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * 1. The above copyright notice and this permission notice shall be
  14. * included in all copies or substantial portions of the Software.
  15. *
  16. * 2. If the Software is incorporated into a build system that allows
  17. * selection among a list of target devices, then similar target
  18. * devices manufactured by PJRC.COM must be included in the list of
  19. * target devices and selectable in the same manner.
  20. *
  21. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  22. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  23. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  24. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  25. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  26. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  28. * SOFTWARE.
  29. */
  30. #ifndef _usb_desc_h_
  31. #define _usb_desc_h_
  32. // This header is NOT meant to be included when compiling
  33. // user sketches in Arduino. The low-level functions
  34. // provided by usb_dev.c are meant to be called only by
  35. // code which provides higher-level interfaces to the user.
  36. #include <stdint.h>
  37. #include <stddef.h>
  38. #define ENDPOINT_UNUSED 0x00
  39. #define ENDPOINT_TRANSIMIT_ONLY 0x15
  40. #define ENDPOINT_RECEIVE_ONLY 0x19
  41. #define ENDPOINT_TRANSMIT_AND_RECEIVE 0x1D
  42. #define ENDPOINT_RECEIVE_ISOCHRONOUS 0x18
  43. #define ENDPOINT_TRANSMIT_ISOCHRONOUS 0x14
  44. /*
  45. Each group of #define lines below corresponds to one of the
  46. settings in the Tools > USB Type menu. This file defines what
  47. type of USB device is actually created for each of those menu
  48. options.
  49. Each "interface" is a set of functionality your PC or Mac will
  50. use and treat as if it is a unique device. Within each interface,
  51. the "endpoints" are the actual communication channels. Most
  52. interfaces use 1, 2 or 3 endpoints. By editing only this file,
  53. you can customize the USB Types to be any collection of interfaces.
  54. To modify a USB Type, delete the XYZ_INTERFACE lines for any
  55. interfaces you wish to remove, and copy them from another USB Type
  56. for any you want to add.
  57. Give each interface a unique number, and edit NUM_INTERFACE to
  58. reflect the total number of interfaces.
  59. Next, assign unique endpoint numbers to all the endpoints across
  60. all the interfaces your device has. You can reuse an endpoint
  61. number for transmit and receive, but the same endpoint number must
  62. not be used twice to transmit, or twice to receive.
  63. Most endpoints also require their maximum size, and some also
  64. need an interval specification (the number of milliseconds the
  65. PC will check for data from that endpoint). For existing
  66. interfaces, usually these other settings should not be changed.
  67. Edit NUM_ENDPOINTS to be at least the largest endpoint number used.
  68. Edit NUM_USB_BUFFERS to control how much memory the USB stack will
  69. allocate. At least 2 should be used for each endpoint. More
  70. memory will allow higher throughput for user programs that have
  71. high latency (eg, spending time doing things other than interacting
  72. with the USB).
  73. Edit the ENDPOINT*_CONFIG lines so each endpoint is configured
  74. the proper way (transmit, receive, or both).
  75. If you are using existing interfaces (making your own device with
  76. a different set of interfaces) the code in all other files should
  77. automatically adapt to the new endpoints you specify here.
  78. If you need to create a new type of interface, you'll need to write
  79. the code which sends and receives packets, and presents an API to
  80. the user. Usually, a pair of files are added for the actual code,
  81. and code is also added in usb_dev.c for any control transfers,
  82. interrupt-level code, or other very low-level stuff not possible
  83. from the packet send/receive functons. Code also is added in
  84. usb_inst.c to create an instance of your C++ object.
  85. You may edit the Vendor and Product ID numbers, and strings. If
  86. the numbers are changed, Teensyduino may not be able to automatically
  87. find and reboot your board when you click the Upload button in
  88. the Arduino IDE. You will need to press the Program button on
  89. Teensy to initiate programming.
  90. Some operating systems, especially Windows, may cache USB device
  91. info. Changes to the device name may not update on the same
  92. computer unless the vendor or product ID numbers change, or the
  93. "bcdDevice" revision code is increased.
  94. If these instructions are missing steps or could be improved, please
  95. let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
  96. */
  97. #if defined(USB_SERIAL)
  98. #define VENDOR_ID 0x16C0
  99. #define PRODUCT_ID 0x0483
  100. #define DEVICE_CLASS 2 // 2 = Communication Class
  101. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  102. #define MANUFACTURER_NAME_LEN 11
  103. #define PRODUCT_NAME {'U','S','B',' ','S','e','r','i','a','l'}
  104. #define PRODUCT_NAME_LEN 10
  105. #define EP0_SIZE 64
  106. #define NUM_ENDPOINTS 4
  107. #define NUM_USB_BUFFERS 12
  108. #define NUM_INTERFACE 2
  109. #define CDC_STATUS_INTERFACE 0
  110. #define CDC_DATA_INTERFACE 1
  111. #define CDC_ACM_ENDPOINT 2
  112. #define CDC_RX_ENDPOINT 3
  113. #define CDC_TX_ENDPOINT 4
  114. #define CDC_ACM_SIZE 16
  115. #define CDC_RX_SIZE 64
  116. #define CDC_TX_SIZE 64
  117. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  118. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  119. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  120. #elif defined(USB_HID)
  121. #define VENDOR_ID 0x16C0
  122. #define PRODUCT_ID 0x0482
  123. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  124. #define MANUFACTURER_NAME_LEN 11
  125. #define PRODUCT_NAME {'K','e','y','b','o','a','r','d','/','M','o','u','s','e','/','J','o','y','s','t','i','c','k'}
  126. #define PRODUCT_NAME_LEN 23
  127. #define EP0_SIZE 64
  128. #define NUM_ENDPOINTS 6
  129. #define NUM_USB_BUFFERS 24
  130. #define NUM_INTERFACE 5
  131. #define SEREMU_INTERFACE 2 // Serial emulation
  132. #define SEREMU_TX_ENDPOINT 1
  133. #define SEREMU_TX_SIZE 64
  134. #define SEREMU_TX_INTERVAL 1
  135. #define SEREMU_RX_ENDPOINT 2
  136. #define SEREMU_RX_SIZE 32
  137. #define SEREMU_RX_INTERVAL 2
  138. #define KEYBOARD_INTERFACE 0 // Keyboard
  139. #define KEYBOARD_ENDPOINT 3
  140. #define KEYBOARD_SIZE 8
  141. #define KEYBOARD_INTERVAL 1
  142. #define KEYMEDIA_INTERFACE 4 // Keyboard Media Keys
  143. #define KEYMEDIA_ENDPOINT 6
  144. #define KEYMEDIA_SIZE 8
  145. #define KEYMEDIA_INTERVAL 4
  146. #define MOUSE_INTERFACE 1 // Mouse
  147. #define MOUSE_ENDPOINT 5
  148. #define MOUSE_SIZE 8
  149. #define MOUSE_INTERVAL 1
  150. #define JOYSTICK_INTERFACE 3 // Joystick
  151. #define JOYSTICK_ENDPOINT 4
  152. #define JOYSTICK_SIZE 16
  153. #define JOYSTICK_INTERVAL 2
  154. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  155. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  156. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  157. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  158. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  159. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  160. #elif defined(USB_SERIAL_HID)
  161. #define VENDOR_ID 0x16C0
  162. #define PRODUCT_ID 0x0487
  163. #define DEVICE_CLASS 0xEF
  164. #define DEVICE_SUBCLASS 0x02
  165. #define DEVICE_PROTOCOL 0x01
  166. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  167. #define MANUFACTURER_NAME_LEN 11
  168. #define PRODUCT_NAME {'S','e','r','i','a','l','/','K','e','y','b','o','a','r','d','/','M','o','u','s','e','/','J','o','y','s','t','i','c','k'}
  169. #define PRODUCT_NAME_LEN 30
  170. #define EP0_SIZE 64
  171. #define NUM_ENDPOINTS 7
  172. #define NUM_USB_BUFFERS 30
  173. #define NUM_INTERFACE 6
  174. #define CDC_IAD_DESCRIPTOR 1
  175. #define CDC_STATUS_INTERFACE 0
  176. #define CDC_DATA_INTERFACE 1 // Serial
  177. #define CDC_ACM_ENDPOINT 2
  178. #define CDC_RX_ENDPOINT 3
  179. #define CDC_TX_ENDPOINT 4
  180. #define CDC_ACM_SIZE 16
  181. #define CDC_RX_SIZE 64
  182. #define CDC_TX_SIZE 64
  183. #define KEYBOARD_INTERFACE 2 // Keyboard
  184. #define KEYBOARD_ENDPOINT 1
  185. #define KEYBOARD_SIZE 8
  186. #define KEYBOARD_INTERVAL 1
  187. #define KEYMEDIA_INTERFACE 5 // Keyboard Media Keys
  188. #define KEYMEDIA_ENDPOINT 7
  189. #define KEYMEDIA_SIZE 8
  190. #define KEYMEDIA_INTERVAL 4
  191. #define MOUSE_INTERFACE 3 // Mouse
  192. #define MOUSE_ENDPOINT 5
  193. #define MOUSE_SIZE 8
  194. #define MOUSE_INTERVAL 2
  195. #define JOYSTICK_INTERFACE 4 // Joystick
  196. #define JOYSTICK_ENDPOINT 6
  197. #define JOYSTICK_SIZE 16
  198. #define JOYSTICK_INTERVAL 1
  199. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  200. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  201. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  202. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  203. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  204. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  205. #define ENDPOINT7_CONFIG ENDPOINT_TRANSIMIT_ONLY
  206. #elif defined(USB_MIDI)
  207. #define VENDOR_ID 0x16C0
  208. #define PRODUCT_ID 0x0485
  209. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  210. #define MANUFACTURER_NAME_LEN 11
  211. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','I','D','I'}
  212. #define PRODUCT_NAME_LEN 11
  213. #define EP0_SIZE 64
  214. #define NUM_ENDPOINTS 4
  215. #define NUM_USB_BUFFERS 16
  216. #define NUM_INTERFACE 2
  217. #define SEREMU_INTERFACE 1 // Serial emulation
  218. #define SEREMU_TX_ENDPOINT 1
  219. #define SEREMU_TX_SIZE 64
  220. #define SEREMU_TX_INTERVAL 1
  221. #define SEREMU_RX_ENDPOINT 2
  222. #define SEREMU_RX_SIZE 32
  223. #define SEREMU_RX_INTERVAL 2
  224. #define MIDI_INTERFACE 0 // MIDI
  225. #define MIDI_TX_ENDPOINT 3
  226. #define MIDI_TX_SIZE 64
  227. #define MIDI_RX_ENDPOINT 4
  228. #define MIDI_RX_SIZE 64
  229. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  230. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  231. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  232. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  233. #elif defined(USB_RAWHID)
  234. #define VENDOR_ID 0x16C0
  235. #define PRODUCT_ID 0x0486
  236. #define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
  237. #define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
  238. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  239. #define MANUFACTURER_NAME_LEN 11
  240. #define PRODUCT_NAME {'T','e','e','n','s','y','d','u','i','n','o',' ','R','a','w','H','I','D'}
  241. #define PRODUCT_NAME_LEN 18
  242. #define EP0_SIZE 64
  243. #define NUM_ENDPOINTS 4
  244. #define NUM_USB_BUFFERS 12
  245. #define NUM_INTERFACE 2
  246. #define RAWHID_INTERFACE 0 // RawHID
  247. #define RAWHID_TX_ENDPOINT 3
  248. #define RAWHID_TX_SIZE 64
  249. #define RAWHID_TX_INTERVAL 1
  250. #define RAWHID_RX_ENDPOINT 4
  251. #define RAWHID_RX_SIZE 64
  252. #define RAWHID_RX_INTERVAL 1
  253. #define SEREMU_INTERFACE 1 // Serial emulation
  254. #define SEREMU_TX_ENDPOINT 1
  255. #define SEREMU_TX_SIZE 64
  256. #define SEREMU_TX_INTERVAL 1
  257. #define SEREMU_RX_ENDPOINT 2
  258. #define SEREMU_RX_SIZE 32
  259. #define SEREMU_RX_INTERVAL 2
  260. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  261. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  262. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  263. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  264. #elif defined(USB_FLIGHTSIM)
  265. #define VENDOR_ID 0x16C0
  266. #define PRODUCT_ID 0x0488
  267. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  268. #define MANUFACTURER_NAME_LEN 11
  269. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','F','l','i','g','h','t',' ','S','i','m',' ','C','o','n','t','r','o','l','s'}
  270. #define PRODUCT_NAME_LEN 26
  271. #define EP0_SIZE 64
  272. #define NUM_ENDPOINTS 4
  273. #define NUM_USB_BUFFERS 20
  274. #define NUM_INTERFACE 2
  275. #define FLIGHTSIM_INTERFACE 0 // Flight Sim Control
  276. #define FLIGHTSIM_TX_ENDPOINT 3
  277. #define FLIGHTSIM_TX_SIZE 64
  278. #define FLIGHTSIM_TX_INTERVAL 1
  279. #define FLIGHTSIM_RX_ENDPOINT 4
  280. #define FLIGHTSIM_RX_SIZE 64
  281. #define FLIGHTSIM_RX_INTERVAL 1
  282. #define SEREMU_INTERFACE 1 // Serial emulation
  283. #define SEREMU_TX_ENDPOINT 1
  284. #define SEREMU_TX_SIZE 64
  285. #define SEREMU_TX_INTERVAL 1
  286. #define SEREMU_RX_ENDPOINT 2
  287. #define SEREMU_RX_SIZE 32
  288. #define SEREMU_RX_INTERVAL 2
  289. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  290. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  291. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  292. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  293. #elif defined(USB_MTPDISK)
  294. #define VENDOR_ID 0x16C0
  295. #define PRODUCT_ID 0x0489
  296. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  297. #define MANUFACTURER_NAME_LEN 11
  298. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','T','P',' ','D','i','s','k'}
  299. #define PRODUCT_NAME_LEN 15
  300. #define EP0_SIZE 64
  301. #define NUM_ENDPOINTS 4
  302. #define NUM_USB_BUFFERS 20
  303. #define NUM_INTERFACE 2
  304. #define MTP_INTERFACE 0 // MTP Disk
  305. #define MTP_TX_ENDPOINT 3
  306. #define MTP_TX_SIZE 64
  307. #define MTP_RX_ENDPOINT 3
  308. #define MTP_RX_SIZE 64
  309. #define MTP_EVENT_ENDPOINT 4
  310. #define MTP_EVENT_SIZE 16
  311. #define MTP_EVENT_INTERVAL 10
  312. #define SEREMU_INTERFACE 1 // Serial emulation
  313. #define SEREMU_TX_ENDPOINT 1
  314. #define SEREMU_TX_SIZE 64
  315. #define SEREMU_TX_INTERVAL 1
  316. #define SEREMU_RX_ENDPOINT 2
  317. #define SEREMU_RX_SIZE 32
  318. #define SEREMU_RX_INTERVAL 2
  319. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  320. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  321. #define ENDPOINT3_CONFIG ENDPOINT_TRANSMIT_AND_RECEIVE
  322. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  323. #elif defined(USB_AUDIO)
  324. #define VENDOR_ID 0x16C0
  325. #define PRODUCT_ID 0x0485 // TODO: assign unique
  326. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  327. #define MANUFACTURER_NAME_LEN 11
  328. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','A','u','d','i','o'}
  329. #define PRODUCT_NAME_LEN 12
  330. #define EP0_SIZE 64
  331. #define NUM_ENDPOINTS 5
  332. #define NUM_USB_BUFFERS 16
  333. #define NUM_INTERFACE 4
  334. #define SEREMU_INTERFACE 0 // Serial emulation
  335. #define SEREMU_TX_ENDPOINT 1
  336. #define SEREMU_TX_SIZE 64
  337. #define SEREMU_TX_INTERVAL 1
  338. #define SEREMU_RX_ENDPOINT 2
  339. #define SEREMU_RX_SIZE 32
  340. #define SEREMU_RX_INTERVAL 2
  341. #define AUDIO_INTERFACE 1 // Audio (uses 3 consecutive interfaces)
  342. #define AUDIO_TX_ENDPOINT 3
  343. #define AUDIO_TX_SIZE 180
  344. #define AUDIO_RX_ENDPOINT 4
  345. #define AUDIO_RX_SIZE 180
  346. #define AUDIO_SYNC_ENDPOINT 5
  347. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  348. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  349. #define ENDPOINT3_CONFIG ENDPOINT_TRANSMIT_ISOCHRONOUS
  350. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ISOCHRONOUS
  351. #define ENDPOINT5_CONFIG ENDPOINT_TRANSMIT_ISOCHRONOUS
  352. #endif
  353. #ifdef USB_DESC_LIST_DEFINE
  354. #if defined(NUM_ENDPOINTS) && NUM_ENDPOINTS > 0
  355. // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15)
  356. extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];
  357. typedef struct {
  358. uint16_t wValue;
  359. uint16_t wIndex;
  360. const uint8_t *addr;
  361. uint16_t length;
  362. } usb_descriptor_list_t;
  363. extern const usb_descriptor_list_t usb_descriptor_list[];
  364. #endif // NUM_ENDPOINTS
  365. #endif // USB_DESC_LIST_DEFINE
  366. #endif