USBLibAPIGuide  1.00.00.01
usblib.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usblib.h - Main header file for the USB Library.
4 //
5 // Copyright (c) 2008-2017 Texas Instruments Incorporated. All rights reserved.
6 // Software License Agreement
7 //
8 // Texas Instruments (TI) is supplying this software for use solely and
9 // exclusively on TI's microcontroller products. The software is owned by
10 // TI and/or its suppliers, and is protected under applicable copyright
11 // laws. You may not combine this software with "viral" open-source
12 // software in order to form a larger program.
13 //
14 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
15 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
16 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
18 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
19 // DAMAGES, FOR ANY REASON WHATSOEVER.
20 //
21 //*****************************************************************************
22 
23 #ifndef __USBLIB_H__
24 #define __USBLIB_H__
25 
26 //*****************************************************************************
27 //
28 // If building with a C++ compiler, make all of the definitions in this header
29 // have a C binding.
30 //
31 //*****************************************************************************
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36 
37 #include <stdint.h>
38 #include <stdbool.h>
39 
40 //*****************************************************************************
41 //
42 // This is the maximum number of devices we can support when in host mode and
43 // using a hub. By default, we support up to 4 devices (plus 1 internally for
44 // the hub itself).
45 //
46 //*****************************************************************************
47 #ifndef MAX_USB_DEVICES
48 #define MAX_USB_DEVICES 5
49 #endif
50 
51 //*****************************************************************************
52 //
53 // This is the maximum number of endpoints supported by the usblib.
54 //
55 //*****************************************************************************
56 #ifndef USBLIB_NUM_EP
57 #define USBLIB_NUM_EP 8 // Number of supported endpoints.
58 #endif
59 
60 //*****************************************************************************
61 //
62 // The following macro allows compiler-independent syntax to be used to
63 // define packed structures. A typical structure definition using these
64 // macros will look similar to the following example:
65 //
66 // #ifdef __ICCARM__
67 // #pragma pack(1)
68 // #endif
69 //
70 // typedef struct _PackedStructName
71 // {
72 // uint32_t ui32FirstField;
73 // int8_t i8CharMember;
74 // uint16_t ui16Short;
75 // }
76 // PACKED tPackedStructName;
77 //
78 // #ifdef __ICCARM__
79 // #pragma pack()
80 // #endif
81 //
82 // The conditional blocks related to __ICCARM__ include the #pragma pack() lines
83 // only if the IAR Embedded Workbench compiler is being used. Unfortunately,
84 // it is not possible to emit a #pragma from within a macro definition so this
85 // must be done explicitly.
86 //
87 //*****************************************************************************
88 #if defined(__TI_ARM__) || \
89  defined(codered) || \
90  defined(__GNUC__) || \
91  defined(__CC_ARM) || \
92  defined(__ARMCC_VERSION) || \
93  defined(sourcerygxx)
94 #define PACKED __attribute__ ((packed))
95 #elif defined(__ICCARM__)
96 #define PACKED
97 #else
98 #error Unrecognized COMPILER!
99 #endif
100 //*****************************************************************************
101 //
102 // Assorted language IDs from the document "USB_LANGIDs.pdf" provided by the
103 // USB Implementers' Forum (Version 1.0).
104 //
105 //*****************************************************************************
106 #define USB_LANG_CHINESE_PRC 0x0804 // Chinese (PRC)
107 #define USB_LANG_CHINESE_TAIWAN 0x0404 // Chinese (Taiwan)
108 #define USB_LANG_EN_US 0x0409 // English (United States)
109 #define USB_LANG_EN_UK 0x0809 // English (United Kingdom)
110 #define USB_LANG_EN_AUS 0x0C09 // English (Australia)
111 #define USB_LANG_EN_CA 0x1009 // English (Canada)
112 #define USB_LANG_EN_NZ 0x1409 // English (New Zealand)
113 #define USB_LANG_FRENCH 0x040C // French (Standard)
114 #define USB_LANG_GERMAN 0x0407 // German (Standard)
115 #define USB_LANG_HINDI 0x0439 // Hindi
116 #define USB_LANG_ITALIAN 0x0410 // Italian (Standard)
117 #define USB_LANG_JAPANESE 0x0411 // Japanese
118 #define USB_LANG_KOREAN 0x0412 // Korean
119 #define USB_LANG_ES_TRAD 0x040A // Spanish (Traditional)
120 #define USB_LANG_ES_MODERN 0x0C0A // Spanish (Modern)
121 #define USB_LANG_SWAHILI 0x0441 // Swahili (Kenya)
122 #define USB_LANG_URDU_IN 0x0820 // Urdu (India)
123 #define USB_LANG_URDU_PK 0x0420 // Urdu (Pakistan)
124 
125 //*****************************************************************************
126 //
129 //
130 //*****************************************************************************
131 
132 //*****************************************************************************
133 //
134 // Note:
135 //
136 // Structure definitions which are derived directly from the USB specification
137 // use field names from the specification. Since a somewhat different version
138 // of Hungarian prefix notation is used from the standard, beware of making
139 // assumptions about field sizes based on the field prefix when using
140 // these structures. Of particular note is the difference in the meaning of
141 // the 'i' prefix. In USB structures, this indicates a single byte index
142 // whereas in other code, this is an integer or enumeration variable.
143 //
144 //*****************************************************************************
145 
146 //*****************************************************************************
147 //
148 // All structures defined in this section of the header require byte packing of
149 // fields. This is usually accomplished using the PACKED macro but, for IAR
150 // Embedded Workbench, this requires a pragma.
151 //
152 //*****************************************************************************
153 #ifdef __ICCARM__
154 #pragma pack(1)
155 #endif
156 
157 //*****************************************************************************
158 //
159 // Definitions related to standard USB device requests (sections 9.3 & 9.4)
160 //
161 //*****************************************************************************
162 
163 //*****************************************************************************
164 //
167 //
168 //*****************************************************************************
169 typedef struct
170 {
171  //
173  //
174  uint8_t bmRequestType;
175 
176  //
178  //
179  uint8_t bRequest;
180 
181  //
183  //
184  uint16_t wValue;
185 
186  //
189  //
190  uint16_t wIndex;
191 
192  //
195  //
196  uint16_t wLength;
197 
198 }
199 PACKED tUSBRequest;
200 
201 //*****************************************************************************
202 //
203 // The following defines are used with the bmRequestType member of tUSBRequest.
204 //
205 // Request types have 3 bit fields:
206 // 4:0 - Is the recipient type.
207 // 6:5 - Is the request type.
208 // 7 - Is the direction of the request.
209 //
210 //*****************************************************************************
211 #define USB_RTYPE_DIR_IN 0x80
212 #define USB_RTYPE_DIR_OUT 0x00
213 
214 #define USB_RTYPE_TYPE_M 0x60
215 #define USB_RTYPE_VENDOR 0x40
216 #define USB_RTYPE_CLASS 0x20
217 #define USB_RTYPE_STANDARD 0x00
218 
219 #define USB_RTYPE_RECIPIENT_M 0x1f
220 #define USB_RTYPE_OTHER 0x03
221 #define USB_RTYPE_ENDPOINT 0x02
222 #define USB_RTYPE_INTERFACE 0x01
223 #define USB_RTYPE_DEVICE 0x00
224 
225 //*****************************************************************************
226 //
227 // Standard USB requests IDs used in the bRequest field of tUSBRequest.
228 //
229 //*****************************************************************************
230 #define USBREQ_GET_STATUS 0x00
231 #define USBREQ_CLEAR_FEATURE 0x01
232 #define USBREQ_SET_FEATURE 0x03
233 #define USBREQ_SET_ADDRESS 0x05
234 #define USBREQ_GET_DESCRIPTOR 0x06
235 #define USBREQ_SET_DESCRIPTOR 0x07
236 #define USBREQ_GET_CONFIG 0x08
237 #define USBREQ_SET_CONFIG 0x09
238 #define USBREQ_GET_INTERFACE 0x0a
239 #define USBREQ_SET_INTERFACE 0x0b
240 #define USBREQ_SYNC_FRAME 0x0c
241 
242 //*****************************************************************************
243 //
244 // Data returned from a USBREQ_GET_STATUS request to a device.
245 //
246 //*****************************************************************************
247 #define USB_STATUS_SELF_PWR 0x0001 // Currently self powered.
248 #define USB_STATUS_BUS_PWR 0x0000 // Currently bus-powered.
249 #define USB_STATUS_PWR_M 0x0001 // Mask for power mode.
250 #define USB_STATUS_REMOTE_WAKE 0x0002 // Remote wake-up is currently enabled.
251 
252 //*****************************************************************************
253 //
254 // Feature Selectors (tUSBRequest.wValue) passed on USBREQ_CLEAR_FEATURE and
255 // USBREQ_SET_FEATURE.
256 //
257 //*****************************************************************************
258 #define USB_FEATURE_EP_HALT 0x0000 // Endpoint halt feature.
259 #define USB_FEATURE_REMOTE_WAKE 0x0001 // Remote wake feature, device only.
260 #define USB_FEATURE_TEST_MODE 0x0002 // Test mode
261 
262 //*****************************************************************************
263 //
264 // Endpoint Selectors (tUSBRequest.wIndex) passed on USBREQ_CLEAR_FEATURE,
265 // USBREQ_SET_FEATURE and USBREQ_GET_STATUS.
266 //
267 //*****************************************************************************
268 #define USB_REQ_EP_NUM_M 0x007F
269 #define USB_REQ_EP_DIR_M 0x0080
270 #define USB_REQ_EP_DIR_IN 0x0080
271 #define USB_REQ_EP_DIR_OUT 0x0000
272 
273 //*****************************************************************************
274 //
275 // Standard USB descriptor types. These values are passed in the upper bytes
276 // of tUSBRequest.wValue on USBREQ_GET_DESCRIPTOR and also appear in the
277 // bDescriptorType field of standard USB descriptors.
278 //
279 //*****************************************************************************
280 #define USB_DTYPE_DEVICE 1
281 #define USB_DTYPE_CONFIGURATION 2
282 #define USB_DTYPE_STRING 3
283 #define USB_DTYPE_INTERFACE 4
284 #define USB_DTYPE_ENDPOINT 5
285 #define USB_DTYPE_DEVICE_QUAL 6
286 #define USB_DTYPE_OSPEED_CONF 7
287 #define USB_DTYPE_INTERFACE_PWR 8
288 #define USB_DTYPE_OTG 9
289 #define USB_DTYPE_INTERFACE_ASC 11
290 #define USB_DTYPE_CS_INTERFACE 36
291 #define USB_DTYPE_HUB 41
292 
293 //*****************************************************************************
294 //
295 // Definitions related to USB descriptors (sections 9.5 & 9.6)
296 //
297 //*****************************************************************************
298 
299 //*****************************************************************************
300 //
303 //
304 //*****************************************************************************
305 typedef struct
306 {
307  //
310  //
311  uint8_t bLength;
312 
313  //
318  //
319  uint8_t bDescriptorType;
320 }
321 PACKED tDescriptorHeader;
322 
323 //*****************************************************************************
324 //
327 //
328 //*****************************************************************************
329 typedef struct
330 {
331  //
334  //
335  uint8_t bLength;
336 
337  //
340  //
341  uint8_t bDescriptorType;
342 
343  //
346  //
347  uint16_t bcdUSB;
348 
349  //
351  //
352  uint8_t bDeviceClass;
353 
354  //
357  //
359 
360  //
363  //
365 
366  //
369  //
371 
372  //
374  //
375  uint16_t idVendor;
376 
377  //
379  //
380  uint16_t idProduct;
381 
382  //
384  //
385  uint16_t bcdDevice;
386 
387  //
389  //
390  uint8_t iManufacturer;
391 
392  //
394  //
395  uint8_t iProduct;
396 
397  //
400  //
401  uint8_t iSerialNumber;
402 
403  //
407  //
409 }
410 PACKED tDeviceDescriptor;
411 
412 //*****************************************************************************
413 //
414 // USB Device Class codes used in the tDeviceDescriptor.bDeviceClass field.
415 // Definitions for the bDeviceSubClass and bDeviceProtocol fields are device
416 // specific and can be found in the appropriate device class header files.
417 //
418 //*****************************************************************************
419 #define USB_CLASS_DEVICE 0x00
420 #define USB_CLASS_AUDIO 0x01
421 #define USB_CLASS_CDC 0x02
422 #define USB_CLASS_HID 0x03
423 #define USB_CLASS_PHYSICAL 0x05
424 #define USB_CLASS_IMAGE 0x06
425 #define USB_CLASS_PRINTER 0x07
426 #define USB_CLASS_MASS_STORAGE 0x08
427 #define USB_CLASS_HUB 0x09
428 #define USB_CLASS_CDC_DATA 0x0a
429 #define USB_CLASS_SMART_CARD 0x0b
430 #define USB_CLASS_SECURITY 0x0d
431 #define USB_CLASS_VIDEO 0x0e
432 #define USB_CLASS_HEALTHCARE 0x0f
433 #define USB_CLASS_DIAG_DEVICE 0xdc
434 #define USB_CLASS_WIRELESS 0xe0
435 #define USB_CLASS_MISC 0xef
436 #define USB_CLASS_APP_SPECIFIC 0xfe
437 #define USB_CLASS_VEND_SPECIFIC 0xff
438 #define USB_CLASS_EVENTS 0xffffffff
439 
440 //*****************************************************************************
441 //
442 // Generic values for undefined subclass and protocol.
443 //
444 //*****************************************************************************
445 #define USB_SUBCLASS_UNDEFINED 0x00
446 #define USB_PROTOCOL_UNDEFINED 0x00
447 
448 //*****************************************************************************
449 //
450 // The following are the miscellaneous subclass values.
451 //
452 //*****************************************************************************
453 #define USB_MISC_SUBCLASS_SYNC 0x01
454 #define USB_MISC_SUBCLASS_COMMON \
455  0x02
456 
457 //*****************************************************************************
458 //
459 // These following are miscellaneous protocol values.
460 //
461 //*****************************************************************************
462 #define USB_MISC_PROTOCOL_IAD 0x01
463 
464 //*****************************************************************************
465 //
466 // These following are hub protocol values.
467 //
468 //*****************************************************************************
469 #define USB_HUB_PROTOCOL_FS 0x00
470 #define USB_HUB_PROTOCOL_SINGLE 0x01
471 #define USB_HUB_PROTOCOL_MULTI 0x02
472 
473 //*****************************************************************************
474 //
477 //
478 //*****************************************************************************
479 typedef struct
480 {
481  //
484  //
485  uint8_t bLength;
486 
487  //
490  //
491  uint8_t bDescriptorType;
492 
493  //
496  //
497  uint16_t bcdUSB;
498 
499  //
501  //
502  uint8_t bDeviceClass;
503 
504  //
507  //
508  uint8_t bDeviceSubClass;
509 
510  //
513  //
514  uint8_t bDeviceProtocol;
515 
516  //
519  //
520  uint8_t bMaxPacketSize0;
521 
522  //
524  //
525  uint8_t bNumConfigurations;
526 
527  //
529  //
530  uint8_t bReserved;
531 }
532 PACKED tDeviceQualifierDescriptor;
533 
534 //*****************************************************************************
535 //
539 //
540 //*****************************************************************************
541 typedef struct
542 {
543  //
546  //
547  uint8_t bLength;
548 
549  //
552  //
553  uint8_t bDescriptorType;
554 
555  //
560  //
561  uint16_t wTotalLength;
562 
563  //
565  //
566  uint8_t bNumInterfaces;
567 
568  //
571  //
573 
574  //
576  //
577  uint8_t iConfiguration;
578 
579  //
581  //
582  uint8_t bmAttributes;
583 
584  //
588  //
589  uint8_t bMaxPower;
590 }
591 PACKED tConfigDescriptor;
592 
593 //*****************************************************************************
594 //
595 // Flags used in constructing the value assigned to the field
596 // tConfigDescriptor.bmAttributes. Note that bit 7 is reserved and must be set
597 // to 1.
598 //
599 //*****************************************************************************
600 #define USB_CONF_ATTR_PWR_M 0xC0
601 
602 #define USB_CONF_ATTR_SELF_PWR 0xC0
603 #define USB_CONF_ATTR_BUS_PWR 0x80
604 #define USB_CONF_ATTR_RWAKE 0xA0
605 
606 //*****************************************************************************
607 //
610 //
611 //*****************************************************************************
612 typedef struct
613 {
614  //
617  //
618  uint8_t bLength;
619 
620  //
623  //
624  uint8_t bDescriptorType;
625 
626  //
629  //
631 
632  //
635  //
637 
638  //
641  //
642  uint8_t bNumEndpoints;
643 
644  //
646  //
648 
649  //
651  //
653 
654  //
656  //
658 
659  //
661  //
662  uint8_t iInterface;
663 }
664 PACKED tInterfaceDescriptor;
665 
666 //*****************************************************************************
667 //
670 //
671 //*****************************************************************************
672 typedef struct
673 {
674  //
677  //
678  uint8_t bLength;
679 
680  //
683  //
684  uint8_t bDescriptorType;
685 
686  //
690  //
692 
693  //
697  //
698  uint8_t bmAttributes;
699 
700  //
705  //
706  uint16_t wMaxPacketSize;
707 
708  //
711  //
712  uint8_t bInterval;
713 }
714 PACKED tEndpointDescriptor;
715 
716 //*****************************************************************************
717 //
718 // Flags used in constructing the value assigned to the field
719 // tEndpointDescriptor.bEndpointAddress.
720 //
721 //*****************************************************************************
722 #define USB_EP_DESC_OUT 0x00
723 #define USB_EP_DESC_IN 0x80
724 #define USB_EP_DESC_NUM_M 0x0f
725 
726 //*****************************************************************************
727 //
728 // Mask used to extract the maximum packet size (in bytes) from the
729 // wMaxPacketSize field of the endpoint descriptor.
730 //
731 //*****************************************************************************
732 #define USB_EP_MAX_PACKET_COUNT_M \
733  0x07FF
734 
735 //*****************************************************************************
736 //
737 // Endpoint attributes used in tEndpointDescriptor.bmAttributes.
738 //
739 //*****************************************************************************
740 #define USB_EP_ATTR_CONTROL 0x00
741 #define USB_EP_ATTR_ISOC 0x01
742 #define USB_EP_ATTR_BULK 0x02
743 #define USB_EP_ATTR_INT 0x03
744 #define USB_EP_ATTR_TYPE_M 0x03
745 
746 #define USB_EP_ATTR_ISOC_M 0x0c
747 #define USB_EP_ATTR_ISOC_NOSYNC 0x00
748 #define USB_EP_ATTR_ISOC_ASYNC 0x04
749 #define USB_EP_ATTR_ISOC_ADAPT 0x08
750 #define USB_EP_ATTR_ISOC_SYNC 0x0c
751 #define USB_EP_ATTR_USAGE_M 0x30
752 #define USB_EP_ATTR_USAGE_DATA 0x00
753 #define USB_EP_ATTR_USAGE_FEEDBACK \
754  0x10
755 #define USB_EP_ATTR_USAGE_IMPFEEDBACK \
756  0x20
757 
758 //*****************************************************************************
759 //
764 //
765 //*****************************************************************************
766 typedef struct
767 {
768  //
771  //
772  uint8_t bLength;
773 
774  //
777  //
778  uint8_t bDescriptorType;
779 
780  //
785  //
786  uint16_t wLANGID[1];
787 }
788 PACKED tString0Descriptor;
789 
790 //*****************************************************************************
791 //
794 //
795 //*****************************************************************************
796 typedef struct
797 {
798  //
802  //
803  uint8_t bLength;
804 
805  //
808  //
809  uint8_t bDescriptorType;
810 
811  //
815  //
816  uint8_t bString;
817 }
818 PACKED tStringDescriptor;
819 
820 //*****************************************************************************
821 //
832 //
833 //*****************************************************************************
834 #define USBShort(ui16Value) (ui16Value & 0xff), (ui16Value >> 8)
835 
836 //*****************************************************************************
837 //
848 //
849 //*****************************************************************************
850 #define USB3Byte(ui32Value) (ui32Value & 0xff), \
851  ((ui32Value >> 8) & 0xff), \
852  ((ui32Value >> 16) & 0xff)
853 
854 //*****************************************************************************
855 //
866 //
867 //*****************************************************************************
868 #define USBLong(ui32Value) (ui32Value & 0xff), \
869  ((ui32Value >> 8) & 0xff), \
870  ((ui32Value >> 16) & 0xff), \
871  ((ui32Value >> 24) & 0xff)
872 
873 //*****************************************************************************
874 //
886 //*****************************************************************************
887 #define NEXT_USB_DESCRIPTOR(ptr) \
888  (tDescriptorHeader *)(((uint8_t *)(ptr)) + \
889  *((uint8_t *)(ptr)))
890 
891 //*****************************************************************************
892 //
893 // Return to default packing when using the IAR Embedded Workbench compiler.
894 //
895 //*****************************************************************************
896 #ifdef __ICCARM__
897 #pragma pack()
898 #endif
899 
900 //*****************************************************************************
901 //
902 // Close the usbchap9_src Doxygen group.
904 //
905 //*****************************************************************************
906 
907 //*****************************************************************************
908 //
911 //
912 //*****************************************************************************
913 
914 //*****************************************************************************
915 //
916 // Function prototype for any standard USB request.
917 //
918 //*****************************************************************************
919 typedef void (* tStdRequest)(void *pvInstance, tUSBRequest *pUSBRequest);
920 
921 //*****************************************************************************
922 //
923 // Data callback for receiving data from an endpoint.
924 //
925 //*****************************************************************************
926 typedef void (* tInfoCallback)(void *pvInstance, uint32_t ui32Info);
927 
928 //*****************************************************************************
929 //
930 // Callback made to indicate that an interface alternate setting change has
931 // occurred.
932 //
933 //*****************************************************************************
934 typedef void (* tInterfaceCallback)(void *pvInstance, uint8_t ui8InterfaceNum,
935  uint8_t ui8AlternateSetting);
936 
937 //*****************************************************************************
938 //
939 // Generic interrupt handler callbacks.
940 //
941 //*****************************************************************************
942 typedef void (* tUSBIntHandler)(void *pvInstance);
943 
944 //*****************************************************************************
945 //
946 // Interrupt handler callbacks that have status information.
947 //
948 //*****************************************************************************
949 typedef void (* tUSBEPIntHandler)(void *pvInstance, uint32_t ui32Status);
950 
951 //*****************************************************************************
952 //
955 //
956 //*****************************************************************************
957 typedef void (* tUSBDeviceHandler)(void *pvInstance, uint32_t ui32Request,
958  void *pvRequestData);
959 
960 //*****************************************************************************
961 //
964 //
965 //*****************************************************************************
966 typedef struct
967 {
968  //
971  //
973 
974  //
977  //
979 
980  //
983  //
985 
986  //
989  //
991 
992  //
995  //
997 
998  //
1001  //
1003 
1004  //
1006  //
1008 
1009  //
1012  //
1014 
1015  //
1017  //
1019 
1020  //
1022  //
1024 
1025  //
1028  //
1030 
1031  //
1036  //
1038 }
1040 
1041 //*****************************************************************************
1042 //
1048 //*****************************************************************************
1049 typedef struct
1050 {
1051  //
1053  //
1054  uint16_t ui16Size;
1055 
1056  //
1059  //
1060  const uint8_t *pui8Data;
1061 }
1063 
1064 //*****************************************************************************
1065 //
1076 //*****************************************************************************
1077 typedef struct
1078 {
1079  //
1082  //
1084 
1085  //
1088  //
1089  const tConfigSection * const *psSections;
1090 }
1092 
1093 //*****************************************************************************
1094 //
1095 // Close the Doxygen group.
1097 //
1098 //*****************************************************************************
1099 
1100 //*****************************************************************************
1101 //
1104 //
1105 //*****************************************************************************
1106 
1107 //*****************************************************************************
1108 //
1109 // Predeclare of the DMA instance structure.
1110 //
1111 //*****************************************************************************
1113 
1114 //*****************************************************************************
1115 //
1116 // USB descriptor parsing functions found in usbdesc.c
1117 //
1118 //*****************************************************************************
1119 
1120 //*****************************************************************************
1121 //
1125 //
1126 //*****************************************************************************
1127 #define USB_DESC_ANY 0xFFFFFFFF
1128 
1129 extern uint32_t USBDescGetNum(tDescriptorHeader *psDesc, uint32_t ui32Size,
1130  uint32_t ui32Type);
1131 extern tDescriptorHeader *USBDescGet(tDescriptorHeader *psDesc,
1132  uint32_t ui32Size, uint32_t ui32Type,
1133  uint32_t ui32Index);
1134 extern uint32_t
1135  USBDescGetNumAlternateInterfaces(tConfigDescriptor *psConfig,
1136  uint8_t ui8InterfaceNumber);
1137 extern tInterfaceDescriptor *USBDescGetInterface(tConfigDescriptor *psConfig,
1138  uint32_t ui32Index,
1139  uint32_t ui32AltCfg);
1140 extern tEndpointDescriptor *
1141  USBDescGetInterfaceEndpoint(tInterfaceDescriptor *psInterface,
1142  uint32_t ui32Index, uint32_t ui32Size);
1143 
1144 //*****************************************************************************
1145 //
1149 //
1150 //*****************************************************************************
1151 typedef enum
1152 {
1153  //
1156  //
1158 
1159  //
1162  //
1164 
1165  //
1168  //
1170 
1171  //
1174  //
1176 
1177  //
1180  //
1182 
1183  //
1186  //
1188 }
1189 tUSBMode;
1190 
1191 //*****************************************************************************
1192 //
1193 // A pointer to a USB mode callback function. This function is called by the
1194 // USB library to indicate to the application which operating mode it should
1195 // use, host or device.
1196 //
1197 //*****************************************************************************
1198 typedef void (*tUSBModeCallback)(uint32_t ui32Index, tUSBMode iMode);
1199 
1200 //*****************************************************************************
1201 //
1218 //
1219 //*****************************************************************************
1220 typedef uint32_t (* tUSBCallback)(void *pvCBData, uint32_t ui32Event,
1221  uint32_t ui32MsgParam, void *pvMsgData);
1222 
1223 //*****************************************************************************
1224 //
1225 // Error sources reported via USB_EVENT_ERROR.
1226 //
1227 //*****************************************************************************
1228 
1229 //
1231 //
1232 #define USBERR_HOST_IN_PID_ERROR \
1233  0x01000000
1234 
1235 //
1237 //
1238 #define USBERR_HOST_IN_NOT_COMP 0x00100000
1239 
1240 //
1242 //
1243 #define USBERR_HOST_IN_STALL 0x00400000
1244 
1245 //
1247 //
1248 #define USBERR_HOST_IN_DATA_ERROR \
1249  0x00080000
1250 
1251 //
1254 //
1255 #define USBERR_HOST_IN_NAK_TO 0x00080000
1256 
1257 //
1259 //
1260 #define USBERR_HOST_IN_ERROR 0x00040000
1261 
1262 //
1264 //
1265 #define USBERR_HOST_IN_FIFO_FULL \
1266  0x00020000
1267 //
1270 //
1271 #define USBERR_HOST_OUT_NAK_TO 0x00000080
1272 
1273 //
1275 //
1276 #define USBERR_HOST_OUT_NOT_COMP \
1277  0x00000080
1278 
1279 //
1281 //
1282 #define USBERR_HOST_OUT_STALL 0x00000020
1283 
1284 //
1286 //
1287 #define USBERR_HOST_OUT_ERROR 0x00000004
1288 
1289 //
1292 //
1293 #define USBERR_HOST_EP0_NAK_TO 0x00000080
1294 
1295 //
1297 //
1298 #define USBERR_HOST_EP0_ERROR 0x00000010
1299 
1300 //
1302 //
1303 #define USBERR_DEV_RX_DATA_ERROR \
1304  0x00080000
1305 
1306 //
1309 //
1310 #define USBERR_DEV_RX_OVERRUN 0x00040000
1311 
1312 //
1314 //
1315 #define USBERR_DEV_RX_FIFO_FULL 0x00020000
1316 
1317 //*****************************************************************************
1318 //
1319 // Close the general_usblib_api Doxygen group.
1321 //
1322 //*****************************************************************************
1323 
1324 //*****************************************************************************
1325 //
1328 //
1329 //*****************************************************************************
1330 
1331 //*****************************************************************************
1332 //
1338 //
1339 //*****************************************************************************
1340 typedef struct
1341 {
1342  //
1344  //
1345  uint32_t ui32Event;
1346 
1347  //
1349  //
1350  uint32_t ui32Instance;
1351 }
1352 tEventInfo;
1353 
1354 //*****************************************************************************
1355 //
1356 // Base identifiers for groups of USB events. These are used by both the
1357 // device class drivers and host layer.
1358 //
1359 // USB_CLASS_EVENT_BASE is the lowest identifier that should be used for
1360 // a class-specific event. Individual event bases are defined for each
1361 // of the supported device class drivers. Events with IDs between
1362 // USB_EVENT_BASE and USB_CLASS_EVENT_BASE are reserved for stack use.
1363 //
1364 //*****************************************************************************
1365 #define USB_EVENT_BASE 0x0000
1366 #define USB_CLASS_EVENT_BASE 0x8000
1367 
1368 //*****************************************************************************
1369 //
1370 // Event base identifiers for the various device classes supported in host
1371 // and device modes.
1372 // The first 0x800 values of a range are reserved for the device specific
1373 // messages and the second 0x800 values of a range are used for the host
1374 // specific messages for a given class.
1375 //
1376 //*****************************************************************************
1377 #define USBD_CDC_EVENT_BASE (USB_CLASS_EVENT_BASE + 0)
1378 #define USBD_HID_EVENT_BASE (USB_CLASS_EVENT_BASE + 0x1000)
1379 #define USBD_HID_KEYB_EVENT_BASE \
1380  (USBD_HID_EVENT_BASE + 0x100)
1381 #define USBD_BULK_EVENT_BASE (USB_CLASS_EVENT_BASE + 0x2000)
1382 #define USBD_MSC_EVENT_BASE (USB_CLASS_EVENT_BASE + 0x3000)
1383 #define USBD_AUDIO_EVENT_BASE (USB_CLASS_EVENT_BASE + 0x4000)
1384 #define USBD_DFU_EVENT_BASE (USB_CLASS_EVENT_BASE + 0x5000)
1385 
1386 #define USBH_CDC_EVENT_BASE (USBD_CDC_EVENT_BASE + 0x800)
1387 #define USBH_HID_EVENT_BASE (USBD_HID_EVENT_BASE + 0x800)
1388 #define USBH_BULK_EVENT_BASE (USBD_BULK_EVENT_BASE + 0x800)
1389 #define USBH_MSC_EVENT_BASE (USBD_MSC_EVENT_BASE + 0x800)
1390 #define USBH_AUDIO_EVENT_BASE (USBD_AUDIO_EVENT_BASE + 0x800)
1391 
1392 //*****************************************************************************
1393 //
1394 // General events supported by device classes and host pipes.
1395 //
1396 //*****************************************************************************
1397 
1398 //
1401 //
1402 #define USB_EVENT_CONNECTED (USB_EVENT_BASE + 0)
1403 
1404 //
1411 //
1412 #define USB_EVENT_DISCONNECTED (USB_EVENT_BASE + 1)
1413 
1414 //
1421 //
1422 #define USB_EVENT_RX_AVAILABLE (USB_EVENT_BASE + 2)
1423 
1424 //
1431 //
1432 #define USB_EVENT_DATA_REMAINING \
1433  (USB_EVENT_BASE + 3)
1434 
1435 //
1444 //
1445 #define USB_EVENT_REQUEST_BUFFER \
1446  (USB_EVENT_BASE + 4)
1447 
1448 //
1453 //
1454 #define USB_EVENT_TX_COMPLETE (USB_EVENT_BASE + 5)
1455 
1456 //
1460 //
1461 #define USB_EVENT_ERROR (USB_EVENT_BASE + 6)
1462 
1463 //
1465 //
1466 #define USB_EVENT_SUSPEND (USB_EVENT_BASE + 7)
1467 
1468 //
1470 //
1471 #define USB_EVENT_RESUME (USB_EVENT_BASE + 8)
1472 
1473 //
1475 //
1476 #define USB_EVENT_SCHEDULER (USB_EVENT_BASE + 9)
1477 //
1479 //
1480 #define USB_EVENT_STALL (USB_EVENT_BASE + 10)
1481 
1482 //
1484 //
1485 #define USB_EVENT_POWER_FAULT (USB_EVENT_BASE + 11)
1486 
1487 //
1490 //
1491 #define USB_EVENT_POWER_ENABLE (USB_EVENT_BASE + 12)
1492 
1493 //
1496 //
1497 #define USB_EVENT_POWER_DISABLE (USB_EVENT_BASE + 13)
1498 
1499 //
1510 //
1511 #define USB_EVENT_COMP_IFACE_CHANGE \
1512  (USB_EVENT_BASE + 14)
1513 
1514 //
1528 //
1529 #define USB_EVENT_COMP_EP_CHANGE \
1530  (USB_EVENT_BASE + 15)
1531 
1532 //
1544 //
1545 #define USB_EVENT_COMP_STR_CHANGE \
1546  (USB_EVENT_BASE + 16)
1547 
1548 //
1561 //
1562 #define USB_EVENT_COMP_CONFIG (USB_EVENT_BASE + 17)
1563 
1564 //
1571 //
1572 #define USB_EVENT_UNKNOWN_CONNECTED \
1573  (USB_EVENT_BASE + 18)
1574 
1575 //
1578 //
1579 #define USB_EVENT_SOF (USB_EVENT_BASE + 19)
1580 
1581 //
1583 //
1584 #define USB_EVENT_LPM_SLEEP (USB_EVENT_BASE + 20)
1585 
1586 //
1588 //
1589 #define USB_EVENT_LPM_RESUME (USB_EVENT_BASE + 21)
1590 
1591 //
1594 //
1595 #define USB_EVENT_LPM_ERROR (USB_EVENT_BASE + 22)
1596 
1597 //
1599 //
1600 #define USB_EVENT_CONFIG_CHANGE (USB_EVENT_BASE + 23)
1601 
1602 //*****************************************************************************
1603 //
1604 // Close the usblib_events Doxygen group.
1606 //
1607 //*****************************************************************************
1608 //*****************************************************************************
1609 //
1612 //
1613 //*****************************************************************************
1614 
1615 //*****************************************************************************
1616 //
1620 //
1621 //*****************************************************************************
1622 typedef uint32_t (* tUSBPacketTransfer)(void *pvHandle, uint8_t *pi8Data,
1623  uint32_t ui32Length, bool bLast);
1624 
1625 //*****************************************************************************
1626 //
1634 //
1635 //*****************************************************************************
1636 typedef uint32_t (* tUSBPacketAvailable)(void *pvHandle);
1637 
1638 //*****************************************************************************
1639 //
1640 // The defines used with the USBDCDFeatureSet() or USBHCDFeatureSet() calls.
1641 //
1642 //*****************************************************************************
1643 
1644 //*****************************************************************************
1645 //
1660 //
1661 //*****************************************************************************
1662 #define USBLIB_FEATURE_LPM 0x00000001
1663 
1664 //*****************************************************************************
1665 //
1666 // The defines used with the USBDCDFeatureSet() or USBHCDFeatureSet() calls
1667 // for \b USBLIB_FEATURE_LPM feature requests.
1668 //
1669 //*****************************************************************************
1670 #define USBLIB_FEATURE_LPM_RMT_WAKE \
1671  0x00000002
1672 #define USBLIB_FEATURE_LPM_EN 0x00000001
1673 #define USBLIB_FEATURE_LPM_DIS 0x00000000
1674 
1675 //*****************************************************************************
1676 //
1681 //
1682 //*****************************************************************************
1683 #define USBLIB_FEATURE_CPUCLK 0x00000002
1684 
1685 //*****************************************************************************
1686 //
1695 //
1696 //*****************************************************************************
1697 #define USBLIB_FEATURE_USBPLL 0x00000003
1698 
1699 //*****************************************************************************
1710 //
1711 //*****************************************************************************
1712 #define USBLIB_FEATURE_USBULPI 0x00000004
1713 
1714 //*****************************************************************************
1715 //
1716 // The defines used with the USBDCDFeatureSet() or USBHCDFeatureSet() calls
1717 // for \b USBLIB_FEATURE_USBULPI feature requests.
1718 //
1719 //*****************************************************************************
1720 #define USBLIB_FEATURE_ULPI_NONE \
1721  0x00000000
1722 #define USBLIB_FEATURE_ULPI_HS 0x00000010
1723 #define USBLIB_FEATURE_ULPI_FS 0x00000020
1724 
1725 //*****************************************************************************
1726 //
1736 //
1737 //*****************************************************************************
1738 #define USBLIB_FEATURE_POWER 0x00000005
1739 
1740 //*****************************************************************************
1741 //
1742 // The defines used with the USBDCDFeatureSet() or USBHCDFeatureSet() calls
1743 // for \b USBLIB_FEATURE_POWER feature requests.
1744 //
1745 //*****************************************************************************
1746 #define USBLIB_FEATURE_POWER_SELF \
1747  0x00000001
1748 #define USBLIB_FEATURE_POWER_BUS \
1749  0x00000000
1750 #define USBLIB_FEATURE_REMOTE_WAKE \
1751  0x00000002
1752 
1753 //*****************************************************************************
1754 //
1755 // The structure used with the USBDCDFeatureSet() or USBHCDFeatureSet() calls
1756 // to set feature enables and resume timing parameter.
1757 //
1758 //*****************************************************************************
1759 typedef struct
1760 {
1761  uint32_t ui32HIRD;
1762  uint32_t ui32Features;
1763 }
1764 tLPMFeature;
1765 
1766 //*****************************************************************************
1767 //
1770 //
1771 //*****************************************************************************
1772 typedef struct
1773 {
1774  //
1776  //
1777  uint32_t ui32Size;
1778 
1779  //
1781  //
1782  volatile uint32_t ui32WriteIndex;
1783 
1784  //
1786  //
1787  volatile uint32_t ui32ReadIndex;
1788 
1789  //
1791  //
1792  uint8_t *pui8Buf;
1793 }
1795 
1796 //*****************************************************************************
1797 //
1798 // Workspace variables required by each buffer instance. This structure is
1799 // private and should not be accessed directly by the application.
1800 //
1801 //*****************************************************************************
1802 typedef struct
1803 {
1805  uint32_t ui32LastSent;
1806  uint32_t ui32Flags;
1807 }
1809 
1810 //*****************************************************************************
1811 //
1814 //
1815 //*****************************************************************************
1816 typedef struct
1817 {
1818  //
1823  //
1825 
1826  //
1830  //
1832 
1833  //
1836  //
1837  void *pvCBData;
1838 
1839  //
1842  //
1844 
1845  //
1850  //
1852 
1853  //
1859  //
1860  void *pvHandle;
1861 
1862  //
1865  //
1866  uint8_t *pui8Buffer;
1867 
1868  //
1870  //
1871  uint32_t ui32BufferSize;
1872 
1873  //
1876  //
1878 }
1879 tUSBBuffer;
1880 
1881 //*****************************************************************************
1882 //
1883 // Close the Doxygen group.
1885 //
1886 //*****************************************************************************
1887 
1888 //*****************************************************************************
1889 //
1890 // USB buffer API function prototypes.
1891 //
1892 //*****************************************************************************
1893 extern const tUSBBuffer *USBBufferInit(tUSBBuffer *psBuffer);
1894 extern void USBBufferZeroLengthPacketInsert(const tUSBBuffer *psBuffer,
1895  bool bSendZLP);
1896 extern void USBBufferInfoGet(const tUSBBuffer *psBuffer,
1897  tUSBRingBufObject *psRingBuf);
1898 extern void *USBBufferCallbackDataSet(tUSBBuffer *psBuffer, void *pvCBData);
1899 extern uint32_t USBBufferWrite(const tUSBBuffer *psBuffer,
1900  const uint8_t *pui8Data, uint32_t ui32Length);
1901 extern void USBBufferDataWritten(const tUSBBuffer *psBuffer,
1902  uint32_t ui32Length);
1903 extern void USBBufferDataRemoved(const tUSBBuffer *psBuffer,
1904  uint32_t ui32Length);
1905 extern void USBBufferFlush(const tUSBBuffer *psBuffer);
1906 extern uint32_t USBBufferRead(const tUSBBuffer *psBuffer, uint8_t *pui8Data,
1907  uint32_t ui32Length);
1908 extern uint32_t USBBufferDataAvailable(const tUSBBuffer *psBuffer);
1909 extern uint32_t USBBufferSpaceAvailable(const tUSBBuffer *psBuffer);
1910 extern uint32_t USBBufferEventCallback(void *pvCBData, uint32_t ui32Event,
1911  uint32_t ui32MsgValue, void *pvMsgData);
1912 extern bool USBRingBufFull(tUSBRingBufObject *psUSBRingBuf);
1913 extern bool USBRingBufEmpty(tUSBRingBufObject *psUSBRingBuf);
1914 extern void USBRingBufFlush(tUSBRingBufObject *psUSBRingBuf);
1915 extern uint32_t USBRingBufUsed(tUSBRingBufObject *psUSBRingBuf);
1916 extern uint32_t USBRingBufFree(tUSBRingBufObject *psUSBRingBuf);
1917 extern uint32_t USBRingBufContigUsed(tUSBRingBufObject *psUSBRingBuf);
1918 extern uint32_t USBRingBufContigFree(tUSBRingBufObject *psUSBRingBuf);
1919 extern uint32_t USBRingBufSize(tUSBRingBufObject *psUSBRingBuf);
1920 extern uint8_t USBRingBufReadOne(tUSBRingBufObject *psUSBRingBuf);
1921 extern void USBRingBufRead(tUSBRingBufObject *psUSBRingBuf,
1922  uint8_t *pui8Data, uint32_t ui32Length);
1923 extern void USBRingBufWriteOne(tUSBRingBufObject *psUSBRingBuf,
1924  uint8_t ui8Data);
1925 extern void USBRingBufWrite(tUSBRingBufObject *psUSBRingBuf,
1926  const uint8_t *pui8Data, uint32_t ui32Length);
1927 extern void USBRingBufAdvanceWrite(tUSBRingBufObject *psUSBRingBuf,
1928  uint32_t ui32NumBytes);
1929 extern void USBRingBufAdvanceRead(tUSBRingBufObject *psUSBRingBuf,
1930  uint32_t ui32NumBytes);
1931 extern void USBRingBufInit(tUSBRingBufObject *psUSBRingBuf,
1932  uint8_t *pui8Buf, uint32_t ui32Size);
1933 
1934 //*****************************************************************************
1935 //
1936 // Mode selection and dual mode interrupt steering functions.
1937 //
1938 //*****************************************************************************
1939 extern void USBStackModeSet(uint32_t ui32Index, tUSBMode iUSBMode,
1940  tUSBModeCallback pfnCallback);
1941 extern void USBDualModeInit(uint32_t ui32Index);
1942 extern void USBDualModeTerm(uint32_t ui32Index);
1943 extern void USBOTGMain(uint32_t ui32MsTicks);
1944 extern void USBOTGPollRate(uint32_t ui32Index, uint32_t ui32PollRate);
1945 extern void USBOTGModeInit(uint32_t ui32Index, uint32_t ui32PollRate,
1946  void *pHostData, uint32_t ui32HostDataSize);
1947 extern void USBOTGModeTerm(uint32_t ui32Index);
1948 extern void USB0_IRQOTGModeHandler(void);
1949 extern bool USBOTGFeatureSet(uint32_t ui32Index, uint32_t ui32Feature,
1950  void *pvFeature);
1951 extern void USB0DualModeIntHandler(void);
1952 
1953 //*****************************************************************************
1954 //
1955 // Mark the end of the C bindings section for C++ compilers.
1956 //
1957 //*****************************************************************************
1958 #ifdef __cplusplus
1959 }
1960 #endif
1961 
1962 #endif // __USBLIB_H__
tUSBDeviceHandler pfnDeviceHandler
Definition: usblib.h:1037
tStdRequest pfnRequestHandler
Definition: usblib.h:978
Definition: usblib.h:1077
uint8_t * pui8Buf
The ring buffer.
Definition: usblib.h:1792
tUSBMode
Definition: usblib.h:1151
uint8_t iManufacturer
The index of a string descriptor describing the manufacturer.
Definition: usblib.h:390
void USBRingBufWriteOne(tUSBRingBufObject *psUSBRingBuf, uint8_t ui8Data)
Definition: usbringbuf.c:611
tEndpointDescriptor * USBDescGetInterfaceEndpoint(tInterfaceDescriptor *psInterface, uint32_t ui32Index, uint32_t ui32Size)
Definition: usbdesc.c:449
void(* tStdRequest)(void *pvInstance, tUSBRequest *pUSBRequest)
Definition: usblib.h:919
tUSBIntHandler pfnSuspendHandler
Definition: usblib.h:1013
Definition: usblib.h:1157
tUSBEPIntHandler pfnEndpointHandler
Definition: usblib.h:1029
uint32_t USBRingBufSize(tUSBRingBufObject *psUSBRingBuf)
Definition: usbringbuf.c:370
uint8_t * pui8Buffer
Definition: usblib.h:1866
uint32_t ui32Event
One of the USB_EVENT_ values.
Definition: usblib.h:1345
Definition: usblib.h:1175
uint8_t bString
Definition: usblib.h:816
uint16_t bcdDevice
The device release number in BCD format.
Definition: usblib.h:385
uint16_t wIndex
Definition: usblib.h:190
uint8_t bInterval
Definition: usblib.h:712
const uint8_t * pui8Data
Definition: usblib.h:1060
uint8_t bInterfaceClass
The interface class code as assigned by the USB-IF.
Definition: usblib.h:647
tUSBPacketTransfer pfnTransfer
Definition: usblib.h:1843
void USBBufferFlush(const tUSBBuffer *psBuffer)
Definition: usbbuffer.c:859
uint8_t bAlternateSetting
Definition: usblib.h:636
uint8_t bNumEndpoints
Definition: usblib.h:642
uint8_t iConfiguration
The index of a string descriptor describing this configuration.
Definition: usblib.h:577
Definition: usblib.h:1816
void USBBufferDataWritten(const tUSBBuffer *psBuffer, uint32_t ui32Length)
Definition: usbbuffer.c:655
bool USBRingBufFull(tUSBRingBufObject *psUSBRingBuf)
Definition: usbringbuf.c:112
tUSBBufferVars sPrivateData
Definition: usblib.h:1877
void * USBBufferCallbackDataSet(tUSBBuffer *psBuffer, void *pvCBData)
Definition: usbbuffer.c:753
volatile uint32_t ui32WriteIndex
The ring buffer write index.
Definition: usblib.h:1782
uint32_t ui32BufferSize
The size, in bytes, of the buffer pointed to by pi8Buffer.
Definition: usblib.h:1871
void(* tInterfaceCallback)(void *pvInstance, uint8_t ui8InterfaceNum, uint8_t ui8AlternateSetting)
Definition: usblib.h:934
uint16_t idProduct
The device Product ID (PID) as assigned by the manufacturer.
Definition: usblib.h:380
void(* tUSBIntHandler)(void *pvInstance)
Definition: usblib.h:942
void USBRingBufAdvanceRead(tUSBRingBufObject *psUSBRingBuf, uint32_t ui32NumBytes)
Definition: usbringbuf.c:482
void(* tUSBModeCallback)(uint32_t ui32Index, tUSBMode iMode)
Definition: usblib.h:1198
uint32_t USBBufferEventCallback(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgValue, void *pvMsgData)
Definition: usbbuffer.c:1039
void * pvHandle
Definition: usblib.h:1860
tUSBIntHandler pfnDisconnectHandler
This callback is made when the device is disconnected from the USB bus.
Definition: usblib.h:1023
void(* tUSBEPIntHandler)(void *pvInstance, uint32_t ui32Status)
Definition: usblib.h:949
uint32_t USBRingBufContigUsed(tUSBRingBufObject *psUSBRingBuf)
Definition: usbringbuf.c:280
uint8_t bMaxPacketSize0
Definition: usblib.h:370
void(* tUSBDeviceHandler)(void *pvInstance, uint32_t ui32Request, void *pvRequestData)
Definition: usblib.h:957
tUSBIntHandler pfnResetHandler
This callback is made when a USB reset is detected.
Definition: usblib.h:1007
void USBDualModeTerm(uint32_t ui32Index)
Definition: usbmode.c:493
uint8_t bInterfaceProtocol
The interface protocol code as assigned by the USB-IF.
Definition: usblib.h:657
void USBOTGModeTerm(uint32_t ui32Index)
Definition: usbmode.c:538
uint8_t bmAttributes
Attributes of this configuration.
Definition: usblib.h:582
const tConfigSection *const * psSections
Definition: usblib.h:1089
bool bTransmitBuffer
Definition: usblib.h:1824
void USB0_IRQOTGModeHandler(void)
Definition: usbmode.c:791
tInfoCallback pfnDataReceived
Definition: usblib.h:996
tInfoCallback pfnDataSent
Definition: usblib.h:1002
Definition: usblib.h:1181
uint8_t ui8NumSections
Definition: usblib.h:1083
void USBRingBufInit(tUSBRingBufObject *psUSBRingBuf, uint8_t *pui8Buf, uint32_t ui32Size)
Definition: usbringbuf.c:689
uint8_t bNumConfigurations
The number of other-speed configurations supported.
Definition: usblib.h:408
void USBStackModeSet(uint32_t ui32Index, tUSBMode iUSBMode, tUSBModeCallback pfnCallback)
Definition: usbmode.c:244
void USBRingBufFlush(tUSBRingBufObject *psUSBRingBuf)
Definition: usbringbuf.c:184
uint32_t USBBufferWrite(const tUSBBuffer *psBuffer, const uint8_t *pui8Data, uint32_t ui32Length)
Definition: usbbuffer.c:798
uint8_t bMaxPower
Definition: usblib.h:589
uint32_t USBRingBufContigFree(tUSBRingBufObject *psUSBRingBuf)
Definition: usbringbuf.c:317
uint32_t(* tUSBPacketAvailable)(void *pvHandle)
Definition: usblib.h:1636
uint8_t bConfigurationValue
Definition: usblib.h:572
uint32_t ui32Size
The ring buffer size.
Definition: usblib.h:1777
uint32_t ui32Instance
The caller supplied instance value that is passed to event handlers.
Definition: usblib.h:1350
uint32_t USBDescGetNum(tDescriptorHeader *psDesc, uint32_t ui32Size, uint32_t ui32Type)
Definition: usbdesc.c:84
uint32_t USBDescGetNumAlternateInterfaces(tConfigDescriptor *psConfig, uint8_t ui8InterfaceNumber)
Definition: usbdesc.c:225
void(* tInfoCallback)(void *pvInstance, uint32_t ui32Info)
Definition: usblib.h:926
uint32_t(* tUSBPacketTransfer)(void *pvHandle, uint8_t *pi8Data, uint32_t ui32Length, bool bLast)
Definition: usblib.h:1622
void USBBufferDataRemoved(const tUSBBuffer *psBuffer, uint32_t ui32Length)
Definition: usbbuffer.c:707
uint32_t ui32HIRD
Definition: usblib.h:1761
Definition: usblib.h:1169
uint32_t ui32Features
Definition: usblib.h:1762
uint16_t wMaxPacketSize
Definition: usblib.h:706
tUSBPacketAvailable pfnAvailable
Definition: usblib.h:1851
tInterfaceDescriptor * USBDescGetInterface(tConfigDescriptor *psConfig, uint32_t ui32Index, uint32_t ui32Alt)
Definition: usbdesc.c:386
const tUSBBuffer * USBBufferInit(tUSBBuffer *psBuffer)
Definition: usbbuffer.c:502
uint8_t iInterface
The index of a string descriptor describing this interface.
Definition: usblib.h:662
void USBOTGPollRate(uint32_t ui32Index, uint32_t ui32PollRate)
Definition: usbmode.c:761
Definition: usblib.h:1802
tUSBIntHandler pfnResumeHandler
This is called when resume signaling is detected.
Definition: usblib.h:1018
tDescriptorHeader * USBDescGet(tDescriptorHeader *psDesc, uint32_t ui32Size, uint32_t ui32Type, uint32_t ui32Index)
Definition: usbdesc.c:150
tInterfaceCallback pfnInterfaceChange
Definition: usblib.h:984
tUSBRingBufObject sRingBuf
Definition: usblib.h:1804
Definition: usblib.h:1187
uint32_t(* tUSBCallback)(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgParam, void *pvMsgData)
Definition: usblib.h:1220
uint16_t wLength
Definition: usblib.h:196
bool USBOTGFeatureSet(uint32_t ui32Index, uint32_t ui32Feature, void *pvFeature)
Definition: usbmode.c:1127
uint8_t bInterfaceSubClass
The interface subclass code as assigned by the USB-IF.
Definition: usblib.h:652
bool USBRingBufEmpty(tUSBRingBufObject *psUSBRingBuf)
Definition: usbringbuf.c:150
uint8_t bEndpointAddress
Definition: usblib.h:691
uint16_t bcdUSB
Definition: usblib.h:347
uint8_t iSerialNumber
Definition: usblib.h:401
void USBOTGModeInit(uint32_t ui32Index, uint32_t ui32PollRate, void *pHostData, uint32_t ui32HostDataSize)
Definition: usbmode.c:597
Definition: usblib.h:966
uint16_t ui16Size
The number of bytes of descriptor data pointed to by pui8Data.
Definition: usblib.h:1054
void * pvCBData
Definition: usblib.h:1837
uint32_t USBRingBufFree(tUSBRingBufObject *psUSBRingBuf)
Definition: usbringbuf.c:252
Definition: usblib.h:1049
uint32_t USBBufferRead(const tUSBBuffer *psBuffer, uint8_t *pui8Data, uint32_t ui32Length)
Definition: usbbuffer.c:900
uint32_t USBBufferSpaceAvailable(const tUSBBuffer *psBuffer)
Definition: usbbuffer.c:993
uint16_t wValue
Word-sized field that varies according to the request.
Definition: usblib.h:184
uint8_t USBRingBufReadOne(tUSBRingBufObject *psUSBRingBuf)
Definition: usbringbuf.c:395
void USB0DualModeIntHandler(void)
Definition: usbmode.c:304
Definition: usblibpriv.h:177
uint32_t USBBufferDataAvailable(const tUSBBuffer *psBuffer)
Definition: usbbuffer.c:956
uint32_t ui32LastSent
Definition: usblib.h:1805
uint16_t wTotalLength
Definition: usblib.h:561
uint8_t bInterfaceNumber
Definition: usblib.h:630
uint16_t idVendor
The device Vendor ID (VID) as assigned by the USB-IF.
Definition: usblib.h:375
uint8_t bReserved
Reserved for future use. Must be set to zero.
Definition: usblib.h:530
void USBOTGMain(uint32_t ui32MsTicks)
Definition: usbmode.c:1027
Definition: usblib.h:1759
tStdRequest pfnGetDescriptor
Definition: usblib.h:972
tUSBCallback pfnCallback
Definition: usblib.h:1831
uint8_t bmRequestType
Determines the type and direction of the request.
Definition: usblib.h:174
Definition: usblib.h:1772
uint8_t bNumInterfaces
The number of interface supported by this configuration.
Definition: usblib.h:566
void USBBufferInfoGet(const tUSBBuffer *psBuffer, tUSBRingBufObject *psRingBuf)
Definition: usbbuffer.c:608
uint32_t ui32Flags
Definition: usblib.h:1806
void USBBufferZeroLengthPacketInsert(const tUSBBuffer *psBuffer, bool bSendZLP)
Definition: usbbuffer.c:546
void USBRingBufAdvanceWrite(tUSBRingBufObject *psUSBRingBuf, uint32_t ui32NumBytes)
Definition: usbringbuf.c:531
void USBRingBufRead(tUSBRingBufObject *psUSBRingBuf, uint8_t *pui8Data, uint32_t ui32Length)
Definition: usbringbuf.c:439
uint32_t USBRingBufUsed(tUSBRingBufObject *psUSBRingBuf)
Definition: usbringbuf.c:217
Definition: usblib.h:1340
uint8_t iProduct
The index of a string descriptor describing the product.
Definition: usblib.h:395
tInfoCallback pfnConfigChange
Definition: usblib.h:990
uint8_t bDeviceSubClass
Definition: usblib.h:358
volatile uint32_t ui32ReadIndex
The ring buffer read index.
Definition: usblib.h:1787
uint8_t bDeviceClass
The device class code.
Definition: usblib.h:352
uint8_t bDeviceProtocol
Definition: usblib.h:364
void USBRingBufWrite(tUSBRingBufObject *psUSBRingBuf, const uint8_t *pui8Data, uint32_t ui32Length)
Definition: usbringbuf.c:649
Definition: usblib.h:1163
USB_CDC_GET/SET_LINE_CODING request-specific data.
Definition: usbaudio.h:288
uint8_t bRequest
Identifies the specific request being made.
Definition: usblib.h:179
void USBDualModeInit(uint32_t ui32Index)
Definition: usbmode.c:414
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale