comparison Output/pjrcUSB/arm/usb_desc.h @ 449:45feb80a2ad1

Major USB update, fixes most (if not all) known issues USB - General - Refactored descriptors - Enabled/Disable USB endpoints - Added debug flags for special features - Code cleanup - Interface count calculation based off of enabled endpoints - Delayed wTotalLength calculation to simplify descriptor offsets - Re-ordered endpoints and interfaces - Added more debug output - Added usbInitTime to show how long keyboard initialization took (Useful when debugging bad init sequences) - Added function for usb_resume() which takes care of the resume sequence * Resume is now only called if packets are starting to timeout USB - Special Options - Added enableDeviceRestartOnUSBTimeout * A last resort hammer for bad USB Chipsets/OSs, don't use if you can help it * Disabled - Added enableUSBResume * Enables host resume wake-up signalling, required to wake a computer from sleep * Enabled - Added enableUSBLowPowerNegotiation * Enables power negotiation hack * Required to use firmware with an IPad and other hard-limit low-power USB hosts * Hasn't been tested with the recent changes * Disabled - Added enableUSBSuspend * Enables power down events on host USB bus suspend * Enabled USB - Keyboard - Attempted to cleanup HID SET_REPORT * Works much better * Still has an issue under Linux which generates *a lot* of NAKs (initializes quickly regardless) + Not present on other keyboards + SETUP -> OUT -> IN : This sequence is the problem + Specifically during the OUT phase - Enabled USB - CDC Virtual Serial Port - Code cleanup - Added convenience struct USBCDCLineCoding for easier debugging - Attempted to cleanup CDC_SET_LING_CODING * Works much better * Still has an issue under Linux which generates *a lot* of NAKs (initializes quickly regardless) + SETUP -> OUT -> IN : This sequence is the problem + Specifically during the OUT phase + Likely the same issues as HID SET_REPORT - Enabled USB - Mouse - Enabled USB - Joystick - Disabled USB - RawIO - Initial code, API not used yet - Disabled DFU - Updated load script, now faster
author Jacob Alexander <haata@kiibohd.com>
date Tue, 31 May 2016 00:19:45 -0700
parents 23a1868b4ac2
children
comparison
equal deleted inserted replaced
448:077a1dfd8529 449:45feb80a2ad1
52 52
53 #define DEVICE_CLASS 0x00 // Keep 0x00 to indicate each sub device will indicate what it is 53 #define DEVICE_CLASS 0x00 // Keep 0x00 to indicate each sub device will indicate what it is
54 #define DEVICE_SUBCLASS 0x00 54 #define DEVICE_SUBCLASS 0x00
55 #define DEVICE_PROTOCOL 0x00 55 #define DEVICE_PROTOCOL 0x00
56 #define EP0_SIZE 64 56 #define EP0_SIZE 64
57 #define NUM_ENDPOINTS 8 57 #define NUM_ENDPOINTS 10 // XXX Can save some space if this can be calculated using KLL
58 #define NUM_USB_BUFFERS 30 58 #define NUM_USB_BUFFERS 30
59 #define NUM_INTERFACE 7 59
60 // XXX Remember to update total interface count, if it isn't correct some OSs will not initialize USB
61 // Linux warns in dmesg
62 // Mac OSX login screen will not initialize
63 #define KEYBOARD_INTERFACES 3 // Boot, NKRO, SysCtrl
64 #define CDC_INTERFACES 2
65 #define MOUSE_INTERFACES 1
66 #define JOYSTICK_INTERFACES 1
67 #define RAWIO_INTERFACES 1
68
60 69
61 #define KEYBOARD_INTERFACE 0 // Keyboard 70 #define KEYBOARD_INTERFACE 0 // Keyboard
62 #define KEYBOARD_ENDPOINT 1 71 #define KEYBOARD_ENDPOINT 1
63 #define KEYBOARD_SIZE 8 72 #define KEYBOARD_SIZE 8
64 #define KEYBOARD_INTERVAL 1 73 #define KEYBOARD_INTERVAL 1
68 #define NKRO_KEYBOARD_ENDPOINT 2 77 #define NKRO_KEYBOARD_ENDPOINT 2
69 #define NKRO_KEYBOARD_SIZE 64 78 #define NKRO_KEYBOARD_SIZE 64
70 #define NKRO_KEYBOARD_INTERVAL 1 79 #define NKRO_KEYBOARD_INTERVAL 1
71 #define NKRO_KEYBOARD_NAME L"NKRO Keyboard" 80 #define NKRO_KEYBOARD_NAME L"NKRO Keyboard"
72 81
82 #define SYS_CTRL_INTERFACE 2 // Media Keys
83 #define SYS_CTRL_ENDPOINT 3
84 #define SYS_CTRL_SIZE 8
85 #define SYS_CTRL_INTERVAL 1
86 #define SYS_CTRL_NAME L"Media Keys"
87
73 #define CDC_IAD_DESCRIPTOR 1 88 #define CDC_IAD_DESCRIPTOR 1
74 #define CDC_STATUS_INTERFACE 2 89 #define CDC_STATUS_INTERFACE 3
75 #define CDC_DATA_INTERFACE 3 // Serial 90 #define CDC_DATA_INTERFACE 4 // Serial
76 #define CDC_ACM_ENDPOINT 3 91 #define CDC_ACM_ENDPOINT 4
77 #define CDC_RX_ENDPOINT 4 92 #define CDC_RX_ENDPOINT 5
78 #define CDC_TX_ENDPOINT 5 93 #define CDC_TX_ENDPOINT 6
79 #define CDC_ACM_SIZE 16 94 #define CDC_ACM_SIZE 16
80 #define CDC_RX_SIZE 64 95 #define CDC_RX_SIZE 64
81 #define CDC_TX_SIZE 64 96 #define CDC_TX_SIZE 64
82 #define CDC_STATUS_NAME L"Virtual Serial Port - Status" 97 #define CDC_STATUS_NAME L"Virtual Serial Port - Status"
83 #define CDC_DATA_NAME L"Virtual Serial Port - Data" 98 #define CDC_DATA_NAME L"Virtual Serial Port - Data"
84 99
85 #define MOUSE_INTERFACE 4 // Mouse 100 #define RAWIO_INTERFACE 5 // RawIO
86 #define MOUSE_ENDPOINT 6 101 #define RAWIO_TX_ENDPOINT 7
102 #define RAWIO_TX_SIZE 64
103 #define RAWIO_TX_INTERVAL 1
104 #define RAWIO_RX_ENDPOINT 8
105 #define RAWIO_RX_SIZE 64
106 #define RAWIO_RX_INTERVAL 1
107 #define RAWIO_NAME L"API Interface"
108
109 #define MOUSE_INTERFACE 6 // Mouse
110 #define MOUSE_ENDPOINT 9
87 #define MOUSE_SIZE 8 111 #define MOUSE_SIZE 8
88 #define MOUSE_INTERVAL 1 112 #define MOUSE_INTERVAL 1
89 #define MOUSE_NAME L"Mouse" 113 #define MOUSE_NAME L"Mouse"
90 114
91 #define JOYSTICK_INTERFACE 5 // Joystick 115 #define JOYSTICK_INTERFACE 7 // Joystick
92 #define JOYSTICK_ENDPOINT 7 116 #define JOYSTICK_ENDPOINT 10
93 #define JOYSTICK_SIZE 16 117 #define JOYSTICK_SIZE 16
94 #define JOYSTICK_INTERVAL 1 118 #define JOYSTICK_INTERVAL 1
95 #define JOYSTICK_NAME L"Joystick" 119 #define JOYSTICK_NAME L"Joystick"
96 120
97 #define SYS_CTRL_INTERFACE 6 // Media Keys 121
98 #define SYS_CTRL_ENDPOINT 8 122 // Descriptor sizes
99 #define SYS_CTRL_SIZE 8 123 #define BASE_DESC_SIZE (9)
100 #define SYS_CTRL_INTERVAL 1 124 #define KEYBOARD_DESC_SIZE (9+9+7)
101 #define SYS_CTRL_NAME L"Media Keys" 125 #define NKRO_KEYBOARD_DESC_SIZE (9+9+7)
102 126 #define SYS_CTRL_DESC_SIZE (9+9+7)
103 #define KEYBOARD_DESC_OFFSET (9 + 9) 127 #define SERIAL_CDC_DESC_SIZE (8+9+5+5+4+5+7+9+7+7)
104 #define NKRO_KEYBOARD_DESC_OFFSET (9 + 9+9+7 + 9) 128 #define RAWIO_DESC_SIZE (9+7+7)
105 #define SERIAL_CDC_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 8) 129 #define MOUSE_DESC_SIZE (9+9+7)
106 #define MOUSE_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 8+9+5+5+4+5+7+9+7+7 + 9) 130 #define JOYSTICK_DESC_SIZE (9+9+7)
107 #define JOYSTICK_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 8+9+5+5+4+5+7+9+7+7 + 9+9+7 + 9) 131
108 #define SYS_CTRL_DESC_OFFSET (9 + 9+9+7 + 9+9+7 + 8+9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9) 132 // Descriptor offsets
109 #define CONFIG_DESC_SIZE (9 + 9+9+7 + 9+9+7 + 8+9+5+5+4+5+7+9+7+7 + 9+9+7 + 9+9+7 + 9+9+7) 133 #define KEYBOARD_DESC_BASE_OFFSET ( \
134 BASE_DESC_SIZE + \
135 9 \
136 )
137 #define SERIAL_CDC_DESC_BASE_OFFSET ( \
138 BASE_DESC_SIZE + \
139 KEYBOARD_DESC_TOTAL_OFFSET + \
140 8 \
141 )
142 #define RAWIO_DESC_BASE_OFFSET ( \
143 BASE_DESC_SIZE + \
144 KEYBOARD_DESC_TOTAL_OFFSET + \
145 SERIAL_CDC_DESC_TOTAL_OFFSET + \
146 9 \
147 )
148 #define MOUSE_DESC_BASE_OFFSET ( \
149 BASE_DESC_SIZE + \
150 KEYBOARD_DESC_TOTAL_OFFSET + \
151 SERIAL_CDC_DESC_TOTAL_OFFSET + \
152 9 \
153 )
154 #define JOYSTICK_DESC_BASE_OFFSET ( \
155 BASE_DESC_SIZE + \
156 KEYBOARD_DESC_TOTAL_OFFSET + \
157 SERIAL_CDC_DESC_TOTAL_OFFSET + \
158 MOUSE_DESC_TOTAL_OFFSET + \
159 9 \
160 )
161
110 162
111 #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY 163 #define ENDPOINT1_CONFIG ENDPOINT_TRANSIMIT_ONLY
112 #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY 164 #define ENDPOINT2_CONFIG ENDPOINT_TRANSIMIT_ONLY
113 #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY 165 #define ENDPOINT3_CONFIG ENDPOINT_TRANSIMIT_ONLY
114 #define ENDPOINT4_CONFIG ENDPOINT_RECEIVE_ONLY 166 #define ENDPOINT4_CONFIG ENDPOINT_TRANSIMIT_ONLY
115 #define ENDPOINT5_CONFIG ENDPOINT_TRANSIMIT_ONLY 167 #define ENDPOINT5_CONFIG ENDPOINT_RECEIVE_ONLY
116 #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY 168 #define ENDPOINT6_CONFIG ENDPOINT_TRANSIMIT_ONLY
117 #define ENDPOINT7_CONFIG ENDPOINT_TRANSIMIT_ONLY 169 #define ENDPOINT7_CONFIG ENDPOINT_TRANSIMIT_ONLY
118 #define ENDPOINT8_CONFIG ENDPOINT_TRANSIMIT_ONLY 170 #define ENDPOINT8_CONFIG ENDPOINT_RECEIVE_ONLY
171 #define ENDPOINT9_CONFIG ENDPOINT_TRANSIMIT_ONLY
172 #define ENDPOINT10_CONFIG ENDPOINT_TRANSIMIT_ONLY
119 173
120 174
121 175
122 // ----- Enumerations ----- 176 // ----- Enumerations -----
123 177
137 191
138 extern const usb_descriptor_list_t usb_descriptor_list[]; 192 extern const usb_descriptor_list_t usb_descriptor_list[];
139 193
140 extern uint8_t *usb_bMaxPower; 194 extern uint8_t *usb_bMaxPower;
141 195
196
197 // ----- Functions -----
198
199 void usb_set_config_descriptor_size();
200