Teensy 4.1 core updated for C++20
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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 6
  172. #define NUM_USB_BUFFERS 30
  173. #define NUM_INTERFACE 5
  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 MOUSE_INTERFACE 3 // Mouse
  188. #define MOUSE_ENDPOINT 5
  189. #define MOUSE_SIZE 8
  190. #define MOUSE_INTERVAL 2
  191. #define JOYSTICK_INTERFACE 4 // Joystick
  192. #define JOYSTICK_ENDPOINT 6
  193. #define JOYSTICK_SIZE 16
  194. #define JOYSTICK_INTERVAL 1
  195. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  196. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  197. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  198. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  199. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  200. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  201. #elif defined(USB_MIDI)
  202. #define VENDOR_ID 0x16C0
  203. #define PRODUCT_ID 0x0485
  204. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  205. #define MANUFACTURER_NAME_LEN 11
  206. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','I','D','I'}
  207. #define PRODUCT_NAME_LEN 11
  208. #define EP0_SIZE 64
  209. #define NUM_ENDPOINTS 4
  210. #define NUM_USB_BUFFERS 16
  211. #define NUM_INTERFACE 2
  212. #define SEREMU_INTERFACE 1 // Serial emulation
  213. #define SEREMU_TX_ENDPOINT 1
  214. #define SEREMU_TX_SIZE 64
  215. #define SEREMU_TX_INTERVAL 1
  216. #define SEREMU_RX_ENDPOINT 2
  217. #define SEREMU_RX_SIZE 32
  218. #define SEREMU_RX_INTERVAL 2
  219. #define MIDI_INTERFACE 0 // MIDI
  220. #define MIDI_TX_ENDPOINT 3
  221. #define MIDI_TX_SIZE 64
  222. #define MIDI_RX_ENDPOINT 4
  223. #define MIDI_RX_SIZE 64
  224. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  225. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  226. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  227. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  228. #elif defined(USB_RAWHID)
  229. #define VENDOR_ID 0x16C0
  230. #define PRODUCT_ID 0x0486
  231. #define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
  232. #define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
  233. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  234. #define MANUFACTURER_NAME_LEN 11
  235. #define PRODUCT_NAME {'T','e','e','n','s','y','d','u','i','n','o',' ','R','a','w','H','I','D'}
  236. #define PRODUCT_NAME_LEN 18
  237. #define EP0_SIZE 64
  238. #define NUM_ENDPOINTS 4
  239. #define NUM_USB_BUFFERS 12
  240. #define NUM_INTERFACE 2
  241. #define RAWHID_INTERFACE 0 // RawHID
  242. #define RAWHID_TX_ENDPOINT 3
  243. #define RAWHID_TX_SIZE 64
  244. #define RAWHID_TX_INTERVAL 1
  245. #define RAWHID_RX_ENDPOINT 4
  246. #define RAWHID_RX_SIZE 64
  247. #define RAWHID_RX_INTERVAL 1
  248. #define SEREMU_INTERFACE 1 // Serial emulation
  249. #define SEREMU_TX_ENDPOINT 1
  250. #define SEREMU_TX_SIZE 64
  251. #define SEREMU_TX_INTERVAL 1
  252. #define SEREMU_RX_ENDPOINT 2
  253. #define SEREMU_RX_SIZE 32
  254. #define SEREMU_RX_INTERVAL 2
  255. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  256. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  257. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  258. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  259. #elif defined(USB_FLIGHTSIM)
  260. #define VENDOR_ID 0x16C0
  261. #define PRODUCT_ID 0x0488
  262. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  263. #define MANUFACTURER_NAME_LEN 11
  264. #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'}
  265. #define PRODUCT_NAME_LEN 26
  266. #define EP0_SIZE 64
  267. #define NUM_ENDPOINTS 4
  268. #define NUM_USB_BUFFERS 20
  269. #define NUM_INTERFACE 2
  270. #define FLIGHTSIM_INTERFACE 0 // Flight Sim Control
  271. #define FLIGHTSIM_TX_ENDPOINT 3
  272. #define FLIGHTSIM_TX_SIZE 64
  273. #define FLIGHTSIM_TX_INTERVAL 1
  274. #define FLIGHTSIM_RX_ENDPOINT 4
  275. #define FLIGHTSIM_RX_SIZE 64
  276. #define FLIGHTSIM_RX_INTERVAL 1
  277. #define SEREMU_INTERFACE 1 // Serial emulation
  278. #define SEREMU_TX_ENDPOINT 1
  279. #define SEREMU_TX_SIZE 64
  280. #define SEREMU_TX_INTERVAL 1
  281. #define SEREMU_RX_ENDPOINT 2
  282. #define SEREMU_RX_SIZE 32
  283. #define SEREMU_RX_INTERVAL 2
  284. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  285. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  286. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  287. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  288. #elif defined(USB_MTPDISK)
  289. #define VENDOR_ID 0x16C0
  290. #define PRODUCT_ID 0x0489
  291. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  292. #define MANUFACTURER_NAME_LEN 11
  293. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','T','P',' ','D','i','s','k'}
  294. #define PRODUCT_NAME_LEN 15
  295. #define EP0_SIZE 64
  296. #define NUM_ENDPOINTS 4
  297. #define NUM_USB_BUFFERS 20
  298. #define NUM_INTERFACE 2
  299. #define MTP_INTERFACE 0 // MTP Disk
  300. #define MTP_TX_ENDPOINT 3
  301. #define MTP_TX_SIZE 64
  302. #define MTP_RX_ENDPOINT 3
  303. #define MTP_RX_SIZE 64
  304. #define MTP_EVENT_ENDPOINT 4
  305. #define MTP_EVENT_SIZE 16
  306. #define MTP_EVENT_INTERVAL 10
  307. #define SEREMU_INTERFACE 1 // Serial emulation
  308. #define SEREMU_TX_ENDPOINT 1
  309. #define SEREMU_TX_SIZE 64
  310. #define SEREMU_TX_INTERVAL 1
  311. #define SEREMU_RX_ENDPOINT 2
  312. #define SEREMU_RX_SIZE 32
  313. #define SEREMU_RX_INTERVAL 2
  314. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  315. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  316. #define ENDPOINT3_CONFIG ENDPOINT_TRANSMIT_AND_RECEIVE
  317. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  318. #elif defined(USB_AUDIO)
  319. #define VENDOR_ID 0x16C0
  320. #define PRODUCT_ID 0x0485 // TODO: assign unique
  321. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  322. #define MANUFACTURER_NAME_LEN 11
  323. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','A','u','d','i','o'}
  324. #define PRODUCT_NAME_LEN 12
  325. #define EP0_SIZE 64
  326. #define NUM_ENDPOINTS 5
  327. #define NUM_USB_BUFFERS 16
  328. #define NUM_INTERFACE 4
  329. #define SEREMU_INTERFACE 3 // Serial emulation
  330. #define SEREMU_TX_ENDPOINT 1
  331. #define SEREMU_TX_SIZE 64
  332. #define SEREMU_TX_INTERVAL 1
  333. #define SEREMU_RX_ENDPOINT 2
  334. #define SEREMU_RX_SIZE 32
  335. #define SEREMU_RX_INTERVAL 2
  336. #define AUDIO_INTERFACE 0 // Audio (uses 3 consecutive interfaces)
  337. #define AUDIO_TX_ENDPOINT 3
  338. #define AUDIO_TX_SIZE 180
  339. #define AUDIO_RX_ENDPOINT 4
  340. #define AUDIO_RX_SIZE 180
  341. #define AUDIO_SYNC_ENDPOINT 5
  342. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  343. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  344. #define ENDPOINT3_CONFIG ENDPOINT_TRANSMIT_ISOCHRONOUS
  345. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ISOCHRONOUS
  346. #define ENDPOINT5_CONFIG ENDPOINT_TRANSMIT_ISOCHRONOUS
  347. #endif
  348. #ifdef USB_DESC_LIST_DEFINE
  349. #if defined(NUM_ENDPOINTS) && NUM_ENDPOINTS > 0
  350. // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15)
  351. extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];
  352. typedef struct {
  353. uint16_t wValue;
  354. uint16_t wIndex;
  355. const uint8_t *addr;
  356. uint16_t length;
  357. } usb_descriptor_list_t;
  358. extern const usb_descriptor_list_t usb_descriptor_list[];
  359. #endif // NUM_ENDPOINTS
  360. #endif // USB_DESC_LIST_DEFINE
  361. #endif