Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
usb.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_USB_H
27#define _ULTIBO_USB_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/globaltypes.h"
34#include "ultibo/globalconst.h"
35#include "ultibo/system.h"
36#include "ultibo/devices.h"
37
39#define USB_DEVICE_PREFIX "USB"
40#define USB_DRIVER_PREFIX "USB"
41#define USB_HOST_PREFIX "USBHost"
42
44#define USB_TYPE_NONE 0
45
46#define USB_TYPE_MAX 0
47
49#define USB_STATE_DETACHED 0
50#define USB_STATE_DETACHING 1
51#define USB_STATE_ATTACHING 2
52#define USB_STATE_ATTACHED 3
53
54#define USB_STATE_MAX 3
55
57#define USB_STATUS_UNBOUND 0
58#define USB_STATUS_BOUND 1
59
60#define USB_STATUS_MAX 1
61
63#define USB_FLAG_NONE 0x00000000
64
66#define USBHOST_TYPE_NONE 0
67#define USBHOST_TYPE_EHCI 1
68#define USBHOST_TYPE_OHCI 2
69#define USBHOST_TYPE_UHCI 3
70#define USBHOST_TYPE_XHCI 4
71#define USBHOST_TYPE_DWCOTG 5
72
73#define USBHOST_TYPE_MAX 5
74
76#define USBHOST_STATE_DISABLED 0
77#define USBHOST_STATE_ENABLED 1
78
79#define USBHOST_STATE_MAX 1
80
82#define USBHOST_FLAG_NONE 0x00000000
83#define USBHOST_FLAG_SHARED 0x00000001
84#define USBHOST_FLAG_NOCACHE 0x00000002
85
87#define USB_STATUS_SUCCESS 0
88#define USB_STATUS_DEVICE_DETACHED 1
89#define USB_STATUS_DEVICE_UNSUPPORTED 2
90#define USB_STATUS_HARDWARE_ERROR 3
91#define USB_STATUS_INVALID_DATA 4
92#define USB_STATUS_INVALID_PARAMETER 5
93#define USB_STATUS_NOT_PROCESSED 6
94#define USB_STATUS_OUT_OF_MEMORY 7
95#define USB_STATUS_TIMEOUT 8
96#define USB_STATUS_UNSUPPORTED_REQUEST 9
97#define USB_STATUS_HARDWARE_STALL 10
98#define USB_STATUS_OPERATION_FAILED 11
99#define USB_STATUS_NOT_BOUND 12
100#define USB_STATUS_ALREADY_BOUND 13
101#define USB_STATUS_NOT_READY 14
102#define USB_STATUS_NOT_COMPLETED 15
103#define USB_STATUS_CANCELLED 16
104#define USB_STATUS_NOT_VALID 17
105
107#define USB_REQUEST_FLAG_NONE 0x00000000
108#define USB_REQUEST_FLAG_ALLOCATED 0x00000001
109#define USB_REQUEST_FLAG_COMPATIBLE 0x00000002
110#define USB_REQUEST_FLAG_ALIGNED 0x00000004
111#define USB_REQUEST_FLAG_SIZED 0x00000008
112#define USB_REQUEST_FLAG_SHARED 0x00000010
113#define USB_REQUEST_FLAG_NOCACHE 0x00000020
114
116#define USB_CONTROL_PHASE_SETUP 0
117#define USB_CONTROL_PHASE_DATA 1
118#define USB_CONTROL_PHASE_STATUS 2
119
121#define USB_CONTROL_GET_TIMEOUT 5000
122#define USB_CONTROL_SET_TIMEOUT 5000
123
125#define USB_DEFAULT_MAX_PACKET_SIZE 8
126#define USB_ALTERNATE_MAX_PACKET_SIZE 64
127
129#define USB_MAX_PACKET_SIZE 1024
130
132#define USB_FRAMES_PER_MS 1
133
135#define USB_UFRAMES_PER_MS 8
136
138#define USB_CONFIGURATION_ATTRIBUTE_RESERVED_HIGH 0x80
139#define USB_CONFIGURATION_ATTRIBUTE_SELF_POWERED 0x40
140#define USB_CONFIGURATION_ATTRIBUTE_REMOTE_WAKEUP 0x20
141#define USB_CONFIGURATION_ATTRIBUTE_RESERVED_LOW 0x1f
142
144#define USB_DEVICE_STATUS_SELF_POWERED (1 << 0)
145#define USB_DEVICE_STATUS_REMOTE_WAKEUP (1 << 1)
146
148#define USB_ENDPOINT_STATUS_HALT (1 << 0)
149
151#define USB_SPEED_HIGH 0
152#define USB_SPEED_FULL 1
153#define USB_SPEED_LOW 2
154#define USB_SPEED_SUPER 3
155#define USB_SPEED_SUPERPLUS 4
156
159#define USB_TRANSFER_TYPE_CONTROL 0
160#define USB_TRANSFER_TYPE_ISOCHRONOUS 1
161#define USB_TRANSFER_TYPE_BULK 2
162#define USB_TRANSFER_TYPE_INTERRUPT 3
163#define USB_TRANSFER_TYPE_MASK 0x03
164
166#define USB_TRANSFER_SIZE_8_BIT 0
167#define USB_TRANSFER_SIZE_16_BIT 1
168#define USB_TRANSFER_SIZE_32_BIT 2
169#define USB_TRANSFER_SIZE_64_BIT 3
170
173#define USB_DESCRIPTOR_TYPE_DEVICE 1
174#define USB_DESCRIPTOR_TYPE_CONFIGURATION 2
175#define USB_DESCRIPTOR_TYPE_STRING 3
176#define USB_DESCRIPTOR_TYPE_INTERFACE 4
177#define USB_DESCRIPTOR_TYPE_ENDPOINT 5
178#define USB_DESCRIPTOR_TYPE_DEVICE_QUALIFIER 6
179#define USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION 7
180#define USB_DESCRIPTOR_TYPE_INTERFACE_POWER 8
181#define USB_DESCRIPTOR_TYPE_CLASS_DEVICE 0x21
182#define USB_DESCRIPTOR_TYPE_CLASS_CONFIGURATION 0x22
183#define USB_DESCRIPTOR_TYPE_CLASS_STRING 0x23
184#define USB_DESCRIPTOR_TYPE_CLASS_INTERFACE 0x24
185#define USB_DESCRIPTOR_TYPE_CLASS_ENDPOINT 0x25
186#define USB_DESCRIPTOR_TYPE_HUB 0x29
187
190#define USB_DIRECTION_OUT 0
191#define USB_DIRECTION_IN 1
192
194#define USB_REQUEST_TYPE_STANDARD 0
195#define USB_REQUEST_TYPE_CLASS 1
196#define USB_REQUEST_TYPE_VENDOR 2
197#define USB_REQUEST_TYPE_RESERVED 3
198
200#define USB_REQUEST_RECIPIENT_DEVICE 0
201#define USB_REQUEST_RECIPIENT_INTERFACE 1
202#define USB_REQUEST_RECIPIENT_ENDPOINT 2
203#define USB_REQUEST_RECIPIENT_OTHER 3
204
206#define USB_BMREQUESTTYPE_DIR_OUT (USB_DIRECTION_OUT << 7)
207#define USB_BMREQUESTTYPE_DIR_IN (USB_DIRECTION_IN << 7)
208#define USB_BMREQUESTTYPE_DIR_MASK (0x01 << 7)
209#define USB_BMREQUESTTYPE_TYPE_STANDARD (USB_REQUEST_TYPE_STANDARD << 5)
210#define USB_BMREQUESTTYPE_TYPE_CLASS (USB_REQUEST_TYPE_CLASS << 5)
211#define USB_BMREQUESTTYPE_TYPE_VENDOR (USB_REQUEST_TYPE_VENDOR << 5)
212#define USB_BMREQUESTTYPE_TYPE_RESERVED (USB_REQUEST_TYPE_RESERVED << 5)
213#define USB_BMREQUESTTYPE_TYPE_MASK (0x03 << 5)
214#define USB_BMREQUESTTYPE_RECIPIENT_DEVICE (USB_REQUEST_RECIPIENT_DEVICE << 0)
215#define USB_BMREQUESTTYPE_RECIPIENT_INTERFACE (USB_REQUEST_RECIPIENT_INTERFACE << 0)
216#define USB_BMREQUESTTYPE_RECIPIENT_ENDPOINT (USB_REQUEST_RECIPIENT_ENDPOINT << 0)
217#define USB_BMREQUESTTYPE_RECIPIENT_OTHER (USB_REQUEST_RECIPIENT_OTHER << 0)
218#define USB_BMREQUESTTYPE_RECIPIENT_MASK (0x1f << 0)
219
222#define USB_DEVICE_REQUEST_GET_STATUS 0
223#define USB_DEVICE_REQUEST_CLEAR_FEATURE 1
224#define USB_DEVICE_REQUEST_SET_FEATURE 3
225#define USB_DEVICE_REQUEST_SET_ADDRESS 5
226#define USB_DEVICE_REQUEST_GET_DESCRIPTOR 6
227#define USB_DEVICE_REQUEST_SET_DESCRIPTOR 7
228#define USB_DEVICE_REQUEST_GET_CONFIGURATION 8
229#define USB_DEVICE_REQUEST_SET_CONFIGURATION 9
230#define USB_DEVICE_REQUEST_GET_INTERFACE 10
231#define USB_DEVICE_REQUEST_SET_INTERFACE 11
232#define USB_DEVICE_REQUEST_SYNCH_FRAME 12
233
236#define USB_DEVICE_FEATURE_ENDPOINT_HALT 0
237#define USB_DEVICE_FEATURE_REMOTE_WAKEUP 1
238#define USB_DEVICE_FEATURE_TEST_MODE 2
239
242#define USB_DEVICE_TEST_MODE_J 0x01
243#define USB_DEVICE_TEST_MODE_K 0x02
244#define USB_DEVICE_TEST_MODE_SE0_NAK 0x03
245#define USB_DEVICE_TEST_MODE_PACKET 0x04
246#define USB_DEVICE_TEST_MODE_FORCE_ENABLE 0x05
247
249#define USB_PACKETID_UNDEF_0 0xf0
250#define USB_PACKETID_OUT 0xe1
251#define USB_PACKETID_ACK 0xd2
252#define USB_PACKETID_DATA0 0xc3
253#define USB_PACKETID_UNDEF_4 0xb4
254#define USB_PACKETID_SOF 0xa5
255#define USB_PACKETID_UNDEF_6 0x96
256#define USB_PACKETID_UNDEF_7 0x87
257#define USB_PACKETID_UNDEF_8 0x78
258#define USB_PACKETID_IN 0x69
259#define USB_PACKETID_NAK 0x5a
260#define USB_PACKETID_DATA1 0x4b
261#define USB_PACKETID_PREAMBLE 0x3c
262#define USB_PACKETID_SETUP 0x2d
263#define USB_PACKETID_STALL 0x1e
264#define USB_PACKETID_UNDEF_F 0x0f
265
267#define USB_CLASS_CODE_INTERFACE_SPECIFIC 0x00
268#define USB_CLASS_CODE_AUDIO 0x01
269#define USB_CLASS_CODE_COMMUNICATIONS_AND_CDC_CONTROL 0x02
270#define USB_CLASS_CODE_COMMS USB_CLASS_CODE_COMMUNICATIONS_AND_CDC_CONTROL
271#define USB_CLASS_CODE_HID 0x03
272#define USB_CLASS_CODE_PHYSICAL 0x05
273#define USB_CLASS_CODE_IMAGE 0x06
274#define USB_CLASS_CODE_PRINTER 0x07
275#define USB_CLASS_CODE_MASS_STORAGE 0x08
276#define USB_CLASS_CODE_HUB 0x09
277#define USB_CLASS_CODE_CDC_DATA 0x0a
278#define USB_CLASS_CODE_SMART_CARD 0x0b
279#define USB_CLASS_CODE_CONTENT_SECURITY 0x0d
280#define USB_CLASS_CODE_VIDEO 0x0e
281#define USB_CLASS_CODE_PERSONAL_HEALTHCARE 0x0f
282#define USB_CLASS_CODE_AUDIO_VIDEO 0x10
283#define USB_CLASS_CODE_BILLBOARD 0x11
284#define USB_CLASS_CODE_DIAGNOSTIC 0xDC
285#define USB_CLASS_CODE_WIRELESS_CONTROLLER 0xe0
286#define USB_CLASS_CODE_MISCELLANEOUS 0xef
287#define USB_CLASS_CODE_APPLICATION_SPECIFIC 0xfe
288#define USB_CLASS_CODE_VENDOR_SPECIFIC 0xff
289
292#define USB_SUBCLASS_CDC_DLCM 0x01
293#define USB_SUBCLASS_CDC_ACM 0x02
294#define USB_SUBCLASS_CDC_TCM 0x03
295#define USB_SUBCLASS_CDC_MCCM 0x04
296#define USB_SUBCLASS_CDC_CCM 0x05
297#define USB_SUBCLASS_CDC_ETHERNET 0x06
298#define USB_SUBCLASS_CDC_WHCM 0x08
299#define USB_SUBCLASS_CDC_DMM 0x09
300#define USB_SUBCLASS_CDC_MDLM 0x0a
301#define USB_SUBCLASS_CDC_OBEX 0x0b
302#define USB_SUBCLASS_CDC_EEM 0x0c
303#define USB_SUBCLASS_CDC_NCM 0x0d
304#define USB_SUBCLASS_CDC_MBIM 0x0e
306#define USB_SUBCLASS_IMAGE_DEFAULT 0x01
308#define USB_SUBCLASS_MASS_STORAGE_DEFAULT 0x00
309#define USB_SUBCLASS_MASS_STORAGE_RBC 0x01
310#define USB_SUBCLASS_MASS_STORAGE_MMC5 0x02
311#define USB_SUBCLASS_MASS_STORAGE_QIC157 0x03
312#define USB_SUBCLASS_MASS_STORAGE_UFI 0x04
313#define USB_SUBCLASS_MASS_STORAGE_SFF8070I 0x05
314#define USB_SUBCLASS_MASS_STORAGE_SCSI 0x06
315#define USB_SUBCLASS_MASS_STORAGE_LSDFS 0x07
316#define USB_SUBCLASS_MASS_STORAGE_IEEE1667 0x08
317#define USB_SUBCLASS_MASS_STORAGE_VENDOR_SPECIFIC 0xff
319#define USB_SUBCLASS_CONTENT_SECURITY_DEFAULT 0x00
321#define USB_SUBCLASS_AUDIO_VIDEO_CONTROL 0x01
322#define USB_SUBCLASS_AUDIO_VIDEO_DATA_VIDEO 0x02
323#define USB_SUBCLASS_AUDIO_VIDEO_DATA_AUDIO 0x03
325#define USB_SUBCLASS_BILLBOARD_DEFAULT 0x00
327#define USB_SUBCLASS_DIAGNOSTIC_DEFAULT 0x01
329#define USB_SUBCLASS_WIRELESS_CONTROLLER_BLUETOOTH 0x01
330#define USB_SUBCLASS_WIRELESS_CONTROLLER_USB 0x02
332#define USB_SUBCLASS_MISCELLANEOUS_SYNC 0x01
333#define USB_SUBCLASS_MISCELLANEOUS_IAD_WAMP 0x02
334#define USB_SUBCLASS_MISCELLANEOUS_CBAF 0x03
335#define USB_SUBCLASS_MISCELLANEOUS_RNDIS 0x04
336#define USB_SUBCLASS_MISCELLANEOUS_USB3VISION 0x05
338#define USB_SUBCLASS_APPLICATION_SPECIFIC_DFU 0x01
339#define USB_SUBCLASS_APPLICATION_SPECIFIC_IRDA 0x02
340#define USB_SUBCLASS_APPLICATION_SPECIFIC_TMC 0x02
342#define USB_SUBCLASS_VENDOR_SPECIFIC 0xff
343
346#define USB_PROTOCOL_CDC_ACM_NONE 0
347#define USB_PROTOCOL_CDC_ACM_AT_V25TER 1
348#define USB_PROTOCOL_CDC_ACM_AT_PCCA101 2
349#define USB_PROTOCOL_CDC_ACM_AT_PCCA101_WAKE 3
350#define USB_PROTOCOL_CDC_ACM_AT_GSM 4
351#define USB_PROTOCOL_CDC_ACM_AT_3G 5
352#define USB_PROTOCOL_CDC_ACM_AT_CDMA 6
353#define USB_PROTOCOL_CDC_ACM_VENDOR 0xff
354#define USB_PROTOCOL_CDC_EEM 7
355#define USB_PROTOCOL_CDC_NCM_NTB 1
356#define USB_PROTOCOL_CDC_MBIM_NTB 2
358#define USB_PROTOCOL_IMAGE_DEFAULT 0x01
360#define USB_PROTOCOL_MASS_STORAGE_CBI 0x00
361#define USB_PROTOCOL_MASS_STORAGE_CB 0x01
362#define USB_PROTOCOL_MASS_STORAGE_BBB 0x50
363#define USB_PROTOCOL_MASS_STORAGE_UAS 0x62
364#define USB_PROTOCOL_MASS_STORAGE_VENDOR_SPECIFIC 0xff
366#define USB_PROTOCOL_HUB_FULLSPEED 0x00
367#define USB_PROTOCOL_HUB_HIGHSPEED_SINGLE_TT 0x01
368#define USB_PROTOCOL_HUB_HIGHSPEED_MULTI_TT 0x02
370#define USB_PROTOCOL_CONTENT_SECURITY_DEFAULT 0x00
372#define USB_PROTOCOL_AUDIO_VIDEO_DEFAULT 0x00
374#define USB_PROTOCOL_BILLBOARD_DEFAULT 0x00
376#define USB_PROTOCOL_DIAGNOSTIC_DEFAULT 0x01
378#define USB_PROTOCOL_WIRELESS_CONTROLLER_BLUETOOTH 0x01
379#define USB_PROTOCOL_WIRELESS_CONTROLLER_UWB 0x02
380#define USB_PROTOCOL_WIRELESS_CONTROLLER_NDIS 0x03
381#define USB_PROTOCOL_WIRELESS_CONTROLLER_BLUETOOTH_AMP 0x04
382#define USB_PROTOCOL_WIRELESS_CONTROLLER_USB_HOST 0x01
383#define USB_PROTOCOL_WIRELESS_CONTROLLER_USB_DEVICE 0x02
384#define USB_PROTOCOL_WIRELESS_CONTROLLER_USB_DEVICE_ISOC 0x03
386#define USB_PROTOCOL_MISCELLANEOUS_ACTIVESYNC 0x01
387#define USB_PROTOCOL_MISCELLANEOUS_PALMSYNC 0x02
388#define USB_PROTOCOL_MISCELLANEOUS_IAD 0x01
389#define USB_PROTOCOL_MISCELLANEOUS_WAMP 0x02
390#define USB_PROTOCOL_MISCELLANEOUS_CBAF 0x01
391#define USB_PROTOCOL_MISCELLANEOUS_RNDIS_ETHERNET 0x01
392#define USB_PROTOCOL_MISCELLANEOUS_RNDIS_WIFI 0x02
393#define USB_PROTOCOL_MISCELLANEOUS_RNDIS_WIMAX 0x03
394#define USB_PROTOCOL_MISCELLANEOUS_RNDIS_WWAN 0x04
395#define USB_PROTOCOL_MISCELLANEOUS_RNDIS_IPV4 0x05
396#define USB_PROTOCOL_MISCELLANEOUS_RNDIS_IPV6 0x06
397#define USB_PROTOCOL_MISCELLANEOUS_RNDIS_GPRS 0x07
398#define USB_PROTOCOL_MISCELLANEOUS_USB3VISION_CONTROL 0x00
399#define USB_PROTOCOL_MISCELLANEOUS_USB3VISION_EVENT 0x01
400#define USB_PROTOCOL_MISCELLANEOUS_USB3VISION_STREAM 0x02
402#define USB_PROTOCOL_APPLICATION_SPECIFIC_DFU_DEFAULT 0x01
403#define USB_PROTOCOL_APPLICATION_SPECIFIC_IRDA_DEFAULT 0x00
404#define USB_PROTOCOL_APPLICATION_SPECIFIC_TMC_DEFAULT 0x00
405#define USB_PROTOCOL_APPLICATION_SPECIFIC_TMC_488 0x01
406
409#define USB_LANG_ARABIC 0x01
410#define USB_LANG_BULGARIAN 0x02
411#define USB_LANG_CATALAN 0x03
412#define USB_LANG_CHINESE 0x04
413#define USB_LANG_CZECH 0x05
414#define USB_LANG_DANISH 0x06
415#define USB_LANG_GERMAN 0x07
416#define USB_LANG_GREEK 0x08
417#define USB_LANG_ENGLISH 0x09
418#define USB_LANG_SPANISH 0x0a
419#define USB_LANG_FINNISH 0x0b
420#define USB_LANG_FRENCH 0x0c
421#define USB_LANG_HEBREW 0x0d
422#define USB_LANG_HUNGARIAN 0x0e
423#define USB_LANG_ICELANDIC 0x0f
424#define USB_LANG_ITALIAN 0x10
425#define USB_LANG_JAPANESE 0x11
426#define USB_LANG_KOREAN 0x12
427#define USB_LANG_DUTCH 0x13
428#define USB_LANG_NORWEGIAN 0x14
429#define USB_LANG_POLISH 0x15
430#define USB_LANG_PORTUGUESE 0x16
431#define USB_LANG_ROMANIAN 0x18
432#define USB_LANG_RUSSIAN 0x19
433#define USB_LANG_CROATIAN 0x1a
434#define USB_LANG_SERBIAN 0x1a
435#define USB_LANG_SLOVAK 0x1b
436#define USB_LANG_ALBANIAN 0x1c
437#define USB_LANG_SWEDISH 0x1d
438#define USB_LANG_THAI 0x1e
439#define USB_LANG_TURKISH 0x1f
440#define USB_LANG_URDU 0x20
441#define USB_LANG_INDONESIAN 0x21
442#define USB_LANG_UKRANIAN 0x22
443#define USB_LANG_BELARUSIAN 0x23
444#define USB_LANG_SLOVENIAN 0x24
445#define USB_LANG_ESTONIAN 0x25
446#define USB_LANG_LATVIAN 0x26
447#define USB_LANG_LITHUANIAN 0x27
448#define USB_LANG_FARSI 0x29
449#define USB_LANG_VIETNAMESE 0x2a
450#define USB_LANG_ARMENIAN 0x2b
451#define USB_LANG_AZERI 0x2c
452#define USB_LANG_BASQUE 0x2d
453#define USB_LANG_MACEDONIAN 0x2f
454#define USB_LANG_AFRIKAANS 0x36
455#define USB_LANG_GEORGIAN 0x37
456#define USB_LANG_FAEROESE 0x38
457#define USB_LANG_HINDI 0x39
458#define USB_LANG_MALAY 0x3e
459#define USB_LANG_KAZAK 0x3f
460#define USB_LANG_SWAHILI 0x41
461#define USB_LANG_UZBEK 0x43
462#define USB_LANG_TATAR 0x44
463#define USB_LANG_BENGALI 0x45
464#define USB_LANG_PUNJABI 0x46
465#define USB_LANG_GUJARATI 0x47
466#define USB_LANG_ORIYA 0x48
467#define USB_LANG_TAMIL 0x49
468#define USB_LANG_TELUGU 0x4a
469#define USB_LANG_KANNADA 0x4b
470#define USB_LANG_MALAYALAM 0x4c
471#define USB_LANG_ASSAMESE 0x4d
472#define USB_LANG_MARATHI 0x4e
473#define USB_LANG_SANSKRIT 0x4f
474#define USB_LANG_KONKANI 0x57
475#define USB_LANG_MANIPURI 0x58
476#define USB_LANG_SINDHI 0x59
477#define USB_LANG_KASHMIRI 0x60
478#define USB_LANG_NEPALI 0x61
480#define USB_LANG_HID 0xff
482
483#define USB_PRIMARY_LANGUAGE_MASK 0x3ff
484
487#define USB_SUBLANG_ARABIC_SAUDI_ARABIA 0x01
488#define USB_SUBLANG_ARABIC_IRAQ 0x02
489#define USB_SUBLANG_ARABIC_EGYPT 0x03
490#define USB_SUBLANG_ARABIC_LIBYA 0x04
491#define USB_SUBLANG_ARABIC_ALGERIA 0x05
492#define USB_SUBLANG_ARABIC_MOROCCO 0x06
493#define USB_SUBLANG_ARABIC_TUNISIA 0x07
494#define USB_SUBLANG_ARABIC_OMAN 0x08
495#define USB_SUBLANG_ARABIC_YEMEN 0x09
496#define USB_SUBLANG_ARABIC_SYRIA 0x10
497#define USB_SUBLANG_ARABIC_JORDAN 0x11
498#define USB_SUBLANG_ARABIC_LEBANON 0x12
499#define USB_SUBLANG_ARABIC_KUWAIT 0x13
500#define USB_SUBLANG_ARABIC_UAE 0x14
501#define USB_SUBLANG_ARABIC_BAHRAIN 0x15
502#define USB_SUBLANG_ARABIC_QATAR 0x16
503#define USB_SUBLANG_AZERI_CYRILLIC 0x01
504#define USB_SUBLANG_AZERI_LATIN 0x02
505#define USB_SUBLANG_CHINESE_TRADITIONAL 0x01
506#define USB_SUBLANG_CHINESE_SIMPLIFIED 0x02
507#define USB_SUBLANG_CHINESE_HONGKONG 0x03
508#define USB_SUBLANG_CHINESE_SINGAPORE 0x04
509#define USB_SUBLANG_CHINESE_MACAU 0x05
510#define USB_SUBLANG_DUTCH 0x01
511#define USB_SUBLANG_DUTCH_BELGIAN 0x02
512#define USB_SUBLANG_ENGLISH_US 0x01
513#define USB_SUBLANG_ENGLISH_UK 0x02
514#define USB_SUBLANG_ENGLISH_AUS 0x03
515#define USB_SUBLANG_ENGLISH_CAN 0x04
516#define USB_SUBLANG_ENGLISH_NZ 0x05
517#define USB_SUBLANG_ENGLISH_EIRE 0x06
518#define USB_SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
519#define USB_SUBLANG_ENGLISH_JAMAICA 0x08
520#define USB_SUBLANG_ENGLISH_CARIBBEAN 0x09
521#define USB_SUBLANG_ENGLISH_BELIZE 0x0a
522#define USB_SUBLANG_ENGLISH_TRINIDAD 0x0b
523#define USB_SUBLANG_ENGLISH_PHILIPPINES 0x0c
524#define USB_SUBLANG_ENGLISH_ZIMBABWE 0x0d
525#define USB_SUBLANG_FRENCH 0x01
526#define USB_SUBLANG_FRENCH_BELGIAN 0x02
527#define USB_SUBLANG_FRENCH_CANADIAN 0x03
528#define USB_SUBLANG_FRENCH_SWISS 0x04
529#define USB_SUBLANG_FRENCH_LUXEMBOURG 0x05
530#define USB_SUBLANG_FRENCH_MONACO 0x06
531#define USB_SUBLANG_GERMAN 0x01
532#define USB_SUBLANG_GERMAN_SWISS 0x02
533#define USB_SUBLANG_GERMAN_AUSTRIAN 0x03
534#define USB_SUBLANG_GERMAN_LUXEMBOURG 0x04
535#define USB_SUBLANG_GERMAN_LIECHTENSTEIN 0x05
536#define USB_SUBLANG_ITALIAN 0x01
537#define USB_SUBLANG_ITALIAN_SWISS 0x02
538#define USB_SUBLANG_KASHMIRI_INDIA 0x02
539#define USB_SUBLANG_KOREAN 0x01
540#define USB_SUBLANG_LITHUANIAN 0x01
541#define USB_SUBLANG_MALAY_MALAYSIA 0x01
542#define USB_SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
543#define USB_SUBLANG_NEPALI_INDIA 0x02
544#define USB_SUBLANG_NORWEGIAN_BOKMAL 0x01
545#define USB_SUBLANG_NORWEGIAN_NYNORSK 0x02
546#define USB_SUBLANG_PORTUGUESE 0x01
547#define USB_SUBLANG_PORTUGUESE_BRAZILIAN 0x02
548#define USB_SUBLANG_SERBIAN_LATIN 0x02
549#define USB_SUBLANG_SERBIAN_CYRILLIC 0x03
550#define USB_SUBLANG_SPANISH 0x01
551#define USB_SUBLANG_SPANISH_MEXICAN 0x02
552#define USB_SUBLANG_SPANISH_MODERN 0x03
553#define USB_SUBLANG_SPANISH_GUATEMALA 0x04
554#define USB_SUBLANG_SPANISH_COSTA_RICA 0x05
555#define USB_SUBLANG_SPANISH_PANAMA 0x06
556#define USB_SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
557#define USB_SUBLANG_SPANISH_VENEZUELA 0x08
558#define USB_SUBLANG_SPANISH_COLOMBIA 0x09
559#define USB_SUBLANG_SPANISH_PERU 0x0a
560#define USB_SUBLANG_SPANISH_ARGENTINA 0x0b
561#define USB_SUBLANG_SPANISH_ECUADOR 0x0c
562#define USB_SUBLANG_SPANISH_CHILE 0x0d
563#define USB_SUBLANG_SPANISH_URUGUAY 0x0e
564#define USB_SUBLANG_SPANISH_PARAGUAY 0x0f
565#define USB_SUBLANG_SPANISH_BOLIVIA 0x10
566#define USB_SUBLANG_SPANISH_EL_SALVADOR 0x11
567#define USB_SUBLANG_SPANISH_HONDURAS 0x12
568#define USB_SUBLANG_SPANISH_NICARAGUA 0x13
569#define USB_SUBLANG_SPANISH_PUERTO_RICO 0x14
570#define USB_SUBLANG_SWEDISH 0x01
571#define USB_SUBLANG_SWEDISH_FINLAND 0x02
572#define USB_SUBLANG_URDU_PAKISTAN 0x01
573#define USB_SUBLANG_URDU_INDIA 0x02
574#define USB_SUBLANG_UZBEK_LATIN 0x01
575#define USB_SUBLANG_UZBEK_CYRILLIC 0x02
576#define USB_SUBLANG_HID_USAGE_DATA_DESCRIPTOR 0x01
577#define USB_SUBLANG_HID_VENDOR_DEFINED_1 0x3c
578#define USB_SUBLANG_HID_VENDOR_DEFINED_2 0x3d
579#define USB_SUBLANG_HID_VENDOR_DEFINED_3 0x3e
580#define USB_SUBLANG_HID_VENDOR_DEFINED_4 0x3f
581
583#define USB_LANGID_US_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_US << 10))
584#define USB_LANGID_UK_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_UK << 10))
585#define USB_LANGID_AUS_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_AUS << 10))
586#define USB_LANGID_CAN_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_CAN << 10))
587#define USB_LANGID_NZ_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_NZ << 10))
588#define USB_LANGID_EIRE_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_EIRE << 10))
589#define USB_LANGID_SOUTH_AFRICA_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_SOUTH_AFRICA << 10))
590#define USB_LANGID_JAMAICA_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_JAMAICA << 10))
591#define USB_LANGID_CARIBBEAN_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_CARIBBEAN << 10))
592#define USB_LANGID_BELIZE_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_BELIZE << 10))
593#define USB_LANGID_TRINIDAD_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_TRINIDAD << 10))
594#define USB_LANGID_PHILIPPINES_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_PHILIPPINES << 10))
595#define USB_LANGID_ZIMBABWE_ENGLISH (USB_LANG_ENGLISH | (USB_SUBLANG_ENGLISH_ZIMBABWE << 10))
596
597#define USB_LANGID_USAGE_HID (USB_LANG_HID | (USB_SUBLANG_HID_USAGE_DATA_DESCRIPTOR << 10))
598#define USB_LANGID_VENDOR1_HID (USB_LANG_HID | (USB_SUBLANG_HID_VENDOR_DEFINED_1 << 10))
599#define USB_LANGID_VENDOR2_HID (USB_LANG_HID | (USB_SUBLANG_HID_VENDOR_DEFINED_2 << 10))
600#define USB_LANGID_VENDOR3_HID (USB_LANG_HID | (USB_SUBLANG_HID_VENDOR_DEFINED_3 << 10))
601#define USB_LANGID_VENDOR4_HID (USB_LANG_HID | (USB_SUBLANG_HID_VENDOR_DEFINED_4 << 10))
602
604#define USB_VENDORID_REALTEK 0x0BDA
605
607#define USB_HUB_PREFIX "USBHub"
608
610#define USBHUB_TYPE_NONE 0
611
612#define USBHUB_TYPE_MAX 0
613
615#define USBHUB_STATE_DETACHED 0
616#define USBHUB_STATE_DETACHING 1
617#define USBHUB_STATE_ATTACHING 2
618#define USBHUB_STATE_ATTACHED 3
619
620#define USBHUB_STATE_MAX 3
621
623#define USBHUB_FLAG_NONE 0x00000000
624#define USBHUB_FLAG_COMPOUND 0x00000001
625#define USBHUB_FLAG_PORT_POWER 0x00000002
626#define USBHUB_FLAG_PORT_PROTECTION 0x00000004
627#define USBHUB_FLAG_MULTI_TRANSLATOR 0x00000008
628
629#define USBHUB_THREAD_STACK_SIZE SIZE_32K
630#define USBHUB_THREAD_PRIORITY THREAD_PRIORITY_HIGHEST
631#define USBHUB_THREAD_NAME "USB Hub"
632
633#define USBHUB_DEVICE_DESCRIPTION "USB Hub"
634
635#define USBHUB_DRIVER_NAME "USB Hub Driver"
636
638
639#define USB_PORT_RESET_TIMEOUT 500
640#define USB_PORT_RESET_RECOVERY 30
641#define USB_PORT_SHORT_RESET_DELAY 10
642#define USB_PORT_LONG_RESET_DELAY 200
643#define USB_PORT_ROOT_RESET_DELAY 60
644
645#define USB_ATTACH_DEBOUNCE_INTERVAL 100
646#define USB_ADDRESS_COMPLETION_TIME 50
647
649#define USB_HUB_CHARACTERISTIC_LPSM (3 << 0)
650#define USB_HUB_CHARACTERISTIC_LPSM_GANGED (0 << 0)
651#define USB_HUB_CHARACTERISTIC_LPSM_PORT (1 << 0)
652#define USB_HUB_CHARACTERISTIC_IS_COMPOUND_DEVICE (1 << 2)
653#define USB_HUB_CHARACTERISTIC_OCPM (3 << 3)
654#define USB_HUB_CHARACTERISTIC_OCPM_GLOBAL (0 << 3)
655#define USB_HUB_CHARACTERISTIC_OCPM_PORT (1 << 3)
656#define USB_HUB_CHARACTERISTIC_OCPM_NONE (2 << 3)
657#define USB_HUB_CHARACTERISTIC_TTTT (3 << 5)
658#define USB_HUB_CHARACTERISTIC_TTTT_8 (0 << 5)
659#define USB_HUB_CHARACTERISTIC_TTTT_16 (1 << 5)
660#define USB_HUB_CHARACTERISTIC_TTTT_24 (2 << 5)
661#define USB_HUB_CHARACTERISTIC_TTTT_32 (3 << 5)
662#define USB_HUB_CHARACTERISTIC_PORT_INDICATOR (1 << 7)
663
665#define USB_C_HUB_LOCAL_POWER 0
666#define USB_C_HUB_OVER_CURRENT 1
667
669#define USB_PORT_CONNECTION 0
670#define USB_PORT_ENABLE 1
671#define USB_PORT_SUSPEND 2
672#define USB_PORT_OVER_CURRENT 3
673#define USB_PORT_RESET 4
674#define USB_PORT_POWER 8
675#define USB_PORT_LOW_SPEED 9
676#define USB_C_PORT_CONNECTION 16
677#define USB_C_PORT_ENABLE 17
678#define USB_C_PORT_SUSPEND 18
679#define USB_C_PORT_OVER_CURRENT 19
680#define USB_C_PORT_RESET 20
681#define USB_PORT_TEST 21
682#define USB_PORT_INDICATOR 22
683
685#define USB_HUB_REQUEST_GET_STATUS 0
686#define USB_HUB_REQUEST_CLEAR_FEATURE 1
687#define USB_HUB_REQUEST_SET_FEATURE 3
688#define USB_HUB_REQUEST_GET_DESCRIPTOR 6
689#define USB_HUB_REQUEST_SET_DESCRIPTOR 7
690#define USB_HUB_REQUEST_CLEAR_TT_BUFFER 8
691#define USB_HUB_REQUEST_RESET_TT 9
692#define USB_HUB_REQUEST_GET_TT_STATE 10
693#define USB_HUB_REQUEST_STOP_TT 11
694
696#define USB_PORT_STATUS_CONNNECTED (1 << 0)
697#define USB_PORT_STATUS_ENABLED (1 << 1)
698#define USB_PORT_STATUS_SUSPENDED (1 << 2)
699#define USB_PORT_STATUS_OVERCURRENT (1 << 3)
700#define USB_PORT_STATUS_RESET (1 << 4)
701#define USB_PORT_STATUS_POWERED (1 << 8)
702#define USB_PORT_STATUS_LOW_SPEED_ATTACHED (1 << 9)
703#define USB_PORT_STATUS_HIGH_SPEED_ATTACHED (1 << 10)
704#define USB_PORT_STATUS_TEST_MODE (1 << 11)
705#define USB_PORT_STATUS_INDICATOR_CONTROL (1 << 12)
706
708#define USB_PORT_CHANGE_CONNECTED (1 << 0)
709#define USB_PORT_CHANGE_ENABLED (1 << 1)
710#define USB_PORT_CHANGE_SUSPENDED (1 << 2)
711#define USB_PORT_CHANGE_OVERCURRENT (1 << 3)
712#define USB_PORT_CHANGE_RESET (1 << 4)
713
715#define USB_HUB_STATUS_LOCAL_POWER (1 << 0)
716#define USB_HUB_STATUS_OVERCURRENT (1 << 1)
717
719#define USB_HUB_CHANGE_LOCAL_POWER (1 << 0)
720#define USB_HUB_CHANGE_OVERCURRENT (1 << 1)
721
725{
726 uint16_t idvendor;
727 uint16_t idproduct;
728};
729
737
747
755
759{
761 uint8_t brequest;
762 uint16_t wvalue;
763 uint16_t windex;
764 uint16_t wlength;
766
774
794
808
823
835
839{
840 uint8_t blength;
842 uint16_t bstring[];
843} PACKED;
844
845typedef uint16_t USB_STRING_DESCRIPTOR_STRING[126];
846
847typedef uint16_t USB_STRING_DESCRIPTOR_LANGIDS[126];
848
852{
853 uint16_t wstatus;
854} PACKED;
855
857typedef struct _USB_HOST USB_HOST;
858typedef struct _USB_DRIVER USB_DRIVER;
862typedef struct _USB_DEVICE USB_DEVICE;
863
869typedef uint32_t STDCALL (*usb_device_enumerate_cb)(USB_DEVICE *device, void *data);
871typedef uint32_t STDCALL (*usb_device_notification_cb)(DEVICE *device, void *data, uint32_t notification);
872
875
877{
878 // Device Properties
880 // USB Properties
881 uint32_t usbid;
882 uint32_t usbstate;
883 uint32_t usbstatus;
887 // Driver Properties
889 uint32_t address;
890 uint32_t speed;
891 uint32_t depth;
892 uint32_t portnumber;
897 char product[128];
898 char manufacturer[128];
899 char serialnumber[128];
901 uint32_t lasterror;
902 uint32_t pendingcount;
904 // Statistics Properties
905 uint32_t requestcount;
906 uint32_t requesterrors;
907 // Internal Properties
910};
911
921
939
948
951
953typedef uint32_t STDCALL (*usb_driver_enumerate_cb)(USB_DRIVER *driver, void *data);
954
956typedef uint32_t STDCALL (*usb_driver_bind_proc)(USB_DEVICE *device, USB_INTERFACE *interrface);
957typedef uint32_t STDCALL (*usb_driver_unbind_proc)(USB_DEVICE *device, USB_INTERFACE *interrface);
958
960{
961 // Driver Properties
963 // USB Properties
966 // Interface Properties
968 // Internal Properties
971};
972
974typedef struct _USB_REQUEST USB_REQUEST;
975
977typedef uint32_t STDCALL (*usb_host_enumerate_cb)(USB_HOST *host, void *data);
979typedef uint32_t STDCALL (*usb_host_notification_cb)(DEVICE *device, void *data, uint32_t notification);
980
982typedef uint32_t STDCALL (*usb_host_start_proc)(USB_HOST *host);
983typedef uint32_t STDCALL (*usb_host_stop_proc)(USB_HOST *host);
984typedef uint32_t STDCALL (*usb_host_reset_proc)(USB_HOST *host);
985typedef uint32_t STDCALL (*usb_host_submit_proc)(USB_HOST *host, USB_REQUEST *request);
986typedef uint32_t STDCALL (*usb_host_cancel_proc)(USB_HOST *host, USB_REQUEST *request);
987
989{
990 // Device Properties
992 // USB Properties
993 uint32_t hostid;
994 uint32_t hoststate;
1000 // Driver Properties
1003 uint32_t alignment;
1004 uint32_t multiplier;
1005 uint32_t maxtransfer;
1006 // Statistics Properties
1007 uint32_t requestcount;
1008 uint32_t requesterrors;
1009 // Internal Properties
1012};
1013
1015
1018
1020{
1021 // Request Properties
1024 void *data;
1025 uint32_t size;
1026 uint32_t flags;
1029 // Control Properties
1031 uint32_t statusdata;
1032 // Result Properties
1033 uint32_t status;
1034 uint32_t actualsize;
1035 // Driver Properties
1043 uint32_t controlphase;
1044 uint32_t nextdatapid;
1057#ifdef USB_DEBUG
1058 // Debug Statistics
1059 uint32_t startsplitattempts;
1060 uint32_t completesplitattempts;
1061 uint32_t completesplitrestarts;
1062 uint32_t startsplitnaks;
1063 uint32_t completesplitnyets;
1064 uint32_t completesplitnaks;
1065#endif
1066};
1067
1069
1082
1083typedef uint8_t USB_HUB_DESCRIPTOR_DATA[64];
1084
1088{
1089 uint16_t wportstatus;
1090 uint16_t wportchange;
1091} PACKED;
1092
1096{
1097 uint16_t whubstatus;
1098 uint16_t whubchange;
1099} PACKED;
1100
1104{
1105 uint8_t data[8];
1106};
1107
1109typedef struct _USB_HUB USB_HUB;
1110typedef struct _USB_PORT USB_PORT;
1118
1120
1122typedef uint32_t STDCALL (*usb_hub_enumerate_cb)(USB_HUB *hub, void *data);
1124typedef uint32_t STDCALL (*usb_hub_notification_cb)(DEVICE *device, void *data, uint32_t notification);
1125
1128
1130{
1131 // Device Properties
1133 // Hub Properties
1134 uint32_t hubid;
1135 uint32_t hubstate;
1136 // Driver Properties
1140 // Statistics Properties
1143 // USB Properties
1147 uint32_t pendingcount;
1149 // Internal Properties
1152};
1153
1155typedef void STDCALL (*usb_log_output_proc)(const char *text, void *data);
1156
1158
1164uint32_t STDCALL usb_start(void);
1165uint32_t STDCALL usb_stop(void);
1166
1168
1171
1178
1184uint32_t STDCALL usb_device_set_address(USB_DEVICE *device, uint8_t address);
1185
1197uint32_t STDCALL usb_device_get_descriptor(USB_DEVICE *device, uint8_t brequest, uint8_t bmrequesttype, uint16_t wvalue, uint16_t windex, void *data, uint16_t length);
1198
1206uint32_t STDCALL usb_device_get_device_descriptor(USB_DEVICE *device, void *data, uint16_t length);
1207
1214uint32_t STDCALL usb_device_create_device_descriptor(USB_DEVICE *device, uint16_t length);
1215
1222uint32_t STDCALL usb_device_read_device_descriptor(USB_DEVICE *device, uint16_t length);
1223
1230uint32_t STDCALL usb_device_read_device_descriptor_ex(USB_DEVICE *device, uint16_t length, BOOL allowshort);
1231
1238
1245
1253uint32_t STDCALL usb_device_create_configuration(USB_DEVICE *device, uint8_t index, uint16_t size);
1254
1261uint32_t STDCALL usb_device_read_configuration(USB_DEVICE *device, uint8_t index);
1262
1271uint32_t STDCALL usb_device_get_string_descriptor(USB_DEVICE *device, uint8_t index, void *data, uint16_t length);
1272
1282uint32_t STDCALL usb_device_get_string_descriptor_ex(USB_DEVICE *device, uint8_t index, uint16_t languageid, void *data, uint16_t length);
1283
1290
1297uint32_t STDCALL usb_device_read_string_descriptor(USB_DEVICE *device, uint8_t index, char *value, uint32_t len);
1298
1306uint32_t STDCALL usb_device_read_string_descriptor_ex(USB_DEVICE *device, uint8_t index, uint16_t languageid, char *value, uint32_t len);
1307
1314uint32_t STDCALL usb_device_read_string_descriptor_w(USB_DEVICE *device, uint8_t index, WCHAR *value, uint32_t len);
1315
1323uint32_t STDCALL usb_device_read_string_descriptor_ex_w(USB_DEVICE *device, uint8_t index, uint16_t languageid, WCHAR *value, uint32_t len);
1324
1333uint32_t STDCALL usb_device_get_configuration_descriptor(USB_DEVICE *device, uint8_t index, void *data, uint16_t length);
1334
1341uint32_t STDCALL usb_device_get_configuration(USB_DEVICE *device, uint8_t *configurationvalue);
1342
1349uint32_t STDCALL usb_device_set_configuration(USB_DEVICE *device, uint8_t configurationvalue);
1350
1358
1365
1372
1380uint32_t STDCALL usb_device_get_interface(USB_DEVICE *device, uint8_t index, uint8_t *alternatesetting);
1381
1389uint32_t STDCALL usb_device_set_interface(USB_DEVICE *device, uint8_t index, uint8_t alternatesetting);
1390
1398
1412
1425USB_INTERFACE * STDCALL usb_device_find_interface_by_class(USB_DEVICE *device, uint8_t interfaceclass, uint8_t interfacesubclass, uint8_t interfaceprotocol);
1426
1435
1444USB_ENDPOINT_DESCRIPTOR * STDCALL usb_device_find_endpoint_by_type(USB_DEVICE *device, USB_INTERFACE *interrface, uint8_t direction, uint8_t transfertype);
1445
1455USB_ENDPOINT_DESCRIPTOR * STDCALL usb_device_find_endpoint_by_type_ex(USB_DEVICE *device, USB_INTERFACE *interrface, uint8_t direction, uint8_t transfertype, uint8_t *index);
1456
1465uint8_t STDCALL usb_device_count_endpoints_by_type(USB_DEVICE *device, USB_INTERFACE *interrface, uint8_t direction, uint8_t transfertype);
1466
1475
1484
1494
1504USB_ENDPOINT_DESCRIPTOR * STDCALL usb_device_find_alternate_endpoint_by_type(USB_DEVICE *device, USB_INTERFACE *interrface, USB_ALTERNATE *alternate, uint8_t direction, uint8_t transfertype);
1505
1514uint32_t STDCALL usb_device_set_feature(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint16_t feature, uint16_t index);
1515
1524uint32_t STDCALL usb_device_clear_feature(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint16_t feature);
1525
1532uint32_t STDCALL usb_device_set_state(USB_DEVICE *device, uint32_t state);
1533
1540uint32_t STDCALL usb_device_set_status(USB_DEVICE *device, uint32_t status);
1541
1548
1556
1563
1570
1578
1585
1587USB_DEVICE * STDCALL usb_device_find_by_id(uint16_t vendorid, uint16_t productid);
1591
1592uint32_t STDCALL usb_device_notification(USB_DEVICE *device, usb_device_notification_cb callback, void *data, uint32_t notification, uint32_t flags);
1593
1595
1601
1608
1613
1618
1623
1628
1633
1638
1640
1647uint32_t STDCALL usb_host_set_state(USB_HOST *host, uint32_t state);
1648
1654
1661
1666
1671
1676
1677USB_HOST * STDCALL usb_host_find(uint32_t hostid);
1680uint32_t STDCALL usb_host_enumerate(usb_host_enumerate_cb callback, void *data);
1681
1682uint32_t STDCALL usb_host_notification(USB_HOST *host, usb_host_notification_cb callback, void *data, uint32_t notification, uint32_t flags);
1683
1685
1692void * STDCALL usb_buffer_allocate(USB_DEVICE *device, uint32_t size);
1693
1701void * STDCALL usb_buffer_allocate_ex(USB_DEVICE *device, uint32_t size, uint32_t *flags);
1702
1711uint32_t STDCALL usb_buffer_validate(USB_DEVICE *device, void *buffer, uint32_t size, uint32_t *flags);
1712
1718uint32_t STDCALL usb_buffer_release(void *buffer);
1719
1721
1731USB_REQUEST * STDCALL usb_request_allocate(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, usb_request_completed_cb callback, uint32_t size, void *driverdata);
1732
1743USB_REQUEST * STDCALL usb_request_allocate_ex(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, usb_request_completed_cb callback, void *data, uint32_t size, void *driverdata);
1744
1751
1761uint32_t STDCALL usb_request_initialize(USB_REQUEST *request, usb_request_completed_cb callback, void *data, uint32_t size, void *driverdata);
1762
1771
1778
1780
1793uint32_t STDCALL usb_control_request(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint8_t brequest, uint8_t bmrequesttype, uint16_t wvalue, uint16_t windex, void *data, uint16_t wlength);
1794
1809uint32_t STDCALL usb_control_request_ex(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint8_t brequest, uint8_t bmrequesttype, uint16_t wvalue, uint16_t windex, void *data, uint16_t wlength, uint32_t timeout, BOOL allowshort);
1810
1812
1828uint32_t STDCALL usb_control_transfer(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint8_t brequest, uint8_t bmrequesttype, uint16_t wvalue, uint16_t windex, void *data, uint16_t wlength, uint32_t *count, uint32_t timeout);
1829
1841uint32_t STDCALL usb_bulk_transfer(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, void *data, uint32_t size, uint32_t *count, uint32_t timeout);
1842
1854uint32_t STDCALL usb_interrupt_transfer(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, void *data, uint32_t size, uint32_t *count, uint32_t timeout);
1855
1858
1865
1872
1880
1888
1895
1902
1909uint32_t STDCALL usb_hub_set_state(USB_HUB *hub, uint32_t state);
1910
1917
1924
1925USB_HUB * STDCALL usb_hub_find(uint32_t hubid);
1928uint32_t STDCALL usb_hub_enumerate(usb_hub_enumerate_cb callback, void *data);
1929
1930uint32_t STDCALL usb_hub_notification(USB_HUB *hub, usb_hub_notification_cb callback, void *data, uint32_t notification, uint32_t flags);
1931
1938
1946
1953
1955
1962uint32_t STDCALL usb_hub_port_reset(USB_PORT *port, uint32_t delay);
1963
1972
1982
1992
2000
2007uint32_t STDCALL usb_hub_port_set_feature(USB_PORT *port, uint16_t feature);
2008
2015uint32_t STDCALL usb_hub_port_clear_feature(USB_PORT *port, uint16_t feature);
2016
2025uint32_t STDCALL usb_hub_port_change_feature(USB_PORT *port, uint16_t feature, BOOL enable);
2026
2035
2044
2053
2055
2060
2065
2070
2075
2080
2085
2090
2095
2100
2105
2110
2115
2120
2125
2130
2135
2140
2144uint32_t STDCALL usb_status_to_string(uint32_t status, char *string, uint32_t len);
2145
2146uint32_t STDCALL usb_device_type_to_string(uint32_t usbtype, char *string, uint32_t len);
2147uint32_t STDCALL usb_device_state_to_string(uint32_t usbstate, char *string, uint32_t len);
2148uint32_t STDCALL usb_device_status_to_string(uint32_t usbstatus, char *string, uint32_t len);
2149
2154
2159
2160uint32_t STDCALL usb_host_type_to_string(uint32_t hosttype, char *string, uint32_t len);
2161uint32_t STDCALL usb_host_state_to_string(uint32_t hoststate, char *string, uint32_t len);
2162
2167
2173
2179
2189uint32_t STDCALL usb_log_devices_ex(USB_DEVICE *device, usb_log_output_proc output, usb_device_enumerate_cb devicecallback, usb_device_enumerate_cb treecallback, void *data);
2190
2191uint32_t STDCALL usb_log_device_callback(USB_DEVICE *device, void *data);
2192uint32_t STDCALL usb_log_tree_callback(USB_DEVICE *device, void *data);
2193
2195
2200
2205
2210
2215
2220
2225
2230
2235
2239uint32_t STDCALL usb_hub_type_to_string(uint32_t hubtype, char *string, uint32_t len);
2240
2244uint32_t STDCALL usb_hub_state_to_string(uint32_t hubstate, char *string, uint32_t len);
2245
2250
2251#ifdef __cplusplus
2252}
2253#endif
2254
2255#endif // _ULTIBO_USB_H
struct _DEVICE DEVICE
Definition devices.h:373
struct _DRIVER DRIVER
Definition devices.h:465
int32_t LONGBOOL
Compatibility with FPC LongBool type (4 bytes).
Definition globaltypes.h:56
#define STDCALL
Definition globaltypes.h:45
#define PACKED
Definition globaltypes.h:48
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
HANDLE THREAD_HANDLE
Definition globaltypes.h:113
HANDLE SEMAPHORE_HANDLE
Definition globaltypes.h:107
wchar_t WCHAR
Standard WideChar type (2 bytes) (Redeclared here for flexibility).
Definition globaltypes.h:58
HANDLE MUTEX_HANDLE
Definition globaltypes.h:105
Definition usb.h:942
USB_ENDPOINT_DESCRIPTOR * endpoints
All available endpoint descriptors on this alternate setting (Set by USB core).
Definition usb.h:945
char description[128]
Null terminated description string (ASCII encoded, English if available) of this alternate setting.
Definition usb.h:946
USB_INTERFACE_DESCRIPTOR * descriptor
Interface descriptor of this alternate setting (Set by USB core).
Definition usb.h:944
Definition usb.h:798
uint8_t iconfiguration
Definition usb.h:804
uint16_t wtotallength
Definition usb.h:801
uint8_t bconfigurationvalue
Definition usb.h:803
uint8_t bnuminterfaces
Definition usb.h:802
uint8_t bmattributes
Definition usb.h:805
uint8_t bmaxpower
Definition usb.h:806
uint8_t bdescriptortype
Definition usb.h:800
uint8_t blength
Definition usb.h:799
Definition usb.h:915
USB_INTERFACE * interfaces
All available interfaces in this configuration (Set by USB core).
Definition usb.h:918
char description[128]
Null terminated description string (ASCII encoded, English if available) of this configuration.
Definition usb.h:919
USB_CONFIGURATION_DESCRIPTOR * descriptor
Configuration descriptor of this configuration (Set by USB core).
Definition usb.h:917
Definition usb.h:759
uint16_t windex
Definition usb.h:763
uint8_t bmrequesttype
Definition usb.h:760
uint16_t wlength
Definition usb.h:764
uint16_t wvalue
Definition usb.h:762
uint8_t brequest
Definition usb.h:761
Definition usb.h:770
uint8_t bdescriptortype
Definition usb.h:772
uint8_t blength
Definition usb.h:771
Definition usb.h:740
uint16_t idvendor
Definition usb.h:741
uint16_t idproduct
Definition usb.h:742
uint8_t binterfaceprotocol
Definition usb.h:745
uint8_t binterfacesubclass
Definition usb.h:744
uint8_t binterfaceclass
Definition usb.h:743
Definition usb.h:750
uint16_t idvendor
Definition usb.h:751
uint8_t binterfacenumber
Definition usb.h:753
uint16_t idproduct
Definition usb.h:752
Definition usb.h:778
uint8_t imanufacturer
Definition usb.h:789
uint8_t bdeviceprotocol
Definition usb.h:784
uint8_t bdevicesubclass
Definition usb.h:783
uint16_t bcddevice
Definition usb.h:788
uint8_t bdeviceclass
Definition usb.h:782
uint8_t iserialnumber
Definition usb.h:791
uint16_t idvendor
Definition usb.h:786
uint8_t iproduct
Definition usb.h:790
uint16_t idproduct
Definition usb.h:787
uint8_t bmaxpacketsize0
Definition usb.h:785
uint16_t bcdusb
Definition usb.h:781
uint8_t bdescriptortype
Definition usb.h:780
uint8_t bnumconfigurations
Definition usb.h:792
uint8_t blength
Definition usb.h:779
Definition usb.h:725
uint16_t idvendor
Definition usb.h:726
uint16_t idproduct
Definition usb.h:727
Definition usb.h:852
uint16_t wstatus
Definition usb.h:853
Definition usb.h:877
char serialnumber[128]
Null terminated serial number string (ASCII encoded, English if available) of this device.
Definition usb.h:899
uint32_t usbstatus
USB device status (eg USB_STATUS_BOUND).
Definition usb.h:883
MUTEX_HANDLE lock
USB device lock.
Definition usb.h:888
uint32_t speed
Speed at which this device is attached (Set by USB core).
Definition usb.h:890
uint32_t portnumber
1 based index of the USB port on the parent hub this device is plugged into (0 for the Root Hub) (Set...
Definition usb.h:892
uint32_t requestcount
Number of USB requests that have been submitted to this device.
Definition usb.h:905
uint32_t usbid
Unique Id of this USB in the USB device table.
Definition usb.h:881
uint32_t configurationvalue
The current configuration value of this USB device (Set by USB core).
Definition usb.h:893
DEVICE device
The Device entry for this USB device.
Definition usb.h:879
uint32_t lasterror
Last error to occur on this device.
Definition usb.h:901
USB_CONFIGURATION * configuration
Currently selected configuration of this USB device (Set by USB core).
Definition usb.h:895
USB_HOST * host
Host controller this USB device is connected to (Set by USB core).
Definition usb.h:884
uint32_t pendingcount
Number of USB requests pending for this device (Set by USB core).
Definition usb.h:902
void * driverdata
Private data for the driver of this USB device.
Definition usb.h:900
USB_DRIVER * driver
Driver this USB device is bound to, if any (Set by USB core).
Definition usb.h:886
USB_DEVICE * parent
Hub this USB device is connected to, or nil if this is the Root Hub (Set by USB core).
Definition usb.h:885
USB_DEVICE_DESCRIPTOR * descriptor
Device descriptor of this device (Set by USB core).
Definition usb.h:894
uint32_t address
Address of this device (Set by USB core).
Definition usb.h:889
THREAD_ID waiterthread
Thread waiting for pending requests to complete (for device detachment) (Set by USB core).
Definition usb.h:903
char manufacturer[128]
Null terminated manufacturer string (ASCII encoded, English if available) of this device.
Definition usb.h:898
USB_CONFIGURATION * configurations
All available configurations on this device (Set by USB core).
Definition usb.h:896
USB_DEVICE * prev
Previous entry in USB device table.
Definition usb.h:908
uint32_t usbstate
USB device state (eg USB_STATE_ATTACHED).
Definition usb.h:882
char product[128]
Null terminated product string (ASCII encoded, English if available) of this device.
Definition usb.h:897
uint32_t requesterrors
Number of USB requests that have failed on this device.
Definition usb.h:906
USB_DEVICE * next
Next entry in USB device table.
Definition usb.h:909
uint32_t depth
Depth of this device (Root Hub is 0, next level hub is 1 etc) (Set by USB core).
Definition usb.h:891
Definition usb.h:960
MUTEX_HANDLE lock
Driver lock.
Definition usb.h:967
DRIVER driver
The Driver entry for this USB Driver.
Definition usb.h:962
usb_driver_bind_proc driverbind
A Driver specific DriverBind method implementing the standard USB driver interface.
Definition usb.h:964
usb_driver_unbind_proc driverunbind
A Driver specific DriverUnbind method implementing the standard USB driver interface.
Definition usb.h:965
USB_DRIVER * next
Next entry in Driver table.
Definition usb.h:970
USB_DRIVER * prev
Previous entry in Driver table.
Definition usb.h:969
Definition usb.h:827
uint8_t bendpointaddress
Definition usb.h:830
uint8_t bmattributes
Definition usb.h:831
uint8_t binterval
Definition usb.h:833
uint8_t bdescriptortype
Definition usb.h:829
uint16_t wmaxpacketsize
Definition usb.h:832
uint8_t blength
Definition usb.h:828
Definition usb.h:989
uint32_t multiplier
Host data buffer multiplier (for DMA requests etc).
Definition usb.h:1004
MUTEX_HANDLE lock
Host lock.
Definition usb.h:1001
uint32_t hoststate
Host state (eg USBHOST_STATE_ENABLED).
Definition usb.h:994
USB_HOST * next
Next entry in Host table.
Definition usb.h:1011
uint32_t requestcount
Number of USB requests that have been submitted to this host.
Definition usb.h:1007
usb_host_start_proc hoststart
A Host specific HostStart method implementing the standard USB host interface.
Definition usb.h:995
uint32_t maxtransfer
Host maximum transfer size.
Definition usb.h:1005
DEVICE device
The Device entry for this USB Host.
Definition usb.h:991
usb_host_reset_proc hostreset
A Host specific HostReset method implementing the standard USB host interface.
Definition usb.h:997
uint32_t hostid
Unique Id of this Host in the Host table.
Definition usb.h:993
USB_HOST * prev
Previous entry in Host table.
Definition usb.h:1010
USB_DEVICE * roothub
The Root hub for this Host (or nil if the Host has not yet been started).
Definition usb.h:1002
usb_host_submit_proc hostsubmit
A Host specific HostSubmit method implementing the standard USB host interface.
Definition usb.h:998
usb_host_stop_proc hoststop
A Host specific HostStop method implementing the standard USB host interface.
Definition usb.h:996
usb_host_cancel_proc hostcancel
A Host specific HostCancel method implementing the standard USB host interface.
Definition usb.h:999
uint32_t requesterrors
Number of USB requests that have failed on this host.
Definition usb.h:1008
uint32_t alignment
Host data buffer alignment (for DMA requests etc).
Definition usb.h:1003
Definition usb.h:1104
uint8_t data[8]
Definition usb.h:1105
Definition usb.h:1073
uint8_t bdesclength
Definition usb.h:1074
uint8_t bpwron2pwrgood
Definition usb.h:1078
uint8_t vardata[]
Variable length field, 64 should be the maximum possible length (255 ports = 2 x 32 bytes of data).
Definition usb.h:1080
uint8_t bnbrports
Definition usb.h:1076
uint8_t bdescriptortype
Definition usb.h:1075
uint8_t bhubcontrcurrent
Definition usb.h:1079
uint16_t whubcharacteristics
Definition usb.h:1077
Definition usb.h:1096
uint16_t whubstatus
See: USB_HUB_STATUS values above.
Definition usb.h:1097
uint16_t whubchange
See: USB_HUB_CHANGE values above.
Definition usb.h:1098
Definition usb.h:1130
uint32_t hubid
Unique Id of this Hub in the Hub table.
Definition usb.h:1134
USB_PORT * ports
Ports on this hub (Set by USBHubCreatePorts using the value in Descriptor.bNbrPorts).
Definition usb.h:1139
MUTEX_HANDLE lock
Hub lock.
Definition usb.h:1137
uint32_t receiveerrors
Definition usb.h:1142
USB_REQUEST * statusrequest
Hub status change request.
Definition usb.h:1145
DEVICE device
The Device entry for this Hub.
Definition usb.h:1132
uint32_t hubstate
Hub state (eg USBHUB_STATE_ATTACHED).
Definition usb.h:1135
uint32_t receivecount
Definition usb.h:1141
USB_HUB * next
Next entry in Hub table.
Definition usb.h:1151
USB_HUB_DESCRIPTOR * descriptor
Class specific Descriptor for this hub.
Definition usb.h:1138
uint32_t pendingcount
Number of USB requests pending for this hub.
Definition usb.h:1147
USB_HUB * prev
Previous entry in Hub table.
Definition usb.h:1150
THREAD_ID waiterthread
Thread waiting for pending requests to complete (for hub detachment).
Definition usb.h:1148
USB_ENDPOINT_DESCRIPTOR * statusendpoint
Hub Interrupt IN Endpoint.
Definition usb.h:1146
USB_HUB_DATA * statusdata
Hub status change data buffer.
Definition usb.h:1144
Definition usb.h:812
uint8_t iinterface
Definition usb.h:821
uint8_t binterfacenumber
Definition usb.h:815
uint8_t binterfaceprotocol
Definition usb.h:820
uint8_t balternatesetting
Definition usb.h:816
uint8_t binterfacesubclass
Definition usb.h:819
uint8_t bnumendpoints
Definition usb.h:817
uint8_t bdescriptortype
Definition usb.h:814
uint8_t blength
Definition usb.h:813
uint8_t binterfaceclass
Definition usb.h:818
Definition usb.h:732
uint8_t binterfaceprotocol
Definition usb.h:735
uint8_t binterfacesubclass
Definition usb.h:734
uint8_t binterfaceclass
Definition usb.h:733
Definition usb.h:925
uint8_t * classdata
Pointer to the start of any class specific descriptors for this interface (Set by USB core).
Definition usb.h:935
uint32_t classsize
Size of any class specific descriptors for this interface (Set by USB core).
Definition usb.h:936
uint32_t alternatecount
The number of alternate settings available for this interface (Set by USB core).
Definition usb.h:929
USB_ENDPOINT_DESCRIPTOR * endpoints
All available endpoint descriptors on this interface (Set by USB core).
Definition usb.h:932
USB_ALTERNATE * alternates
All available alternate settings for this interface (Set by USB core).
Definition usb.h:933
void * driverdata
Private data for the driver of this USB interface.
Definition usb.h:937
char description[128]
Null terminated description string (ASCII encoded, English if available) of this interface.
Definition usb.h:934
USB_DRIVER * driver
Driver this USB interface is bound to, if any (Set by USB core).
Definition usb.h:927
USB_INTERFACE_DESCRIPTOR * descriptor
Interface descriptor of this interface (Set by USB core).
Definition usb.h:931
uint32_t alternatesetting
The currently selected alternate setting for this interface (Set by USB core).
Definition usb.h:930
Definition usb.h:1088
uint16_t wportstatus
See: USB_PORT_STATUS values above.
Definition usb.h:1089
uint16_t wportchange
See: USB_PORT_CHANGE values above.
Definition usb.h:1090
Definition usb.h:1112
USB_PORT_STATUS status
Status of this port.
Definition usb.h:1116
USB_DEVICE * child
Pointer to the USB device attached to this port, or nil if there is none.
Definition usb.h:1115
USB_HUB * hub
Pointer to the USB hub this port is attached to.
Definition usb.h:1113
uint8_t number
Number of this port (1-based).
Definition usb.h:1114
Definition usb.h:1020
LONGBOOL shortattempt
The current transaction for this request is a short read or write.
Definition usb.h:1041
LONGBOOL completesplit
On a split transaction indicates if the request is on the start split or complete split phase.
Definition usb.h:1040
uint32_t attemptedbytesremaining
The number of bytes remaining in the current transaction.
Definition usb.h:1048
uint32_t actualsize
Actual size of the data transferred (Should be checked after a successful IN request).
Definition usb.h:1034
uint32_t attemptedpacketsremaining
The number of packets remaining in the current transaction.
Definition usb.h:1047
uint32_t attemptedbytes
The number of bytes attempted in the current transaction.
Definition usb.h:1046
LONGBOOL issplit
Request is a split transaction due to full or low speed device.
Definition usb.h:1039
uint32_t totalbytesattempted
The total number of bytes attempted for this request.
Definition usb.h:1050
LONGBOOL isping
Ping request in progress as part of request processing.
Definition usb.h:1038
void * data
Data buffer for the request (IN or OUT).
Definition usb.h:1024
uint32_t flags
Flags for the request (eg USB_REQUEST_FLAG_ALIGNED).
Definition usb.h:1026
USB_DEVICE * device
USB Device to send this request to.
Definition usb.h:1022
uint32_t completesplitretries
The number of complete split retries for this request.
Definition usb.h:1054
uint32_t attemptedpackets
The number of packets attempted in the current transaction.
Definition usb.h:1045
uint32_t totalpacketsattempted
The total number of packets attempted for this request.
Definition usb.h:1049
uint32_t packetstransferred
The number of packets transferred for this request.
Definition usb.h:1051
void * driverdata
USB device driver private data for the completion callback (Optional).
Definition usb.h:1028
uint32_t bytestransferred
The number of bytes transferred for this request.
Definition usb.h:1052
LONGBOOL startofframe
The request needs to wait for the next start of frame to be started.
Definition usb.h:1042
uint32_t size
Size of data buffer (For IN requests, the maximum number of bytes of data to receive) (For OUT reques...
Definition usb.h:1025
uint32_t statusdata
Data for the Status phase of a USB control request (For safety only as no data is normally transferre...
Definition usb.h:1031
USB_CONTROL_SETUP_DATA * setupdata
Data for the Setup phase of a USB control request (Must be provided for control requests,...
Definition usb.h:1030
void * currentdata
Host driver data pointer during transaction processing.
Definition usb.h:1037
uint32_t controlphase
The currently processing phase of a control request.
Definition usb.h:1043
SEMAPHORE_HANDLE resubmitsemaphore
The handle of the semaphore used to signal the resubmit thread (or INVALID_HANDLE_VALUE).
Definition usb.h:1056
void * transferdata
Host driver private data for transfer handling.
Definition usb.h:1036
uint32_t nextdatapid
The next Data PID for the data toggle during IN or OUT (Data0/Data1 etc).
Definition usb.h:1044
uint32_t spliterrorcount
The number of split transaction errors for this request.
Definition usb.h:1053
usb_request_completed_cb callback
Callback function that will be called when this USB request has been successfully completed or has fa...
Definition usb.h:1027
uint32_t status
Status of the transfer (USB_STATUS_SUCCESS if successful, or another error code if the transfer faile...
Definition usb.h:1033
THREAD_HANDLE resubmitthread
The handle of the thread performing resubmit for this request (or INVALID_HANDLE_VALUE).
Definition usb.h:1055
USB_ENDPOINT_DESCRIPTOR * endpoint
Endpoint descriptor on the device to send this request to.
Definition usb.h:1023
Definition usb.h:839
uint16_t bstring[]
UTF-16LE encoded string (specification says "UNICODE").
Definition usb.h:842
uint8_t bdescriptortype
Definition usb.h:841
uint8_t blength
Definition usb.h:840
HANDLE THREAD_ID
Type for Thread-IDs.
Definition system.h:63
uint32_t STDCALL usb_interrupt_transfer(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, void *data, uint32_t size, uint32_t *count, uint32_t timeout)
Perform a synchronous interrupt transfer to a USB device and endpoint.
USB_DRIVER *STDCALL usb_driver_create(void)
Driver Methods.
uint32_t STDCALL usb_hub_unlock(USB_HUB *hub)
Unlock the specified Hub to allow changes.
uint32_t STDCALL usb_device_read_string_descriptor_ex(USB_DEVICE *device, uint8_t index, uint16_t languageid, char *value, uint32_t len)
Get the content of the specified string descriptor from the specified device.
uint32_t STDCALL usb_device_status_to_notification(uint32_t status)
Convert a Device status value into the notification code for device notifications.
BOOL STDCALL usb_hub_has_port_indicator(USB_HUB *hub)
Returns True if Hub supports Port Indicators or False if not.
void STDCALL usb_log_device_configuration(USB_DEVICE *device, usb_log_output_proc output, void *data)
USB_HOST *STDCALL usb_host_find_by_name(const char *name)
USB_HOST *STDCALL usb_host_find(uint32_t hostid)
USB_HUB *STDCALL usb_hub_find(uint32_t hubid)
struct _USB_DRIVER USB_DRIVER
Forward declared to satisfy USBDevice.
Definition usb.h:858
struct _USB_PORT_STATUS USB_PORT_STATUS
Definition usb.h:1086
uint32_t STDCALL usb_start(void)
Starts all registered USB hosts, starts the USB hub thread and begins the USB enumeration process....
USB_HOST *STDCALL usb_host_create(void)
Create a new Host entry.
uint32_t STDCALL usb_device_attach(USB_DEVICE *device)
Configure and initialize a newly attached USB device.
uint32_t STDCALL usb_host_enumerate(usb_host_enumerate_cb callback, void *data)
uint32_t STDCALL(* usb_device_enumerate_cb)(USB_DEVICE *device, void *data)
Definition usb.h:869
USB_DRIVER *STDCALL usb_driver_check(USB_DRIVER *driver)
Check if the supplied USB Driver is in the driver table.
struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR
Definition usb.h:796
uint32_t STDCALL usb_log_devices(void)
Print information about all devices attached to the USB.
USB_DEVICE *STDCALL usb_device_find(uint32_t usbid)
void STDCALL usb_hub_enumerate_devices(USB_DEVICE *device, usb_device_enumerate_cb callback, void *data)
Enumerate each device in the USB tree and call an enumerate callback for each one.
uint32_t STDCALL usb_request_cancel(USB_REQUEST *request)
Cancel a USB request previously submitted to a host controller.
BOOL STDCALL usb_is_in_endpoint(USB_ENDPOINT_DESCRIPTOR *endpoint)
Returns True if Endpoint is an IN endpoint or False if not.
BOOL STDCALL usb_hub_is_multi_tt(USB_HUB *hub)
Returns True if Hub has multiple Transaction Translators or False if not.
uint32_t STDCALL usb_driver_get_count(void)
Get the current USB driver count.
uint32_t STDCALL usb_device_get_interface(USB_DEVICE *device, uint8_t index, uint8_t *alternatesetting)
Get the interface alternate setting for the specified device.
uint32_t STDCALL usb_log_devices_ex(USB_DEVICE *device, usb_log_output_proc output, usb_device_enumerate_cb devicecallback, usb_device_enumerate_cb treecallback, void *data)
Print information about one or all devices attached to the USB with custom output and callbacks.
uint32_t STDCALL usb_bulk_transfer(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, void *data, uint32_t size, uint32_t *count, uint32_t timeout)
Perform a synchronous bulk transfer to a USB device and endpoint.
void STDCALL usb_hub_unbind_devices(USB_DEVICE *device, USB_DRIVER *driver, usb_device_unbind_proc callback)
Enumerate each device in the USB tree and call an unbind callback for each one.
uint32_t STDCALL usb_device_set_status(USB_DEVICE *device, uint32_t status)
Set the status of the specified device and send a notification.
uint32_t STDCALL usb_hub_port_reset(USB_PORT *port, uint32_t delay)
Hub Port Methods.
uint32_t STDCALL usb_device_read_configuration(USB_DEVICE *device, uint8_t index)
Read and parse the specified configuration for this device.
uint32_t STDCALL usb_log_tree_callback(USB_DEVICE *device, void *data)
uint32_t STDCALL usb_hub_create_ports(USB_HUB *hub)
Hub Methods.
uint32_t STDCALL usb_host_notification(USB_HOST *host, usb_host_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
void STDCALL(* usb_request_completed_cb)(USB_REQUEST *request)
Definition usb.h:1017
uint32_t STDCALL usb_control_request_ex(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint8_t brequest, uint8_t bmrequesttype, uint16_t wvalue, uint16_t windex, void *data, uint16_t wlength, uint32_t timeout, BOOL allowshort)
Send a USB control request to the specified device and wait for the request to complete.
USB_DEVICE *STDCALL usb_device_find_by_id(uint16_t vendorid, uint16_t productid)
USB_PORT *STDCALL usb_device_get_port(USB_DEVICE *device)
Get the USB Port that the specified device is connected to.
USB_DEVICE *STDCALL usb_device_find_by_description(const char *description)
BOOL STDCALL usb_hub_has_port_current_protection(USB_HUB *hub)
Returns True if Hub supports per port Over Current Power Protection or False if not.
struct _USB_DEVICE_ID USB_DEVICE_ID
USB Device Id record for driver device identification (Not part of USB specification).
Definition usb.h:723
uint32_t STDCALL(* usb_driver_bind_proc)(USB_DEVICE *device, USB_INTERFACE *interrface)
Definition usb.h:956
uint32_t STDCALL usb_control_request(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint8_t brequest, uint8_t bmrequesttype, uint16_t wvalue, uint16_t windex, void *data, uint16_t wlength)
Control Methods.
uint32_t STDCALL usb_device_read_string_descriptor_ex_w(USB_DEVICE *device, uint8_t index, uint16_t languageid, WCHAR *value, uint32_t len)
Get the content of the specified string descriptor from the specified device.
struct _USB_PORT USB_PORT
Definition usb.h:1110
uint32_t STDCALL usb_buffer_release(void *buffer)
Release a data buffer from a USB request.
void STDCALL usb_hub_bind_devices(USB_DEVICE *device, usb_device_bind_proc callback)
Enumerate each device in the USB tree and call a bind callback for each one.
USB_DRIVER *STDCALL usb_driver_find_by_name(const char *name)
Find a driver by name in the Driver table.
USB_ENDPOINT_DESCRIPTOR *STDCALL usb_device_find_alternate_endpoint_by_type(USB_DEVICE *device, USB_INTERFACE *interrface, USB_ALTERNATE *alternate, uint8_t direction, uint8_t transfertype)
Find an endpoint of the specified type and direction on the specified alternate setting interface of ...
uint32_t STDCALL usb_device_bind(USB_DEVICE *device)
Attempt to bind a device to one of the registered drivers.
uint32_t STDCALL usb_device_read_device_descriptor(USB_DEVICE *device, uint16_t length)
Read all or part of the device descriptor from the specified device using USBControlRequest.
USB_ENDPOINT_DESCRIPTOR *STDCALL usb_device_find_endpoint_by_type_ex(USB_DEVICE *device, USB_INTERFACE *interrface, uint8_t direction, uint8_t transfertype, uint8_t *index)
Find the next endpoint of the specified type and direction on the specified interface of the specifie...
uint32_t STDCALL usb_device_release(USB_DEVICE *device)
Deregister and Destroy a Device from the Device table.
uint32_t STDCALL usb_hub_port_power_off(USB_PORT *port)
Power off the specified USB port.
uint32_t STDCALL usb_hub_set_state(USB_HUB *hub, uint32_t state)
Set the state of the specified hub and send a notification.
BOOL STDCALL usb_hub_is_compound(USB_HUB *hub)
Returns True if Hub is part of a Compound Device or False if not.
uint32_t STDCALL usb_device_clear_feature(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint16_t feature)
Disable a feature on the specified endpoint on the specified device.
uint32_t STDCALL usb_hub_enumerate(usb_hub_enumerate_cb callback, void *data)
void STDCALL usb_device_read_string_language_ids(USB_DEVICE *device, USB_STRING_DESCRIPTOR_LANGIDS *languageids)
Get the list of supported string language identifiers from the specified device.
uint32_t STDCALL usb_device_get_device_descriptor(USB_DEVICE *device, void *data, uint16_t length)
Read all or part of the device descriptor from the specified device using USBControlRequest.
BOOL STDCALL usb_is_root_hub(USB_DEVICE *device)
Returns True if Device is a Root Hub or False if not.
struct _USB_INTERFACE_ID USB_INTERFACE_ID
USB Interface Id record for driver device identification (Not part of USB specification).
Definition usb.h:730
uint32_t STDCALL usb_device_read_string_descriptor_w(USB_DEVICE *device, uint8_t index, WCHAR *value, uint32_t len)
Get the content of the specified string descriptor from the specified device.
uint32_t STDCALL(* usb_host_start_proc)(USB_HOST *host)
Definition usb.h:982
uint32_t STDCALL usb_device_notification(USB_DEVICE *device, usb_device_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
void STDCALL usb_log_interface_descriptor(USB_DEVICE *device, USB_INTERFACE_DESCRIPTOR *descriptor, usb_log_output_proc output, void *data)
uint32_t STDCALL usb_hub_create_hub_descriptor(USB_HUB *hub)
Allocate the hub descriptor for the specified hub.
uint32_t STDCALL usb_host_state_to_notification(uint32_t state)
Convert a Host state value into the notification code for device notifications.
USB_HOST *STDCALL usb_host_create_ex(uint32_t size)
Create a new Host entry.
uint32_t STDCALL usb_host_register(USB_HOST *host)
Register a new Host in the Host table.
BOOL STDCALL usb_is_isochronous_endpoint(USB_ENDPOINT_DESCRIPTOR *endpoint)
Returns True if Endpoint is a ISOCHRONOUS endpoint or False if not.
uint8_t STDCALL usb_device_count_endpoints_by_type(USB_DEVICE *device, USB_INTERFACE *interrface, uint8_t direction, uint8_t transfertype)
Count the number of endpoints of the specified type and direction on the specified interface of the s...
struct _USB_ENDPOINT_DESCRIPTOR USB_ENDPOINT_DESCRIPTOR
Definition usb.h:825
struct _USB_DEVICE USB_DEVICE
Definition usb.h:862
struct _USB_INTERFACE USB_INTERFACE
Forward declared to satisfy USBDevice.
Definition usb.h:860
uint32_t STDCALL usb_hub_port_change_feature(USB_PORT *port, uint16_t feature, BOOL enable)
Enable or disable a feature on the specified USB port.
uint32_t STDCALL(* usb_host_notification_cb)(DEVICE *device, void *data, uint32_t notification)
Definition usb.h:979
uint32_t STDCALL(* usb_hub_enumerate_cb)(USB_HUB *hub, void *data)
Definition usb.h:1122
void *STDCALL usb_buffer_allocate_ex(USB_DEVICE *device, uint32_t size, uint32_t *flags)
Allocate a data buffer for a USB request.
uint32_t STDCALL usb_device_set_configuration(USB_DEVICE *device, uint8_t configurationvalue)
Set the configuration for the specified device.
uint32_t STDCALL usb_hub_lock(USB_HUB *hub)
Lock the specified Hub to prevent changes.
uint32_t STDCALL usb_driver_destroy(USB_DRIVER *driver)
Destroy an existing USB Driver entry.
uint32_t STDCALL usb_hub_port_attach_device(USB_PORT *port)
Attach a newly connected USB device to the specified USB port.
struct _USB_HUB_DESCRIPTOR USB_HUB_DESCRIPTOR
Definition usb.h:1071
USB_HOST *STDCALL usb_host_find_by_description(const char *description)
uint32_t STDCALL usb_device_set_interface(USB_DEVICE *device, uint8_t index, uint8_t alternatesetting)
Set the interface alternate setting for the specified device.
struct _USB_HUB_STATUS USB_HUB_STATUS
Definition usb.h:1094
uint32_t STDCALL(* usb_device_unbind_proc)(USB_DEVICE *device, USB_DRIVER *driver)
Definition usb.h:867
uint32_t STDCALL usb_hub_power_on_ports(USB_HUB *hub)
Power on all ports on a Hub.
uint32_t STDCALL usb_device_get_count(void)
Get the current device count.
struct _USB_DEVICE_STATUS USB_DEVICE_STATUS
Definition usb.h:850
uint32_t STDCALL usb_device_get_configuration(USB_DEVICE *device, uint8_t *configurationvalue)
Get the current configuration for the specified device.
uint32_t STDCALL usb_host_state_to_string(uint32_t hoststate, char *string, uint32_t len)
uint32_t STDCALL(* usb_host_cancel_proc)(USB_HOST *host, USB_REQUEST *request)
Definition usb.h:986
uint32_t STDCALL usb_driver_enumerate(usb_driver_enumerate_cb callback, void *data)
Enumerate all drivers in the USB Driver table.
USB_HOST *STDCALL usb_host_check(USB_HOST *host)
Check if the supplied Host is in the host table.
void STDCALL usb_async_start(USB_HOST *host)
BOOL STDCALL usb_hub_has_port_power_switching(USB_HUB *hub)
Returns True if Hub supports per port Power Switching or False if not.
struct _USB_DEVICE_DESCRIPTOR USB_DEVICE_DESCRIPTOR
Definition usb.h:776
uint32_t STDCALL usb_hub_port_clear_feature(USB_PORT *port, uint16_t feature)
Disable a feature on the specified USB port.
uint32_t STDCALL usb_device_status_to_string(uint32_t usbstatus, char *string, uint32_t len)
USB_INTERFACE *STDCALL usb_device_find_interface_by_class_only(USB_DEVICE *device, uint8_t interfaceclass)
Find an interface of the specified class on the specified device.
uint32_t STDCALL usb_device_set_address(USB_DEVICE *device, uint8_t address)
Set the bus address for the specified device.
uint32_t STDCALL(* usb_device_bind_proc)(USB_DEVICE *device)
Definition usb.h:865
uint32_t STDCALL usb_device_state_to_notification(uint32_t state)
Convert a Device state value into the notification code for device notifications.
USB_HUB *STDCALL usb_hub_find_by_name(const char *name)
USB_ALTERNATE *STDCALL usb_device_find_alternate_by_setting(USB_DEVICE *device, USB_INTERFACE *interrface, uint8_t alternatesetting)
Find the alternate setting with the specified value on the specified interface of the specified devic...
struct _USB_CONFIGURATION USB_CONFIGURATION
Forward declared to satisfy USBDevice.
Definition usb.h:861
void STDCALL usb_log_endpoint_descriptor(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *descriptor, usb_log_output_proc output, void *data)
uint32_t STDCALL usb_hub_state_to_string(uint32_t hubstate, char *string, uint32_t len)
Return a string describing the supplied Hub state value.
struct _USB_DEVICE_AND_INTERFACE_NO USB_DEVICE_AND_INTERFACE_NO
USB Device and Interface No record for driver device identification (Not part of USB specification).
Definition usb.h:748
BOOL STDCALL usb_is_interrupt_request(USB_REQUEST *request)
Returns True if Request is an interrupt request or False if not.
uint16_t USB_STRING_DESCRIPTOR_STRING[126]
Array type to allow typecasting of bString element in TUSBStringDescriptor (Maximum size of descripto...
Definition usb.h:845
USB_DEVICE *STDCALL usb_device_check(USB_DEVICE *device)
Check if the supplied Device is in the device table.
uint32_t STDCALL usb_device_get_string_descriptor(USB_DEVICE *device, uint8_t index, void *data, uint16_t length)
Read all or part of the specified string descriptor from the specified device using USBControlRequest...
BOOL STDCALL usb_is_bulk_request(USB_REQUEST *request)
Returns True if Request is a bulk request or False if not.
uint32_t STDCALL usb_device_create_configuration(USB_DEVICE *device, uint8_t index, uint16_t size)
Allocate the specified configuration for this device.
uint32_t STDCALL usb_host_destroy(USB_HOST *host)
Destroy an existing Host entry.
uint32_t STDCALL usb_device_type_to_string(uint32_t usbtype, char *string, uint32_t len)
uint32_t STDCALL usb_device_get_string_descriptor_ex(USB_DEVICE *device, uint8_t index, uint16_t languageid, void *data, uint16_t length)
Read all or part of the specified string descriptor from the specified device using USBControlRequest...
uint32_t STDCALL(* usb_host_stop_proc)(USB_HOST *host)
Definition usb.h:983
uint32_t STDCALL usb_device_read_device_descriptor_ex(USB_DEVICE *device, uint16_t length, BOOL allowshort)
Read all or part of the device descriptor from the specified device using USBControlRequest.
uint32_t STDCALL usb_status_to_string(uint32_t status, char *string, uint32_t len)
Translates a USB status code into a string.
USB_REQUEST *STDCALL usb_request_allocate_ex(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, usb_request_completed_cb callback, void *data, uint32_t size, void *driverdata)
Allocate a new USB request.
void STDCALL usb_log_configuration_descriptor(USB_DEVICE *device, USB_CONFIGURATION_DESCRIPTOR *descriptor, usb_log_output_proc output, void *data)
uint32_t STDCALL usb_stop(void)
uint32_t STDCALL usb_driver_register(USB_DRIVER *driver)
Register a new Driver in the USB Driver table.
uint32_t STDCALL usb_hub_port_get_status(USB_PORT *port)
Read the status of the specified USB port.
USB_HUB *STDCALL usb_hub_find_by_description(const char *description)
uint32_t STDCALL usb_hub_port_set_feature(USB_PORT *port, uint16_t feature)
Enable a feature on the specified USB port.
uint32_t STDCALL usb_hub_read_hub_descriptor(USB_HUB *hub)
Read the hub descriptor for the specified hub.
USB_DRIVER *STDCALL usb_driver_create_ex(uint32_t size)
Create a new USB Driver entry.
uint32_t STDCALL usb_device_unbind(USB_DEVICE *device, USB_DRIVER *driver)
Unbind a device from a driver.
struct _USB_DEVICE_AND_INTERFACE_ID USB_DEVICE_AND_INTERFACE_ID
USB Device and Interface Id record for driver device identification (Not part of USB specification).
Definition usb.h:738
void *STDCALL usb_buffer_allocate(USB_DEVICE *device, uint32_t size)
Buffer Methods.
uint8_t USB_HUB_DESCRIPTOR_DATA[64]
Array type to allow typecasting of varData element in TUSBHubDescriptor.
Definition usb.h:1083
struct _USB_HUB_DATA USB_HUB_DATA
Definition usb.h:1102
uint32_t STDCALL usb_host_type_to_string(uint32_t hosttype, char *string, uint32_t len)
uint32_t STDCALL usb_hub_port_power_on(USB_PORT *port)
Power on the specified USB port.
uint32_t STDCALL usb_hub_port_status_changed(USB_PORT *port)
Process a status change for the specified USB port.
struct _USB_REQUEST USB_REQUEST
Forward declared to satisfy USBHost.
Definition usb.h:974
USB_INTERFACE *STDCALL usb_device_find_interface_by_index(USB_DEVICE *device, uint8_t index)
Find the interface with the specified index on the specified device.
uint32_t STDCALL usb_device_enumerate(usb_device_enumerate_cb callback, void *data)
uint32_t STDCALL usb_request_initialize(USB_REQUEST *request, usb_request_completed_cb callback, void *data, uint32_t size, void *driverdata)
Initialize or Reinitialize an existing USB request.
uint32_t STDCALL usb_request_release(USB_REQUEST *request)
Release and destroy a USB request.
USB_DEVICE *STDCALL usb_device_allocate(USB_HOST *host, USB_DEVICE *parent)
Create and Register a new Device entry in the Device table.
uint32_t STDCALL usb_hub_get_count(void)
Get the current hub count.
uint32_t STDCALL(* usb_host_enumerate_cb)(USB_HOST *host, void *data)
Definition usb.h:977
USB_DEVICE *STDCALL usb_device_find_by_name(const char *name)
uint32_t STDCALL usb_request_submit(USB_REQUEST *request)
Submit a USB request to a host controller for execution.
uint32_t STDCALL usb_device_get_descriptor(USB_DEVICE *device, uint8_t brequest, uint8_t bmrequesttype, uint16_t wvalue, uint16_t windex, void *data, uint16_t length)
Read any descriptor from the specified device using USBControlRequest.
uint32_t STDCALL usb_device_detach(USB_DEVICE *device)
Shutdown and detach a USB device.
uint32_t STDCALL usb_host_get_count(void)
Get the current host count.
uint32_t STDCALL usb_device_read_string_descriptor(USB_DEVICE *device, uint8_t index, char *value, uint32_t len)
Get the content of the specified string descriptor from the specified device.
USB_DRIVER *STDCALL usb_driver_find(uint32_t driverid)
Find a driver by Id in the USB Driver table.
struct _USB_STRING_DESCRIPTOR USB_STRING_DESCRIPTOR
Definition usb.h:837
USB_HUB *STDCALL usb_hub_allocate(USB_DEVICE *device)
Create and Register a new Hub device.
uint32_t STDCALL usb_device_create_configurations(USB_DEVICE *device)
Allocate the available configurations for this device.
uint32_t STDCALL usb_hub_notification(USB_HUB *hub, usb_hub_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
uint32_t STDCALL usb_hub_port_disable(USB_PORT *port)
Disable the specified USB port.
USB_ALTERNATE *STDCALL usb_device_find_alternate_by_index(USB_DEVICE *device, USB_INTERFACE *interrface, uint8_t index)
Find the alternate setting with the specified index on the specified interface of the specified devic...
uint32_t STDCALL usb_control_transfer(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint8_t brequest, uint8_t bmrequesttype, uint16_t wvalue, uint16_t windex, void *data, uint16_t wlength, uint32_t *count, uint32_t timeout)
Synchronous Transfer Methods.
uint32_t STDCALL usb_host_set_state(USB_HOST *host, uint32_t state)
Host Methods.
USB_HUB *STDCALL usb_device_get_hub(USB_DEVICE *device)
Get the USB Hub that the specified device is connected to.
uint32_t STDCALL usb_hub_release(USB_HUB *hub)
Deregister and Destroy a Hub device.
uint32_t STDCALL usb_device_state_to_string(uint32_t usbstate, char *string, uint32_t len)
uint32_t STDCALL usb_hub_state_to_notification(uint32_t state)
Convert a Hub state value into the notification code for device notifications.
struct _USB_INTERFACE_DESCRIPTOR USB_INTERFACE_DESCRIPTOR
Definition usb.h:810
BOOL STDCALL usb_is_interrupt_endpoint(USB_ENDPOINT_DESCRIPTOR *endpoint)
Returns True if Endpoint is a INTERRUPT endpoint or False if not.
USB_CONFIGURATION *STDCALL usb_device_find_configuration_by_value(USB_DEVICE *device, uint8_t configurationvalue)
Find the configuration represented by configuration value for the specified device.
BOOL STDCALL usb_is_control_request(USB_REQUEST *request)
Returns True if Request is a control request or False if not.
uint8_t STDCALL usb_hub_get_tt_think_time(USB_HUB *hub)
Get the TT Think Time from a Hub.
USB_ENDPOINT_DESCRIPTOR *STDCALL usb_device_find_alternate_endpoint_by_index(USB_DEVICE *device, USB_INTERFACE *interrface, USB_ALTERNATE *alternate, uint8_t index)
Find the endpoint with the specified index on the specified alternate setting interface of the specif...
BOOL STDCALL usb_is_out_endpoint(USB_ENDPOINT_DESCRIPTOR *endpoint)
Returns True if Endpoint is an OUT endpoint or False if not.
uint32_t STDCALL usb_device_get_configuration_descriptor(USB_DEVICE *device, uint8_t index, void *data, uint16_t length)
Read all or part of the specified configuration descriptor from the specified device using USBControl...
uint32_t STDCALL usb_log_device_callback(USB_DEVICE *device, void *data)
void STDCALL usb_log_device_descriptor(USB_DEVICE *device, USB_DEVICE_DESCRIPTOR *descriptor, usb_log_output_proc output, void *data)
void STDCALL(* usb_log_output_proc)(const char *text, void *data)
Definition usb.h:1155
USB_ENDPOINT_DESCRIPTOR *STDCALL usb_device_find_endpoint_by_type(USB_DEVICE *device, USB_INTERFACE *interrface, uint8_t direction, uint8_t transfertype)
Find an endpoint of the specified type and direction on the specified interface of the specified devi...
uint32_t STDCALL usb_host_deregister(USB_HOST *host)
Deregister a Host from the Host table.
struct _USB_ALTERNATE USB_ALTERNATE
Forward declared to satisfy USBDevice.
Definition usb.h:859
uint32_t STDCALL usb_device_set_feature(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, uint16_t feature, uint16_t index)
Enable a feature on the specified endpoint on the specified device.
BOOL STDCALL usb_is_bulk_endpoint(USB_ENDPOINT_DESCRIPTOR *endpoint)
Returns True if Endpoint is a BULK endpoint or False if not.
uint32_t STDCALL(* usb_device_notification_cb)(DEVICE *device, void *data, uint32_t notification)
Definition usb.h:871
uint32_t STDCALL usb_driver_deregister(USB_DRIVER *driver)
Deregister a Driver from the USB Driver table.
uint32_t STDCALL(* usb_driver_unbind_proc)(USB_DEVICE *device, USB_INTERFACE *interrface)
Definition usb.h:957
uint32_t STDCALL(* usb_hub_notification_cb)(DEVICE *device, void *data, uint32_t notification)
Definition usb.h:1124
uint32_t STDCALL usb_hub_port_detach_device(USB_PORT *port)
Detach a disconnected USB device from the specified USB port.
struct _USB_HUB USB_HUB
Forward declared to satisfy USBPort.
Definition usb.h:1109
uint16_t USB_STRING_DESCRIPTOR_LANGIDS[126]
Array type to allow typecasting of bString element in TUSBStringDescriptor (Maximum size of descripto...
Definition usb.h:847
BOOL STDCALL usb_is_isochronous_request(USB_REQUEST *request)
Returns True if Request is an isochronous request or False if not.
uint32_t STDCALL usb_device_set_state(USB_DEVICE *device, uint32_t state)
Set the state of the specified device and send a notification.
USB_HUB *STDCALL usb_hub_check(USB_HUB *hub)
Check if the supplied Hub is in the hub table.
uint32_t STDCALL usb_hub_type_to_string(uint32_t hubtype, char *string, uint32_t len)
Return a string describing the supplied Hub type value.
struct _USB_HOST USB_HOST
Forward declared to satisfy USBDevice.
Definition usb.h:857
uint32_t STDCALL(* usb_host_reset_proc)(USB_HOST *host)
Definition usb.h:984
uint32_t STDCALL usb_device_create_device_descriptor(USB_DEVICE *device, uint16_t length)
Allocate a device descriptor for the specified device.
struct _USB_DESCRIPTOR_HEADER USB_DESCRIPTOR_HEADER
Definition usb.h:768
uint32_t STDCALL(* usb_driver_enumerate_cb)(USB_DRIVER *driver, void *data)
Definition usb.h:953
uint32_t STDCALL usb_buffer_validate(USB_DEVICE *device, void *buffer, uint32_t size, uint32_t *flags)
Validate a data buffer for a USB request against the USB host requirements.
USB_INTERFACE *STDCALL usb_device_find_interface_by_class(USB_DEVICE *device, uint8_t interfaceclass, uint8_t interfacesubclass, uint8_t interfaceprotocol)
Find an interface of the specified class on the specified device.
uint8_t STDCALL usb_device_get_address(USB_DEVICE *device)
Device Methods.
USB_REQUEST *STDCALL usb_request_allocate(USB_DEVICE *device, USB_ENDPOINT_DESCRIPTOR *endpoint, usb_request_completed_cb callback, uint32_t size, void *driverdata)
Request Methods.
uint32_t STDCALL usb_device_read_configurations(USB_DEVICE *device)
Read and parse the available configurations for this device.
USB_ENDPOINT_DESCRIPTOR *STDCALL usb_device_find_endpoint_by_index(USB_DEVICE *device, USB_INTERFACE *interrface, uint8_t index)
Find the endpoint with the specified index on the specified interface of the specified device.
uint32_t STDCALL(* usb_host_submit_proc)(USB_HOST *host, USB_REQUEST *request)
Definition usb.h:985
struct _USB_CONTROL_SETUP_DATA USB_CONTROL_SETUP_DATA
Definition usb.h:757
BOOL STDCALL usb_is_hub(USB_DEVICE *device)
Returns True if Device is a Hub or False if not.