Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

10 роки тому
10 роки тому
9 роки тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. /*
  43. Each group of #define lines below corresponds to one of the
  44. settings in the Tools > USB Type menu. This file defines what
  45. type of USB device is actually created for each of those menu
  46. options.
  47. Each "interface" is a set of functionality your PC or Mac will
  48. use and treat as if it is a unique device. Within each interface,
  49. the "endpoints" are the actual communication channels. Most
  50. interfaces use 1, 2 or 3 endpoints. By editing only this file,
  51. you can customize the USB Types to be any collection of interfaces.
  52. To modify a USB Type, delete the XYZ_INTERFACE lines for any
  53. interfaces you wish to remove, and copy them from another USB Type
  54. for any you want to add.
  55. Give each interface a unique number, and edit NUM_INTERFACE to
  56. reflect the total number of interfaces.
  57. Next, assign unique endpoint numbers to all the endpoints across
  58. all the interfaces your device has. You can reuse an endpoint
  59. number for transmit and receive, but the same endpoint number must
  60. not be used twice to transmit, or twice to receive.
  61. Most endpoints also require their maximum size, and some also
  62. need an interval specification (the number of milliseconds the
  63. PC will check for data from that endpoint). For existing
  64. interfaces, usually these other settings should not be changed.
  65. Edit NUM_ENDPOINTS to be at least the largest endpoint number used.
  66. Edit NUM_USB_BUFFERS to control how much memory the USB stack will
  67. allocate. At least 2 should be used for each endpoint. More
  68. memory will allow higher throughput for user programs that have
  69. high latency (eg, spending time doing things other than interacting
  70. with the USB).
  71. Edit the ENDPOINT*_CONFIG lines so each endpoint is configured
  72. the proper way (transmit, receive, or both).
  73. If you are using existing interfaces (making your own device with
  74. a different set of interfaces) the code in all other files should
  75. automatically adapt to the new endpoints you specify here.
  76. If you need to create a new type of interface, you'll need to write
  77. the code which sends and receives packets, and presents an API to
  78. the user. Usually, a pair of files are added for the actual code,
  79. and code is also added in usb_dev.c for any control transfers,
  80. interrupt-level code, or other very low-level stuff not possible
  81. from the packet send/receive functons. Code also is added in
  82. usb_inst.c to create an instance of your C++ object.
  83. You may edit the Vendor and Product ID numbers, and strings. If
  84. the numbers are changed, Teensyduino may not be able to automatically
  85. find and reboot your board when you click the Upload button in
  86. the Arduino IDE. You will need to press the Program button on
  87. Teensy to initiate programming.
  88. Some operating systems, especially Windows, may cache USB device
  89. info. Changes to the device name may not update on the same
  90. computer unless the vendor or product ID numbers change, or the
  91. "bcdDevice" revision code is increased.
  92. If these instructions are missing steps or could be improved, please
  93. let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
  94. */
  95. #if defined(USB_SERIAL)
  96. #define VENDOR_ID 0x16C0
  97. #define PRODUCT_ID 0x0483
  98. #define DEVICE_CLASS 2 // 2 = Communication Class
  99. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  100. #define MANUFACTURER_NAME_LEN 11
  101. #define PRODUCT_NAME {'U','S','B',' ','S','e','r','i','a','l'}
  102. #define PRODUCT_NAME_LEN 10
  103. #define EP0_SIZE 64
  104. #define NUM_ENDPOINTS 4
  105. #define NUM_USB_BUFFERS 12
  106. #define NUM_INTERFACE 2
  107. #define CDC_STATUS_INTERFACE 0
  108. #define CDC_DATA_INTERFACE 1
  109. #define CDC_ACM_ENDPOINT 2
  110. #define CDC_RX_ENDPOINT 3
  111. #define CDC_TX_ENDPOINT 4
  112. #define CDC_ACM_SIZE 16
  113. #define CDC_RX_SIZE 64
  114. #define CDC_TX_SIZE 64
  115. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  116. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  117. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  118. #elif defined(USB_HID)
  119. #define VENDOR_ID 0x16C0
  120. #define PRODUCT_ID 0x0482
  121. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  122. #define MANUFACTURER_NAME_LEN 11
  123. #define PRODUCT_NAME {'K','e','y','b','o','a','r','d','/','M','o','u','s','e','/','J','o','y','s','t','i','c','k'}
  124. #define PRODUCT_NAME_LEN 23
  125. #define EP0_SIZE 64
  126. #define NUM_ENDPOINTS 6
  127. #define NUM_USB_BUFFERS 24
  128. #define NUM_INTERFACE 5
  129. #define SEREMU_INTERFACE 2 // Serial emulation
  130. #define SEREMU_TX_ENDPOINT 1
  131. #define SEREMU_TX_SIZE 64
  132. #define SEREMU_TX_INTERVAL 1
  133. #define SEREMU_RX_ENDPOINT 2
  134. #define SEREMU_RX_SIZE 32
  135. #define SEREMU_RX_INTERVAL 2
  136. #define KEYBOARD_INTERFACE 0 // Keyboard
  137. #define KEYBOARD_ENDPOINT 3
  138. #define KEYBOARD_SIZE 8
  139. #define KEYBOARD_INTERVAL 1
  140. #define KEYMEDIA_INTERFACE 4 // Keyboard Media Keys
  141. #define KEYMEDIA_ENDPOINT 6
  142. #define KEYMEDIA_SIZE 8
  143. #define KEYMEDIA_INTERVAL 4
  144. #define MOUSE_INTERFACE 1 // Mouse
  145. #define MOUSE_ENDPOINT 5
  146. #define MOUSE_SIZE 8
  147. #define MOUSE_INTERVAL 1
  148. #define JOYSTICK_INTERFACE 3 // Joystick
  149. #define JOYSTICK_ENDPOINT 4
  150. #define JOYSTICK_SIZE 16
  151. #define JOYSTICK_INTERVAL 2
  152. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  153. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  154. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  155. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  156. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  157. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  158. #elif defined(USB_SERIAL_HID)
  159. #define VENDOR_ID 0x16C0
  160. #define PRODUCT_ID 0x0487
  161. #define DEVICE_CLASS 0xEF
  162. #define DEVICE_SUBCLASS 0x02
  163. #define DEVICE_PROTOCOL 0x01
  164. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  165. #define MANUFACTURER_NAME_LEN 11
  166. #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'}
  167. #define PRODUCT_NAME_LEN 30
  168. #define EP0_SIZE 64
  169. #define NUM_ENDPOINTS 6
  170. #define NUM_USB_BUFFERS 30
  171. #define NUM_INTERFACE 5
  172. #define CDC_IAD_DESCRIPTOR 1
  173. #define CDC_STATUS_INTERFACE 0
  174. #define CDC_DATA_INTERFACE 1 // Serial
  175. #define CDC_ACM_ENDPOINT 2
  176. #define CDC_RX_ENDPOINT 3
  177. #define CDC_TX_ENDPOINT 4
  178. #define CDC_ACM_SIZE 16
  179. #define CDC_RX_SIZE 64
  180. #define CDC_TX_SIZE 64
  181. #define KEYBOARD_INTERFACE 2 // Keyboard
  182. #define KEYBOARD_ENDPOINT 1
  183. #define KEYBOARD_SIZE 8
  184. #define KEYBOARD_INTERVAL 1
  185. #define MOUSE_INTERFACE 3 // Mouse
  186. #define MOUSE_ENDPOINT 5
  187. #define MOUSE_SIZE 8
  188. #define MOUSE_INTERVAL 2
  189. #define JOYSTICK_INTERFACE 4 // Joystick
  190. #define JOYSTICK_ENDPOINT 6
  191. #define JOYSTICK_SIZE 16
  192. #define JOYSTICK_INTERVAL 1
  193. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  194. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  195. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  196. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  197. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  198. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  199. #elif defined(USB_MIDI)
  200. #define VENDOR_ID 0x16C0
  201. #define PRODUCT_ID 0x0485
  202. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  203. #define MANUFACTURER_NAME_LEN 11
  204. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','I','D','I'}
  205. #define PRODUCT_NAME_LEN 11
  206. #define EP0_SIZE 64
  207. #define NUM_ENDPOINTS 4
  208. #define NUM_USB_BUFFERS 16
  209. #define NUM_INTERFACE 2
  210. #define SEREMU_INTERFACE 1 // Serial emulation
  211. #define SEREMU_TX_ENDPOINT 1
  212. #define SEREMU_TX_SIZE 64
  213. #define SEREMU_TX_INTERVAL 1
  214. #define SEREMU_RX_ENDPOINT 2
  215. #define SEREMU_RX_SIZE 32
  216. #define SEREMU_RX_INTERVAL 2
  217. #define MIDI_INTERFACE 0 // MIDI
  218. #define MIDI_TX_ENDPOINT 3
  219. #define MIDI_TX_SIZE 64
  220. #define MIDI_RX_ENDPOINT 4
  221. #define MIDI_RX_SIZE 64
  222. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  223. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  224. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  225. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  226. #elif defined(USB_RAWHID)
  227. #define VENDOR_ID 0x16C0
  228. #define PRODUCT_ID 0x0486
  229. #define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
  230. #define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
  231. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  232. #define MANUFACTURER_NAME_LEN 11
  233. #define PRODUCT_NAME {'T','e','e','n','s','y','d','u','i','n','o',' ','R','a','w','H','I','D'}
  234. #define PRODUCT_NAME_LEN 18
  235. #define EP0_SIZE 64
  236. #define NUM_ENDPOINTS 4
  237. #define NUM_USB_BUFFERS 12
  238. #define NUM_INTERFACE 2
  239. #define RAWHID_INTERFACE 0 // RawHID
  240. #define RAWHID_TX_ENDPOINT 3
  241. #define RAWHID_TX_SIZE 64
  242. #define RAWHID_TX_INTERVAL 1
  243. #define RAWHID_RX_ENDPOINT 4
  244. #define RAWHID_RX_SIZE 64
  245. #define RAWHID_RX_INTERVAL 1
  246. #define SEREMU_INTERFACE 1 // Serial emulation
  247. #define SEREMU_TX_ENDPOINT 1
  248. #define SEREMU_TX_SIZE 64
  249. #define SEREMU_TX_INTERVAL 1
  250. #define SEREMU_RX_ENDPOINT 2
  251. #define SEREMU_RX_SIZE 32
  252. #define SEREMU_RX_INTERVAL 2
  253. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  254. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  255. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  256. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  257. #elif defined(USB_FLIGHTSIM)
  258. #define VENDOR_ID 0x16C0
  259. #define PRODUCT_ID 0x0488
  260. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  261. #define MANUFACTURER_NAME_LEN 11
  262. #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'}
  263. #define PRODUCT_NAME_LEN 26
  264. #define EP0_SIZE 64
  265. #define NUM_ENDPOINTS 4
  266. #define NUM_USB_BUFFERS 20
  267. #define NUM_INTERFACE 2
  268. #define FLIGHTSIM_INTERFACE 0 // Flight Sim Control
  269. #define FLIGHTSIM_TX_ENDPOINT 3
  270. #define FLIGHTSIM_TX_SIZE 64
  271. #define FLIGHTSIM_TX_INTERVAL 1
  272. #define FLIGHTSIM_RX_ENDPOINT 4
  273. #define FLIGHTSIM_RX_SIZE 64
  274. #define FLIGHTSIM_RX_INTERVAL 1
  275. #define SEREMU_INTERFACE 1 // Serial emulation
  276. #define SEREMU_TX_ENDPOINT 1
  277. #define SEREMU_TX_SIZE 64
  278. #define SEREMU_TX_INTERVAL 1
  279. #define SEREMU_RX_ENDPOINT 2
  280. #define SEREMU_RX_SIZE 32
  281. #define SEREMU_RX_INTERVAL 2
  282. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  283. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  284. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  285. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  286. #elif defined(USB_MTPDISK)
  287. #define VENDOR_ID 0x16C0
  288. #define PRODUCT_ID 0x0489
  289. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  290. #define MANUFACTURER_NAME_LEN 11
  291. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','T','P',' ','D','i','s','k'}
  292. #define PRODUCT_NAME_LEN 15
  293. #define EP0_SIZE 64
  294. #define NUM_ENDPOINTS 4
  295. #define NUM_USB_BUFFERS 20
  296. #define NUM_INTERFACE 2
  297. #define MTP_INTERFACE 0 // MTP Disk
  298. #define MTP_TX_ENDPOINT 3
  299. #define MTP_TX_SIZE 64
  300. #define MTP_RX_ENDPOINT 3
  301. #define MTP_RX_SIZE 64
  302. #define MTP_EVENT_ENDPOINT 4
  303. #define MTP_EVENT_SIZE 16
  304. #define MTP_EVENT_INTERVAL 10
  305. #define SEREMU_INTERFACE 1 // Serial emulation
  306. #define SEREMU_TX_ENDPOINT 1
  307. #define SEREMU_TX_SIZE 64
  308. #define SEREMU_TX_INTERVAL 1
  309. #define SEREMU_RX_ENDPOINT 2
  310. #define SEREMU_RX_SIZE 32
  311. #define SEREMU_RX_INTERVAL 2
  312. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  313. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  314. #define ENDPOINT3_CONFIG ENDPOINT_TRANSMIT_AND_RECEIVE
  315. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  316. #endif
  317. #ifdef USB_DESC_LIST_DEFINE
  318. #if defined(NUM_ENDPOINTS) && NUM_ENDPOINTS > 0
  319. // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15)
  320. extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];
  321. typedef struct {
  322. uint16_t wValue;
  323. uint16_t wIndex;
  324. const uint8_t *addr;
  325. uint16_t length;
  326. } usb_descriptor_list_t;
  327. extern const usb_descriptor_list_t usb_descriptor_list[];
  328. #endif // NUM_ENDPOINTS
  329. #endif // USB_DESC_LIST_DEFINE
  330. #endif