Teensy 4.1 core updated for C++20
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

326 lines
12KB

  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 5
  127. #define NUM_USB_BUFFERS 24
  128. #define NUM_INTERFACE 4
  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 MOUSE_INTERFACE 1 // Mouse
  141. #define MOUSE_ENDPOINT 5
  142. #define MOUSE_SIZE 8
  143. #define MOUSE_INTERVAL 1
  144. #define JOYSTICK_INTERFACE 3 // Joystick
  145. #define JOYSTICK_ENDPOINT 4
  146. #define JOYSTICK_SIZE 16
  147. #define JOYSTICK_INTERVAL 2
  148. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  149. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  150. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  151. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  152. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  153. #elif defined(USB_SERIAL_HID)
  154. #define VENDOR_ID 0x16C0
  155. #define PRODUCT_ID 0x0487
  156. #define DEVICE_CLASS 0xEF
  157. #define DEVICE_SUBCLASS 0x02
  158. #define DEVICE_PROTOCOL 0x01
  159. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  160. #define MANUFACTURER_NAME_LEN 11
  161. #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'}
  162. #define PRODUCT_NAME_LEN 30
  163. #define EP0_SIZE 64
  164. #define NUM_ENDPOINTS 6
  165. #define NUM_USB_BUFFERS 30
  166. #define NUM_INTERFACE 5
  167. #define CDC_IAD_DESCRIPTOR 1
  168. #define CDC_STATUS_INTERFACE 0
  169. #define CDC_DATA_INTERFACE 1 // Serial
  170. #define CDC_ACM_ENDPOINT 2
  171. #define CDC_RX_ENDPOINT 3
  172. #define CDC_TX_ENDPOINT 4
  173. #define CDC_ACM_SIZE 16
  174. #define CDC_RX_SIZE 64
  175. #define CDC_TX_SIZE 64
  176. #define KEYBOARD_INTERFACE 2 // Keyboard
  177. #define KEYBOARD_ENDPOINT 1
  178. #define KEYBOARD_SIZE 8
  179. #define KEYBOARD_INTERVAL 1
  180. #define MOUSE_INTERFACE 3 // Mouse
  181. #define MOUSE_ENDPOINT 5
  182. #define MOUSE_SIZE 8
  183. #define MOUSE_INTERVAL 2
  184. #define JOYSTICK_INTERFACE 4 // Joystick
  185. #define JOYSTICK_ENDPOINT 6
  186. #define JOYSTICK_SIZE 16
  187. #define JOYSTICK_INTERVAL 1
  188. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  189. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  190. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  191. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  192. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  193. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  194. #elif defined(USB_MIDI)
  195. #define VENDOR_ID 0x16C0
  196. #define PRODUCT_ID 0x0485
  197. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  198. #define MANUFACTURER_NAME_LEN 11
  199. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','I','D','I'}
  200. #define PRODUCT_NAME_LEN 11
  201. #define EP0_SIZE 64
  202. #define NUM_ENDPOINTS 4
  203. #define NUM_USB_BUFFERS 16
  204. #define NUM_INTERFACE 2
  205. #define SEREMU_INTERFACE 1 // Serial emulation
  206. #define SEREMU_TX_ENDPOINT 1
  207. #define SEREMU_TX_SIZE 64
  208. #define SEREMU_TX_INTERVAL 1
  209. #define SEREMU_RX_ENDPOINT 2
  210. #define SEREMU_RX_SIZE 32
  211. #define SEREMU_RX_INTERVAL 2
  212. #define MIDI_INTERFACE 0 // MIDI
  213. #define MIDI_TX_ENDPOINT 3
  214. #define MIDI_TX_SIZE 64
  215. #define MIDI_RX_ENDPOINT 4
  216. #define MIDI_RX_SIZE 64
  217. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  218. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  219. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  220. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  221. #elif defined(USB_RAWHID)
  222. #define VENDOR_ID 0x16C0
  223. #define PRODUCT_ID 0x0486
  224. #define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
  225. #define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
  226. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  227. #define MANUFACTURER_NAME_LEN 11
  228. #define PRODUCT_NAME {'T','e','e','n','s','y','d','u','i','n','o',' ','R','a','w','H','I','D'}
  229. #define PRODUCT_NAME_LEN 18
  230. #define EP0_SIZE 64
  231. #define NUM_ENDPOINTS 6
  232. #define NUM_USB_BUFFERS 12
  233. #define NUM_INTERFACE 2
  234. #define RAWHID_INTERFACE 0 // RawHID
  235. #define RAWHID_TX_ENDPOINT 3
  236. #define RAWHID_TX_SIZE 64
  237. #define RAWHID_TX_INTERVAL 1
  238. #define RAWHID_RX_ENDPOINT 4
  239. #define RAWHID_RX_SIZE 64
  240. #define RAWHID_RX_INTERVAL 1
  241. #define SEREMU_INTERFACE 1 // Serial emulation
  242. #define SEREMU_TX_ENDPOINT 1
  243. #define SEREMU_TX_SIZE 64
  244. #define SEREMU_TX_INTERVAL 1
  245. #define SEREMU_RX_ENDPOINT 2
  246. #define SEREMU_RX_SIZE 32
  247. #define SEREMU_RX_INTERVAL 2
  248. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  249. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  250. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  251. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  252. #elif defined(USB_FLIGHTSIM)
  253. #define VENDOR_ID 0x16C0
  254. #define PRODUCT_ID 0x0488
  255. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  256. #define MANUFACTURER_NAME_LEN 11
  257. #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'}
  258. #define PRODUCT_NAME_LEN 26
  259. #define EP0_SIZE 64
  260. #define NUM_ENDPOINTS 4
  261. #define NUM_USB_BUFFERS 20
  262. #define NUM_INTERFACE 2
  263. #define FLIGHTSIM_INTERFACE 0 // Flight Sim Control
  264. #define FLIGHTSIM_TX_ENDPOINT 3
  265. #define FLIGHTSIM_TX_SIZE 64
  266. #define FLIGHTSIM_TX_INTERVAL 1
  267. #define FLIGHTSIM_RX_ENDPOINT 4
  268. #define FLIGHTSIM_RX_SIZE 64
  269. #define FLIGHTSIM_RX_INTERVAL 1
  270. #define SEREMU_INTERFACE 1 // Serial emulation
  271. #define SEREMU_TX_ENDPOINT 1
  272. #define SEREMU_TX_SIZE 64
  273. #define SEREMU_TX_INTERVAL 1
  274. #define SEREMU_RX_ENDPOINT 2
  275. #define SEREMU_RX_SIZE 32
  276. #define SEREMU_RX_INTERVAL 2
  277. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  278. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  279. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  280. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  281. #endif
  282. #ifdef USB_DESC_LIST_DEFINE
  283. #if defined(NUM_ENDPOINTS) && NUM_ENDPOINTS > 0
  284. // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15)
  285. extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];
  286. typedef struct {
  287. uint16_t wValue;
  288. uint16_t wIndex;
  289. const uint8_t *addr;
  290. uint16_t length;
  291. } usb_descriptor_list_t;
  292. extern const usb_descriptor_list_t usb_descriptor_list[];
  293. #endif // NUM_ENDPOINTS
  294. #endif // USB_DESC_LIST_DEFINE
  295. #endif