1 | #ifndef _usbcalls_h__
|
---|
2 | #define _usbcalls_h_
|
---|
3 |
|
---|
4 | #ifdef __cplusplus
|
---|
5 | extern "C" {
|
---|
6 | #endif
|
---|
7 |
|
---|
8 | typedef ULONG USBHANDLE, *PUSBHANDLE;
|
---|
9 | typedef ULONG USBNOTIFY, *PUSBNOTIFY;
|
---|
10 | typedef ULONG ISOHANDLE, *PISOHANDLE;
|
---|
11 |
|
---|
12 | #define USB_NOT_INIT 7000
|
---|
13 | #define USB_ERROR_NO_MORE_NOTIFICATIONS 7001
|
---|
14 | #define USB_ERROR_OUTOF_RESOURCES 7002
|
---|
15 | #define USB_ERROR_INVALID_ENDPOINT 7003
|
---|
16 | #define USB_ERROR_LESSTRANSFERED 7004
|
---|
17 |
|
---|
18 | /* IORB status codes */
|
---|
19 | #define USB_IORB_DONE 0x0000
|
---|
20 | #define USB_IORB_FAILED 0x8000
|
---|
21 |
|
---|
22 | #define USB_ANY_PRODUCTVERSION 0xFFFF
|
---|
23 | #define USB_OPEN_FIRST_UNUSED 0
|
---|
24 |
|
---|
25 | #ifdef USB_BIND_DYNAMIC
|
---|
26 | typedef APIRET APIENTRY USBREGISTERDEVICENOTIFICATION( PUSBNOTIFY pNotifyID,
|
---|
27 | HEV hDeviceAdded,
|
---|
28 | HEV hDeviceRemoved,
|
---|
29 | USHORT usVendor,
|
---|
30 | USHORT usProduct,
|
---|
31 | USHORT usBCDVersion);
|
---|
32 | typedef USBREGISTERDEVICENOTIFICATION *PUSBREGISTERDEVICENOTIFICATION;
|
---|
33 |
|
---|
34 | typedef APIRET APIENTRY USBDEREGISTERNOTIFICATION( USBNOTIFY NotifyID);
|
---|
35 |
|
---|
36 | typedef USBDEREGISTERNOTIFICATION *PUSBDEREGISTERNOTIFICATION;
|
---|
37 |
|
---|
38 | typedef APIRET APIENTRY USBOPEN( PUSBHANDLE pHandle,
|
---|
39 | USHORT usVendor,
|
---|
40 | USHORT usProduct,
|
---|
41 | USHORT usBCDDevice,
|
---|
42 | USHORT usEnumDevice);
|
---|
43 | typedef USBOPEN *PUSBOPEN;
|
---|
44 | typedef APIRET APIENTRY USBCLOSE( USBHANDLE Handle);
|
---|
45 | typedef USBCLOSE *PUSBCLOSE;
|
---|
46 |
|
---|
47 | typedef APIRET APIENTRY USBCTRLMESSAGE( USBHANDLE Handle,
|
---|
48 | UCHAR ucRequestType,
|
---|
49 | UCHAR ucRequest,
|
---|
50 | USHORT usValue,
|
---|
51 | USHORT usIndex,
|
---|
52 | USHORT usLength,
|
---|
53 | PVOID pvData,
|
---|
54 | ULONG ulTimeout);
|
---|
55 | typedef USBCTRLMESSAGE *PUSBCTRLMESSAGE;
|
---|
56 | #else
|
---|
57 | APIRET APIENTRY UsbQueryNumberDevices( ULONG *pulNumDev);
|
---|
58 |
|
---|
59 | APIRET APIENTRY UsbQueryDeviceReport( ULONG ulDevNumber,
|
---|
60 | ULONG *ulBufLen,
|
---|
61 | PVOID pvData);
|
---|
62 | APIRET APIENTRY UsbRegisterChangeNotification( PUSBNOTIFY pNotifyID,
|
---|
63 | HEV hDeviceAdded,
|
---|
64 | HEV hDeviceRemoved);
|
---|
65 |
|
---|
66 | APIRET APIENTRY UsbRegisterDeviceNotification( PUSBNOTIFY pNotifyID,
|
---|
67 | HEV hDeviceAdded,
|
---|
68 | HEV hDeviceRemoved,
|
---|
69 | USHORT usVendor,
|
---|
70 | USHORT usProduct,
|
---|
71 | USHORT usBCDVersion);
|
---|
72 |
|
---|
73 | APIRET APIENTRY UsbDeregisterNotification( USBNOTIFY NotifyID);
|
---|
74 |
|
---|
75 | APIRET APIENTRY UsbOpen( PUSBHANDLE pHandle,
|
---|
76 | USHORT usVendor,
|
---|
77 | USHORT usProduct,
|
---|
78 | USHORT usBCDDevice,
|
---|
79 | USHORT usEnumDevice);
|
---|
80 |
|
---|
81 | APIRET APIENTRY UsbClose( USBHANDLE Handle);
|
---|
82 |
|
---|
83 | APIRET APIENTRY UsbCtrlMessage( USBHANDLE Handle,
|
---|
84 | UCHAR ucRequestType,
|
---|
85 | UCHAR ucRequest,
|
---|
86 | USHORT usValue,
|
---|
87 | USHORT usIndex,
|
---|
88 | USHORT usLength,
|
---|
89 | PVOID pvData,
|
---|
90 | ULONG ulTimeout);
|
---|
91 |
|
---|
92 | APIRET APIENTRY UsbBulkRead( USBHANDLE Handle,
|
---|
93 | UCHAR Endpoint,
|
---|
94 | UCHAR Interface,
|
---|
95 | ULONG *ulNumBytes,
|
---|
96 | PVOID pvData,
|
---|
97 | ULONG ulTimeout);
|
---|
98 |
|
---|
99 | APIRET APIENTRY UsbBulkRead2( USBHANDLE Handle,
|
---|
100 | UCHAR Endpoint,
|
---|
101 | UCHAR Interface,
|
---|
102 | BOOL fShortOk,
|
---|
103 | ULONG *ulNumBytes,
|
---|
104 | PVOID pvData,
|
---|
105 | ULONG ulTimeout);
|
---|
106 |
|
---|
107 | APIRET APIENTRY UsbBulkWrite( USBHANDLE Handle,
|
---|
108 | UCHAR Endpoint,
|
---|
109 | UCHAR Interface,
|
---|
110 | ULONG ulNumBytes,
|
---|
111 | PVOID pvData,
|
---|
112 | ULONG ulTimeout);
|
---|
113 |
|
---|
114 | APIRET APIENTRY UsbBulkWrite2( USBHANDLE Handle,
|
---|
115 | UCHAR Endpoint,
|
---|
116 | UCHAR AltInterface,
|
---|
117 | BOOL fShortOk,
|
---|
118 | ULONG ulNumBytes,
|
---|
119 | PVOID pvData,
|
---|
120 | ULONG ulTimeout);
|
---|
121 |
|
---|
122 | APIRET APIENTRY UsbIrqStart( USBHANDLE Handle,
|
---|
123 | UCHAR Endpoint,
|
---|
124 | UCHAR Interface,
|
---|
125 | USHORT usNumBytes,
|
---|
126 | PVOID pvData,
|
---|
127 | PHEV pHevModified);
|
---|
128 | APIRET APIENTRY UsbIrqStop( USBHANDLE Handle,
|
---|
129 | HEV HevModified);
|
---|
130 |
|
---|
131 | APIRET APIENTRY UsbIsoStart( USBHANDLE Handle,
|
---|
132 | UCHAR Endpoint,
|
---|
133 | UCHAR Interface,
|
---|
134 | ISOHANDLE *phIso);
|
---|
135 | APIRET APIENTRY UsbIsoStop( ISOHANDLE hIso);
|
---|
136 |
|
---|
137 | APIRET APIENTRY UsbIsoDequeue( ISOHANDLE hIso,
|
---|
138 | PVOID pBuffer,
|
---|
139 | ULONG ulNumBytes);
|
---|
140 | APIRET APIENTRY UsbIsoEnqueue( ISOHANDLE hIso,
|
---|
141 | const UCHAR * pBuffer,
|
---|
142 | ULONG ulNumBytes);
|
---|
143 | APIRET APIENTRY UsbIsoPeekQueue( ISOHANDLE hIso,
|
---|
144 | UCHAR * pByte,
|
---|
145 | ULONG ulOffset);
|
---|
146 | APIRET APIENTRY UsbIsoGetLength( ISOHANDLE hIso,
|
---|
147 | ULONG *pulLength);
|
---|
148 |
|
---|
149 | APIRET APIENTRY UsbIrqRead( USBHANDLE Handle,
|
---|
150 | UCHAR Endpoint,
|
---|
151 | UCHAR Interface,
|
---|
152 | ULONG *ulNumBytes,
|
---|
153 | PVOID pvData,
|
---|
154 | ULONG ulTimeout);
|
---|
155 |
|
---|
156 | APIRET APIENTRY UsbFixupDevice( USBHANDLE Handle,
|
---|
157 | UCHAR ucConfiguration,
|
---|
158 | UCHAR *pucConfigurationData,
|
---|
159 | ULONG ulConfigurationLen );
|
---|
160 |
|
---|
161 | APIRET APIENTRY InitUsbCalls(void);
|
---|
162 | APIRET APIENTRY TermUsbCalls(void);
|
---|
163 |
|
---|
164 | /* Standard USB Requests See 9.4. in USB 1.1. spec. */
|
---|
165 |
|
---|
166 | /* 09 01 2003 - KIEWITZ */
|
---|
167 | #define UsbDeviceClearFeature(HANDLE, FEAT) \
|
---|
168 | UsbCtrlMessage(HANDLE, 0x00, 0x01, FEAT, 0, 0, NULL, 0)
|
---|
169 | #define UsbDeviceSetFeature(HANDLE, FEAT) \
|
---|
170 | UsbCtrlMessage(HANDLE, 0x80, 0x03, FEAT, 0, 0, NULL, 0)
|
---|
171 | #define UsbInterfaceClearFeature(HANDLE, IFACE, FEAT) \
|
---|
172 | UsbCtrlMessage(HANDLE, 0x01, 0x01, FEAT, IFACE, 0, NULL, 0)
|
---|
173 | #define UsbInterfaceSetFeature(HANDLE, IFACE, FEAT) \
|
---|
174 | UsbCtrlMessage(HANDLE, 0x80, 0x03, FEAT, IFACE, 0, NULL, 0)
|
---|
175 | #define UsbEndpointClearFeature(HANDLE, ENDPOINT, FEAT) \
|
---|
176 | UsbCtrlMessage(HANDLE, 0x02, 0x01, FEAT, ENDPOINT, 0, NULL, 0)
|
---|
177 | #define UsbEndpointSetFeature(HANDLE, ENDPOINT, FEAT) \
|
---|
178 | UsbCtrlMessage(HANDLE, 0x80, 0x03, FEAT, ENDPOINT, 0, NULL, 0)
|
---|
179 | #define FEATURE_DEVICE_REMOTE_WAKEUP 1
|
---|
180 | #define FEATURE_ENDPOINT_HALT 0
|
---|
181 | #define UsbEndpointClearHalt(HANDLE, ENDPOINT) \
|
---|
182 | UsbEndpointClearFeature(HANDLE, ENDPOINT, FEATURE_ENDPOINT_HALT)
|
---|
183 |
|
---|
184 | #define UsbDeviceGetConfiguration(HANDLE, DATA) \
|
---|
185 | UsbCtrlMessage(HANDLE, 0x80, 0x08, 0, 0, 1, DATA, 0)
|
---|
186 | #define UsbDeviceSetConfiguration(HANDLE, CONFIG) \
|
---|
187 | UsbCtrlMessage(HANDLE, 0x00, 0x09, CONFIG, 0, 0, NULL, 0)
|
---|
188 |
|
---|
189 | #define UsbDeviceGetStatus(HANDLE, STATUS) \
|
---|
190 | UsbCtrlMessage(HANDLE, 0x80, 0x00, 0, 0, 2, STATUS, 0)
|
---|
191 | #define UsbInterfaceGetStatus(HANDLE, IFACE, STATUS) \
|
---|
192 | UsbCtrlMessage(HANDLE, 0x80, 0x00, 0, IFACE, 2, STATUS, 0)
|
---|
193 | #define UsbEndpointGetStatus(HANDLE, ENDPOINT, STATUS) \
|
---|
194 | UsbCtrlMessage(HANDLE, 0x80, 0x00, 0, ENDPOINT, 2, STATUS, 0)
|
---|
195 |
|
---|
196 | #define STATUS_ENDPOINT_HALT 0x0001
|
---|
197 | #define STATUS_DEVICE_SELFPOWERD 0x0001
|
---|
198 | #define STATUS_DEVICE_REMOTEWAKEUP 0x0002
|
---|
199 |
|
---|
200 | #define UsbDeviceSetAddress(HANDLE, ADDRESS) \
|
---|
201 | UsbCtrlMessage(HANDLE, 0x80, 0x05, ADDRESS, 0, 0, NULL, 0)
|
---|
202 |
|
---|
203 | #define UsbDeviceGetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
204 | UsbCtrlMessage(HANDLE, 0x80, 0x06, (0x0100|INDEX), LID, LEN, DATA, 0)
|
---|
205 | #define UsbDeviceSetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
206 | UsbCtrlMessage(HANDLE, 0x80, 0x07, (0x0100|INDEX), LID, LEN, DATA, 0)
|
---|
207 | #define UsbConfigurationGetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
208 | UsbCtrlMessage(HANDLE, 0x80, 0x06, (0x0200|INDEX), LID, LEN, DATA, 0)
|
---|
209 | #define UsbConfigurationSetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
210 | UsbCtrlMessage(HANDLE, 0x80, 0x07, (0x0200|INDEX), LID, LEN, DATA, 0)
|
---|
211 | #define UsbStringGetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
212 | UsbCtrlMessage(HANDLE, 0x80, 0x06, (0x0300|INDEX), LID, LEN, DATA, 0)
|
---|
213 | #define UsbStringSetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
214 | UsbCtrlMessage(HANDLE, 0x80, 0x07, (0x0300|INDEX), LID, LEN, DATA, 0)
|
---|
215 | #define UsbInterfaceGetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
216 | UsbCtrlMessage(HANDLE, 0x80, 0x06, (0x0400|INDEX), LID, LEN, DATA, 0)
|
---|
217 | #define UsbInterfaceSetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
218 | UsbCtrlMessage(HANDLE, 0x80, 0x07, (0x0400|INDEX), LID, LEN, DATA, 0)
|
---|
219 | #define UsbEndpointGetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
220 | UsbCtrlMessage(HANDLE, 0x80, 0x06, (0x0500|INDEX), LID, LEN, DATA, 0)
|
---|
221 | #define UsbEndpointSetDescriptor(HANDLE, INDEX, LID, LEN, DATA) \
|
---|
222 | UsbCtrlMessage(HANDLE, 0x80, 0x07, (0x0500|INDEX), LID, LEN, DATA, 0)
|
---|
223 |
|
---|
224 | #define UsbInterfaceGetAltSetting(HANDLE, IFACE, SETTING) \
|
---|
225 | UsbCtrlMessage(HANDLE, 0x81, 0x0A, 0, IFACE, 1, SETTING, 0)
|
---|
226 | #define UsbInterfaceSetAltSetting(HANDLE, IFACE, ALTSET) \
|
---|
227 | UsbCtrlMessage(HANDLE, 0x01, 0x0B, ALTSET, IFACE, 0, NULL, 0)
|
---|
228 |
|
---|
229 | #define UsbEndpointSynchFrame(HANDLE, ENDPOINT, FRAMENUM) \
|
---|
230 | UsbCtrlMessage(HANDLE, 0x82, 0x0B, 0, ENDPOINT, 2, FRAMENUM, 0)
|
---|
231 | #endif
|
---|
232 |
|
---|
233 |
|
---|
234 | #ifdef __cplusplus
|
---|
235 | }
|
---|
236 | #endif
|
---|
237 |
|
---|
238 | #endif /* _usbcalls_h_ */
|
---|