1 |
/*---------------------------------------------------------------------------- |
---|
2 |
* U S B - K e r n e l |
---|
3 |
*---------------------------------------------------------------------------- |
---|
4 |
* Name: USBUSER.C |
---|
5 |
* Purpose: USB Custom User Module |
---|
6 |
* Version: V1.10 |
---|
7 |
*---------------------------------------------------------------------------- |
---|
8 |
* This file is part of the uVision/ARM development tools. |
---|
9 |
* This software may only be used under the terms of a valid, current, |
---|
10 |
* end user licence from KEIL for a compatible version of KEIL software |
---|
11 |
* development tools. Nothing else gives you the right to use it. |
---|
12 |
* |
---|
13 |
* Copyright (c) 2005-2006 Keil Software. |
---|
14 |
*---------------------------------------------------------------------------*/ |
---|
15 |
|
---|
16 |
#include <LPC23xx.H> /* LPC23xx definitions */ |
---|
17 |
|
---|
18 |
#include "type.h" |
---|
19 |
|
---|
20 |
#include "usb.h" |
---|
21 |
#include "usbcfg.h" |
---|
22 |
#include "usbhw.h" |
---|
23 |
#include "usbcore.h" |
---|
24 |
#include "usbuser.h" |
---|
25 |
|
---|
26 |
#include "demo.h" |
---|
27 |
|
---|
28 |
|
---|
29 |
/* |
---|
30 |
* USB Power Event Callback |
---|
31 |
* Called automatically on USB Power Event |
---|
32 |
* Parameter: power: On(TRUE)/Off(FALSE) |
---|
33 |
*/ |
---|
34 |
|
---|
35 |
#if USB_POWER_EVENT |
---|
36 |
void USB_Power_Event (BOOL power) { |
---|
37 |
} |
---|
38 |
#endif |
---|
39 |
|
---|
40 |
|
---|
41 |
/* |
---|
42 |
* USB Reset Event Callback |
---|
43 |
* Called automatically on USB Reset Event |
---|
44 |
*/ |
---|
45 |
|
---|
46 |
#if USB_RESET_EVENT |
---|
47 |
void USB_Reset_Event (void) { |
---|
48 |
USB_ResetCore(); |
---|
49 |
} |
---|
50 |
#endif |
---|
51 |
|
---|
52 |
|
---|
53 |
/* |
---|
54 |
* USB Suspend Event Callback |
---|
55 |
* Called automatically on USB Suspend Event |
---|
56 |
*/ |
---|
57 |
|
---|
58 |
#if USB_SUSPEND_EVENT |
---|
59 |
void USB_Suspend_Event (void) { |
---|
60 |
} |
---|
61 |
#endif |
---|
62 |
|
---|
63 |
|
---|
64 |
/* |
---|
65 |
* USB Resume Event Callback |
---|
66 |
* Called automatically on USB Resume Event |
---|
67 |
*/ |
---|
68 |
|
---|
69 |
#if USB_RESUME_EVENT |
---|
70 |
void USB_Resume_Event (void) { |
---|
71 |
} |
---|
72 |
#endif |
---|
73 |
|
---|
74 |
|
---|
75 |
/* |
---|
76 |
* USB Remote Wakeup Event Callback |
---|
77 |
* Called automatically on USB Remote Wakeup Event |
---|
78 |
*/ |
---|
79 |
|
---|
80 |
#if USB_WAKEUP_EVENT |
---|
81 |
void USB_WakeUp_Event (void) { |
---|
82 |
} |
---|
83 |
#endif |
---|
84 |
|
---|
85 |
|
---|
86 |
/* |
---|
87 |
* USB Start of Frame Event Callback |
---|
88 |
* Called automatically on USB Start of Frame Event |
---|
89 |
*/ |
---|
90 |
|
---|
91 |
#if USB_SOF_EVENT |
---|
92 |
void USB_SOF_Event (void) { |
---|
93 |
} |
---|
94 |
#endif |
---|
95 |
|
---|
96 |
|
---|
97 |
/* |
---|
98 |
* USB Error Event Callback |
---|
99 |
* Called automatically on USB Error Event |
---|
100 |
* Parameter: error: Error Code |
---|
101 |
*/ |
---|
102 |
|
---|
103 |
#if USB_ERROR_EVENT |
---|
104 |
void USB_Error_Event (DWORD error) { |
---|
105 |
} |
---|
106 |
#endif |
---|
107 |
|
---|
108 |
|
---|
109 |
/* |
---|
110 |
* USB Set Configuration Event Callback |
---|
111 |
* Called automatically on USB Set Configuration Request |
---|
112 |
*/ |
---|
113 |
|
---|
114 |
#if USB_CONFIGURE_EVENT |
---|
115 |
void USB_Configure_Event (void) { |
---|
116 |
|
---|
117 |
if (USB_Configuration) { /* Check if USB is configured */ |
---|
118 |
GetInReport(); |
---|
119 |
USB_WriteEP(0x81, &InReport, sizeof(InReport)); |
---|
120 |
} |
---|
121 |
} |
---|
122 |
#endif |
---|
123 |
|
---|
124 |
|
---|
125 |
/* |
---|
126 |
* USB Set Interface Event Callback |
---|
127 |
* Called automatically on USB Set Interface Request |
---|
128 |
*/ |
---|
129 |
|
---|
130 |
#if USB_INTERFACE_EVENT |
---|
131 |
void USB_Interface_Event (void) { |
---|
132 |
} |
---|
133 |
#endif |
---|
134 |
|
---|
135 |
|
---|
136 |
/* |
---|
137 |
* USB Set/Clear Feature Event Callback |
---|
138 |
* Called automatically on USB Set/Clear Feature Request |
---|
139 |
*/ |
---|
140 |
|
---|
141 |
#if USB_FEATURE_EVENT |
---|
142 |
void USB_Feature_Event (void) { |
---|
143 |
} |
---|
144 |
#endif |
---|
145 |
|
---|
146 |
|
---|
147 |
#define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL) |
---|
148 |
|
---|
149 |
/* USB Endpoint Events Callback Pointers */ |
---|
150 |
void (* const USB_P_EP[16]) (DWORD event) = { |
---|
151 |
P_EP(0), |
---|
152 |
P_EP(1), |
---|
153 |
P_EP(2), |
---|
154 |
P_EP(3), |
---|
155 |
P_EP(4), |
---|
156 |
P_EP(5), |
---|
157 |
P_EP(6), |
---|
158 |
P_EP(7), |
---|
159 |
P_EP(8), |
---|
160 |
P_EP(9), |
---|
161 |
P_EP(10), |
---|
162 |
P_EP(11), |
---|
163 |
P_EP(12), |
---|
164 |
P_EP(13), |
---|
165 |
P_EP(14), |
---|
166 |
P_EP(15), |
---|
167 |
}; |
---|
168 |
|
---|
169 |
|
---|
170 |
/* |
---|
171 |
* USB Endpoint 1 Event Callback |
---|
172 |
* Called automatically on USB Endpoint 1 Event |
---|
173 |
* Parameter: event |
---|
174 |
*/ |
---|
175 |
|
---|
176 |
void USB_EndPoint1 (DWORD event) { |
---|
177 |
|
---|
178 |
switch (event) { |
---|
179 |
case USB_EVT_IN: |
---|
180 |
GetInReport(); |
---|
181 |
USB_WriteEP(0x81, &InReport, sizeof(InReport)); |
---|
182 |
break; |
---|
183 |
} |
---|
184 |
} |
---|
185 |
|
---|
186 |
|
---|
187 |
/* |
---|
188 |
* USB Endpoint 2 Event Callback |
---|
189 |
* Called automatically on USB Endpoint 2 Event |
---|
190 |
* Parameter: event |
---|
191 |
*/ |
---|
192 |
|
---|
193 |
void USB_EndPoint2 (DWORD event) { |
---|
194 |
} |
---|
195 |
|
---|
196 |
|
---|
197 |
/* |
---|
198 |
* USB Endpoint 3 Event Callback |
---|
199 |
* Called automatically on USB Endpoint 3 Event |
---|
200 |
* Parameter: event |
---|
201 |
*/ |
---|
202 |
|
---|
203 |
void USB_EndPoint3 (DWORD event) { |
---|
204 |
} |
---|
205 |
|
---|
206 |
|
---|
207 |
/* |
---|
208 |
* USB Endpoint 4 Event Callback |
---|
209 |
* Called automatically on USB Endpoint 4 Event |
---|
210 |
* Parameter: event |
---|
211 |
*/ |
---|
212 |
|
---|
213 |
void USB_EndPoint4 (DWORD event) { |
---|
214 |
} |
---|
215 |
|
---|
216 |
|
---|
217 |
/* |
---|
218 |
* USB Endpoint 5 Event Callback |
---|
219 |
* Called automatically on USB Endpoint 5 Event |
---|
220 |
* Parameter: event |
---|
221 |
*/ |
---|
222 |
|
---|
223 |
void USB_EndPoint5 (DWORD event) { |
---|
224 |
} |
---|
225 |
|
---|
226 |
|
---|
227 |
/* |
---|
228 |
* USB Endpoint 6 Event Callback |
---|
229 |
* Called automatically on USB Endpoint 6 Event |
---|
230 |
* Parameter: event |
---|
231 |
*/ |
---|
232 |
|
---|
233 |
void USB_EndPoint6 (DWORD event) { |
---|
234 |
} |
---|
235 |
|
---|
236 |
|
---|
237 |
/* |
---|
238 |
* USB Endpoint 7 Event Callback |
---|
239 |
* Called automatically on USB Endpoint 7 Event |
---|
240 |
* Parameter: event |
---|
241 |
*/ |
---|
242 |
|
---|
243 |
void USB_EndPoint7 (DWORD event) { |
---|
244 |
} |
---|
245 |
|
---|
246 |
|
---|
247 |
/* |
---|
248 |
* USB Endpoint 8 Event Callback |
---|
249 |
* Called automatically on USB Endpoint 8 Event |
---|
250 |
* Parameter: event |
---|
251 |
*/ |
---|
252 |
|
---|
253 |
void USB_EndPoint8 (DWORD event) { |
---|
254 |
} |
---|
255 |
|
---|
256 |
|
---|
257 |
/* |
---|
258 |
* USB Endpoint 9 Event Callback |
---|
259 |
* Called automatically on USB Endpoint 9 Event |
---|
260 |
* Parameter: event |
---|
261 |
*/ |
---|
262 |
|
---|
263 |
void USB_EndPoint9 (DWORD event) { |
---|
264 |
} |
---|
265 |
|
---|
266 |
|
---|
267 |
/* |
---|
268 |
* USB Endpoint 10 Event Callback |
---|
269 |
* Called automatically on USB Endpoint 10 Event |
---|
270 |
* Parameter: event |
---|
271 |
*/ |
---|
272 |
|
---|
273 |
void USB_EndPoint10 (DWORD event) { |
---|
274 |
} |
---|
275 |
|
---|
276 |
|
---|
277 |
/* |
---|
278 |
* USB Endpoint 11 Event Callback |
---|
279 |
* Called automatically on USB Endpoint 11 Event |
---|
280 |
* Parameter: event |
---|
281 |
*/ |
---|
282 |
|
---|
283 |
void USB_EndPoint11 (DWORD event) { |
---|
284 |
} |
---|
285 |
|
---|
286 |
|
---|
287 |
/* |
---|
288 |
* USB Endpoint 12 Event Callback |
---|
289 |
* Called automatically on USB Endpoint 12 Event |
---|
290 |
* Parameter: event |
---|
291 |
*/ |
---|
292 |
|
---|
293 |
void USB_EndPoint12 (DWORD event) { |
---|
294 |
} |
---|
295 |
|
---|
296 |
|
---|
297 |
/* |
---|
298 |
* USB Endpoint 13 Event Callback |
---|
299 |
* Called automatically on USB Endpoint 13 Event |
---|
300 |
* Parameter: event |
---|
301 |
*/ |
---|
302 |
|
---|
303 |
void USB_EndPoint13 (DWORD event) { |
---|
304 |
} |
---|
305 |
|
---|
306 |
|
---|
307 |
/* |
---|
308 |
* USB Endpoint 14 Event Callback |
---|
309 |
* Called automatically on USB Endpoint 14 Event |
---|
310 |
* Parameter: event |
---|
311 |
*/ |
---|
312 |
|
---|
313 |
void USB_EndPoint14 (DWORD event) { |
---|
314 |
} |
---|
315 |
|
---|
316 |
|
---|
317 |
/* |
---|
318 |
* USB Endpoint 15 Event Callback |
---|
319 |
* Called automatically on USB Endpoint 15 Event |
---|
320 |
* Parameter: event |
---|
321 |
*/ |
---|
322 |
|
---|
323 |
void USB_EndPoint15 (DWORD event) { |
---|
324 |
} |
---|