Teensy 4.1 core updated for C++20
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.

310 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. To modify a USB Type to have different interfaces, start in this
  44. file. Delete the XYZ_INTERFACE lines for any interfaces you
  45. wish to remove, and copy them from another USB Type for any you
  46. want to add.
  47. Give each interface a unique number, and edit NUM_INTERFACE to
  48. reflect the number of interfaces.
  49. Within each interface, make sure it uses a unique set of endpoints.
  50. Edit NUM_ENDPOINTS to be at least the largest endpoint number used.
  51. Then edit the ENDPOINT*_CONFIG lines so each endpoint is configured
  52. the proper way (transmit, receive, or both).
  53. The CONFIG_DESC_SIZE and any XYZ_DESC_OFFSET numbers must be
  54. edited to the correct sizes. See usb_desc.c for the giant array
  55. of bytes. Someday these may be done automatically..... (but how?)
  56. If you are using existing interfaces, the code in each file should
  57. automatically adapt to the changes you specify. If you need to
  58. create a new type of interface, you'll need to write the code which
  59. sends and receives packets, and presents an API to the user.
  60. Finally, edit usb_inst.cpp, which creats instances of the C++
  61. objects for each combination.
  62. Some operating systems, especially Windows, may cache USB device
  63. info. Changes to the device name may not update on the same
  64. computer unless the vendor or product ID numbers change, or the
  65. "bcdDevice" revision code is increased.
  66. If these instructions are missing steps or could be improved, please
  67. let me know? http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
  68. */
  69. #if defined(USB_SERIAL)
  70. #define VENDOR_ID 0x16C0
  71. #define PRODUCT_ID 0x0483
  72. #define DEVICE_CLASS 2 // 2 = Communication Class
  73. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  74. #define MANUFACTURER_NAME_LEN 11
  75. #define PRODUCT_NAME {'U','S','B',' ','S','e','r','i','a','l'}
  76. #define PRODUCT_NAME_LEN 10
  77. #define EP0_SIZE 64
  78. #define NUM_ENDPOINTS 4
  79. #define NUM_USB_BUFFERS 12
  80. #define NUM_INTERFACE 2
  81. #define CDC_STATUS_INTERFACE 0
  82. #define CDC_DATA_INTERFACE 1
  83. #define CDC_ACM_ENDPOINT 2
  84. #define CDC_RX_ENDPOINT 3
  85. #define CDC_TX_ENDPOINT 4
  86. #define CDC_ACM_SIZE 16
  87. #define CDC_RX_SIZE 64
  88. #define CDC_TX_SIZE 64
  89. #define CONFIG_DESC_SIZE (9+9+5+5+4+5+7+9+7+7)
  90. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  91. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  92. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  93. #elif defined(USB_HID)
  94. #define VENDOR_ID 0x16C0
  95. #define PRODUCT_ID 0x0482
  96. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  97. #define MANUFACTURER_NAME_LEN 11
  98. #define PRODUCT_NAME {'K','e','y','b','o','a','r','d','/','M','o','u','s','e','/','J','o','y','s','t','i','c','k'}
  99. #define PRODUCT_NAME_LEN 23
  100. #define EP0_SIZE 64
  101. #define NUM_ENDPOINTS 5
  102. #define NUM_USB_BUFFERS 24
  103. #define NUM_INTERFACE 4
  104. #define SEREMU_INTERFACE 2 // Serial emulation
  105. #define SEREMU_TX_ENDPOINT 1
  106. #define SEREMU_TX_SIZE 64
  107. #define SEREMU_TX_INTERVAL 1
  108. #define SEREMU_RX_ENDPOINT 2
  109. #define SEREMU_RX_SIZE 32
  110. #define SEREMU_RX_INTERVAL 2
  111. #define KEYBOARD_INTERFACE 0 // Keyboard
  112. #define KEYBOARD_ENDPOINT 3
  113. #define KEYBOARD_SIZE 8
  114. #define KEYBOARD_INTERVAL 1
  115. #define MOUSE_INTERFACE 1 // Mouse
  116. #define MOUSE_ENDPOINT 5
  117. #define MOUSE_SIZE 8
  118. #define MOUSE_INTERVAL 1
  119. #define JOYSTICK_INTERFACE 3 // Joystick
  120. #define JOYSTICK_ENDPOINT 4
  121. #define JOYSTICK_SIZE 16
  122. #define JOYSTICK_INTERVAL 2
  123. #define KEYBOARD_DESC_OFFSET (9 + 9)
  124. #define MOUSE_DESC_OFFSET (9 + 9+9+7 + 9)
  125. #define SEREMU_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 9)
  126. #define JOYSTICK_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 9+9+7+7 + 9)
  127. #define CONFIG_DESC_SIZE (9 + 9+9+7 + 9+9+7 + 9+9+7+7 + 9+9+7)
  128. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  129. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  130. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  131. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  132. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  133. #elif defined(USB_SERIAL_HID)
  134. #define VENDOR_ID 0x16C0
  135. #define PRODUCT_ID 0x0487
  136. #define DEVICE_CLASS 0xEF
  137. #define DEVICE_SUBCLASS 0x02
  138. #define DEVICE_PROTOCOL 0x01
  139. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  140. #define MANUFACTURER_NAME_LEN 11
  141. #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'}
  142. #define PRODUCT_NAME_LEN 30
  143. #define EP0_SIZE 64
  144. #define NUM_ENDPOINTS 6
  145. #define NUM_USB_BUFFERS 30
  146. #define NUM_INTERFACE 5
  147. #define CDC_IAD_DESCRIPTOR 1
  148. #define CDC_STATUS_INTERFACE 0
  149. #define CDC_DATA_INTERFACE 1 // Serial
  150. #define CDC_ACM_ENDPOINT 2
  151. #define CDC_RX_ENDPOINT 3
  152. #define CDC_TX_ENDPOINT 4
  153. #define CDC_ACM_SIZE 16
  154. #define CDC_RX_SIZE 64
  155. #define CDC_TX_SIZE 64
  156. #define KEYBOARD_INTERFACE 2 // Keyboard
  157. #define KEYBOARD_ENDPOINT 1
  158. #define KEYBOARD_SIZE 8
  159. #define KEYBOARD_INTERVAL 1
  160. #define MOUSE_INTERFACE 3 // Mouse
  161. #define MOUSE_ENDPOINT 5
  162. #define MOUSE_SIZE 8
  163. #define MOUSE_INTERVAL 2
  164. #define JOYSTICK_INTERFACE 4 // Joystick
  165. #define JOYSTICK_ENDPOINT 6
  166. #define JOYSTICK_SIZE 16
  167. #define JOYSTICK_INTERVAL 1
  168. #define KEYBOARD_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9)
  169. #define MOUSE_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9)
  170. #define JOYSTICK_DESC_OFFSET (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9)
  171. #define CONFIG_DESC_SIZE (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9+9+7)
  172. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  173. #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
  174. #define ENDPOINT3_CONFIG ENDPOINT_RECEIVE_ONLY
  175. #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
  176. #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY
  177. #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
  178. #elif defined(USB_MIDI)
  179. #define VENDOR_ID 0x16C0
  180. #define PRODUCT_ID 0x0485
  181. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  182. #define MANUFACTURER_NAME_LEN 11
  183. #define PRODUCT_NAME {'T','e','e','n','s','y',' ','M','I','D','I'}
  184. #define PRODUCT_NAME_LEN 11
  185. #define EP0_SIZE 64
  186. #define NUM_ENDPOINTS 4
  187. #define NUM_USB_BUFFERS 16
  188. #define NUM_INTERFACE 2
  189. #define SEREMU_INTERFACE 1 // Serial emulation
  190. #define SEREMU_TX_ENDPOINT 1
  191. #define SEREMU_TX_SIZE 64
  192. #define SEREMU_TX_INTERVAL 1
  193. #define SEREMU_RX_ENDPOINT 2
  194. #define SEREMU_RX_SIZE 32
  195. #define SEREMU_RX_INTERVAL 2
  196. #define MIDI_INTERFACE 0 // MIDI
  197. #define MIDI_TX_ENDPOINT 3
  198. #define MIDI_TX_SIZE 64
  199. #define MIDI_RX_ENDPOINT 4
  200. #define MIDI_RX_SIZE 64
  201. #define SEREMU_DESC_OFFSET (9 + 9+7+6+6+9+9+9+5+9+5 + 9)
  202. #define CONFIG_DESC_SIZE (9 + 9+7+6+6+9+9+9+5+9+5 + 9+9+7+7)
  203. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  204. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  205. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  206. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  207. #elif defined(USB_RAWHID)
  208. #define VENDOR_ID 0x16C0
  209. #define PRODUCT_ID 0x0486
  210. #define RAWHID_USAGE_PAGE 0xFFAB // recommended: 0xFF00 to 0xFFFF
  211. #define RAWHID_USAGE 0x0200 // recommended: 0x0100 to 0xFFFF
  212. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  213. #define MANUFACTURER_NAME_LEN 11
  214. #define PRODUCT_NAME {'T','e','e','n','s','y','d','u','i','n','o',' ','R','a','w','H','I','D'}
  215. #define PRODUCT_NAME_LEN 18
  216. #define EP0_SIZE 64
  217. #define NUM_ENDPOINTS 6
  218. #define NUM_USB_BUFFERS 12
  219. #define NUM_INTERFACE 2
  220. #define RAWHID_INTERFACE 0 // RawHID
  221. #define RAWHID_TX_ENDPOINT 3
  222. #define RAWHID_TX_SIZE 64
  223. #define RAWHID_TX_INTERVAL 1
  224. #define RAWHID_RX_ENDPOINT 4
  225. #define RAWHID_RX_SIZE 64
  226. #define RAWHID_RX_INTERVAL 1
  227. #define SEREMU_INTERFACE 1 // Serial emulation
  228. #define SEREMU_TX_ENDPOINT 1
  229. #define SEREMU_TX_SIZE 64
  230. #define SEREMU_TX_INTERVAL 1
  231. #define SEREMU_RX_ENDPOINT 2
  232. #define SEREMU_RX_SIZE 32
  233. #define SEREMU_RX_INTERVAL 2
  234. #define RAWHID_DESC_OFFSET (9 + 9)
  235. #define SEREMU_DESC_OFFSET (9 + 9+9+7+7 + 9)
  236. #define CONFIG_DESC_SIZE (9 + 9+9+7+7 + 9+9+7+7)
  237. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  238. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  239. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  240. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  241. #elif defined(USB_FLIGHTSIM)
  242. #define VENDOR_ID 0x16C0
  243. #define PRODUCT_ID 0x0488
  244. #define MANUFACTURER_NAME {'T','e','e','n','s','y','d','u','i','n','o'}
  245. #define MANUFACTURER_NAME_LEN 11
  246. #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'}
  247. #define PRODUCT_NAME_LEN 26
  248. #define EP0_SIZE 64
  249. #define NUM_ENDPOINTS 4
  250. #define NUM_USB_BUFFERS 20
  251. #define NUM_INTERFACE 2
  252. #define FLIGHTSIM_INTERFACE 0 // Flight Sim Control
  253. #define FLIGHTSIM_TX_ENDPOINT 3
  254. #define FLIGHTSIM_TX_SIZE 64
  255. #define FLIGHTSIM_TX_INTERVAL 1
  256. #define FLIGHTSIM_RX_ENDPOINT 4
  257. #define FLIGHTSIM_RX_SIZE 64
  258. #define FLIGHTSIM_RX_INTERVAL 1
  259. #define SEREMU_INTERFACE 1 // Serial emulation
  260. #define SEREMU_TX_ENDPOINT 1
  261. #define SEREMU_TX_SIZE 64
  262. #define SEREMU_TX_INTERVAL 1
  263. #define SEREMU_RX_ENDPOINT 2
  264. #define SEREMU_RX_SIZE 32
  265. #define SEREMU_RX_INTERVAL 2
  266. #define FLIGHTSIM_DESC_OFFSET (9 + 9)
  267. #define SEREMU_DESC_OFFSET (9 + 9+9+7+7 + 9)
  268. #define CONFIG_DESC_SIZE (9 + 9+9+7+7 + 9+9+7+7)
  269. #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
  270. #define ENDPOINT2_CONFIG ENDPOINT_RECEIVE_ONLY
  271. #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
  272. #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY
  273. #endif
  274. // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15)
  275. extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];
  276. typedef struct {
  277. uint16_t wValue;
  278. uint16_t wIndex;
  279. const uint8_t *addr;
  280. uint16_t length;
  281. } usb_descriptor_list_t;
  282. extern const usb_descriptor_list_t usb_descriptor_list[];
  283. #endif