]> git.donarmstrong.com Git - kiibohd-controller.git/blob - Output/pjrcUSB/arm/usb_desc.h
Finished USB for Teensy 3.1 (Now 3.1 compatible!)
[kiibohd-controller.git] / Output / pjrcUSB / arm / usb_desc.h
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
31 #ifndef _usb_desc_h_
32 #define _usb_desc_h_
33
34 // This header is NOT meant to be included when compiling
35 // user sketches in Arduino.  The low-level functions
36 // provided by usb_dev.c are meant to be called only by
37 // code which provides higher-level interfaces to the user.
38
39 #include <stdint.h>
40 #include <stddef.h>
41 #include "output_com.h"
42
43 #define ENDPOINT_UNUSED                 0x00
44 #define ENDPOINT_TRANSIMIT_ONLY         0x15
45 #define ENDPOINT_RECEIVE_ONLY           0x19
46 #define ENDPOINT_TRANSMIT_AND_RECEIVE   0x1D
47
48 /*
49 To modify a USB Type to have different interfaces, start in this
50 file.  Delete the XYZ_INTERFACE lines for any interfaces you
51 wish to remove, and copy them from another USB Type for any you
52 want to add.
53
54 Give each interface a unique number, and edit NUM_INTERFACE to
55 reflect the number of interfaces.
56
57 Within each interface, make sure it uses a unique set of endpoints.
58 Edit NUM_ENDPOINTS to be at least the largest endpoint number used.
59 Then edit the ENDPOINT*_CONFIG lines so each endpoint is configured
60 the proper way (transmit, receive, or both).
61
62 The CONFIG_DESC_SIZE and any XYZ_DESC_OFFSET numbers must be
63 edited to the correct sizes.  See usb_desc.c for the giant array
64 of bytes.  Someday these may be done automatically..... (but how?)
65
66 If you are using existing interfaces, the code in each file should
67 automatically adapt to the changes you specify.  If you need to
68 create a new type of interface, you'll need to write the code which
69 sends and receives packets, and presents an API to the user.
70
71 Finally, edit usb_inst.cpp, which creats instances of the C++
72 objects for each combination.
73
74 Some operating systems, especially Windows, may cache USB device
75 info.  Changes to the device name may not update on the same
76 computer unless the vendor or product ID numbers change, or the
77 "bcdDevice" revision code is increased.
78
79 If these instructions are missing steps or could be improved, please
80 let me know?  http://forum.pjrc.com/forums/4-Suggestions-amp-Bug-Reports
81 */
82
83
84
85 #define DEVICE_CLASS            0xEF
86 #define DEVICE_SUBCLASS 0x02
87 #define DEVICE_PROTOCOL 0x01
88 #define EP0_SIZE                64
89 #define NUM_ENDPOINTS           6
90 #define NUM_USB_BUFFERS 30
91 #define NUM_INTERFACE           4
92 #define CDC_IAD_DESCRIPTOR      1
93 #define CDC_STATUS_INTERFACE    0
94 #define CDC_DATA_INTERFACE      1       // Serial
95 #define CDC_ACM_ENDPOINT        2
96 #define CDC_RX_ENDPOINT       3
97 #define CDC_TX_ENDPOINT       4
98 #define CDC_ACM_SIZE          16
99 #define CDC_RX_SIZE           64
100 #define CDC_TX_SIZE           64
101 #define KEYBOARD_INTERFACE    2 // Keyboard
102 #define KEYBOARD_ENDPOINT     1
103 #define KEYBOARD_SIZE         8
104 #define KEYBOARD_INTERVAL     1
105 #define MOUSE_INTERFACE       3 // Mouse
106 #define MOUSE_ENDPOINT        5
107 #define MOUSE_SIZE            8
108 #define MOUSE_INTERVAL        2
109 #define JOYSTICK_INTERFACE    4 // Joystick
110 #define JOYSTICK_ENDPOINT     6
111 #define JOYSTICK_SIZE         16
112 #define JOYSTICK_INTERVAL     1
113 #define KEYBOARD_DESC_OFFSET    (9+8 + 9+5+5+4+5+7+9+7+7 + 9)
114 #define MOUSE_DESC_OFFSET       (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9)
115 #define JOYSTICK_DESC_OFFSET    (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9)
116 #define CONFIG_DESC_SIZE        (9+8 + 9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9+9+7)
117 #define ENDPOINT1_CONFIG        ENDPOINT_TRANSIMIT_ONLY
118 #define ENDPOINT2_CONFIG        ENDPOINT_TRANSIMIT_ONLY
119 #define ENDPOINT3_CONFIG        ENDPOINT_RECEIVE_ONLY
120 #define ENDPOINT4_CONFIG        ENDPOINT_TRANSIMIT_ONLY
121 #define ENDPOINT5_CONFIG        ENDPOINT_TRANSIMIT_ONLY
122 #define ENDPOINT6_CONFIG        ENDPOINT_TRANSIMIT_ONLY
123
124
125 // NUM_ENDPOINTS = number of non-zero endpoints (0 to 15)
126 extern const uint8_t usb_endpoint_config_table[NUM_ENDPOINTS];
127
128 typedef struct {
129         uint16_t        wValue;
130         uint16_t        wIndex;
131         const uint8_t   *addr;
132         uint16_t        length;
133 } usb_descriptor_list_t;
134
135 extern const usb_descriptor_list_t usb_descriptor_list[];
136
137
138 #endif
139