選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

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