No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

330 líneas
13KB

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