root/Examples_CP-JR_ARM7_LPC2368/ETT_LPC2368_Examples/USB_DEMO/USBCDC/usbuser.c

Revision 8, 6.4 kB (checked in by phil, 16 years ago)

Added Examples etc. from CD

Line 
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 software is supplied "AS IS" without any warranties, express,
9  * implied or statutory, including but not limited to the implied
10  * warranties of fitness for purpose, satisfactory quality and
11  * noninfringement. Keil extends you a royalty-free right to reproduce
12  * and distribute executable files created using this software for use
13  * on NXP LPC microcontroller devices only. Nothing else gives you
14  * the right to use this software.
15  *
16  * Copyright (c) 2005-2007 Keil Software.
17  *---------------------------------------------------------------------------*/
18
19 #include <LPC23xx.H>                        /* LPC23xx definitions */
20
21 #include "type.h"
22
23 #include "usb.h"
24 #include "usbcfg.h"
25 #include "usbhw.h"
26 #include "usbcore.h"
27 #include "usbuser.h"
28 #include "cdcuser.h"
29
30
31 /*
32  *  USB Power Event Callback
33  *   Called automatically on USB Power Event
34  *    Parameter:       power: On(TRUE)/Off(FALSE)
35  */
36
37 #if USB_POWER_EVENT
38 void USB_Power_Event (BOOL  power) {
39 }
40 #endif
41
42
43 /*
44  *  USB Reset Event Callback
45  *   Called automatically on USB Reset Event
46  */
47
48 #if USB_RESET_EVENT
49 void USB_Reset_Event (void) {
50   USB_ResetCore();
51 }
52 #endif
53
54
55 /*
56  *  USB Suspend Event Callback
57  *   Called automatically on USB Suspend Event
58  */
59
60 #if USB_SUSPEND_EVENT
61 void USB_Suspend_Event (void) {
62 }
63 #endif
64
65
66 /*
67  *  USB Resume Event Callback
68  *   Called automatically on USB Resume Event
69  */
70
71 #if USB_RESUME_EVENT
72 void USB_Resume_Event (void) {
73 }
74 #endif
75
76
77 /*
78  *  USB Remote Wakeup Event Callback
79  *   Called automatically on USB Remote Wakeup Event
80  */
81
82 #if USB_WAKEUP_EVENT
83 void USB_WakeUp_Event (void) {
84 }
85 #endif
86
87
88 /*
89  *  USB Start of Frame Event Callback
90  *   Called automatically on USB Start of Frame Event
91  */
92
93 #if USB_SOF_EVENT
94 void USB_SOF_Event (void) {
95 }
96 #endif
97
98
99 /*
100  *  USB Error Event Callback
101  *   Called automatically on USB Error Event
102  *    Parameter:       error: Error Code
103  */
104
105 #if USB_ERROR_EVENT
106 void USB_Error_Event (DWORD error) {
107 }
108 #endif
109
110
111 /*
112  *  USB Set Configuration Event Callback
113  *   Called automatically on USB Set Configuration Request
114  */
115
116 #if USB_CONFIGURE_EVENT
117 void USB_Configure_Event (void) {
118
119   if (USB_Configuration) {                  /* Check if USB is configured */
120     /* add your code here */
121   }
122 }
123 #endif
124
125
126 /*
127  *  USB Set Interface Event Callback
128  *   Called automatically on USB Set Interface Request
129  */
130
131 #if USB_INTERFACE_EVENT
132 void USB_Interface_Event (void) {
133 }
134 #endif
135
136
137 /*
138  *  USB Set/Clear Feature Event Callback
139  *   Called automatically on USB Set/Clear Feature Request
140  */
141
142 #if USB_FEATURE_EVENT
143 void USB_Feature_Event (void) {
144 }
145 #endif
146
147
148 #define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)
149
150 /* USB Endpoint Events Callback Pointers */
151 void (* const USB_P_EP[16]) (DWORD event) = {
152   P_EP(0),
153   P_EP(1),
154   P_EP(2),
155   P_EP(3),
156   P_EP(4),
157   P_EP(5),
158   P_EP(6),
159   P_EP(7),
160   P_EP(8),
161   P_EP(9),
162   P_EP(10),
163   P_EP(11),
164   P_EP(12),
165   P_EP(13),
166   P_EP(14),
167   P_EP(15),
168 };
169
170
171 /*
172  *  USB Endpoint 1 Event Callback
173  *   Called automatically on USB Endpoint 1 Event
174  *    Parameter:       event
175  */
176
177 void USB_EndPoint1 (DWORD event) {
178          WORD temp;
179   static WORD serialState;
180
181   switch (event) {
182     case USB_EVT_IN:
183       temp = CDC_GetSerialState();
184       if (serialState != temp) {
185          serialState = temp;
186          CDC_NotificationIn();            /* send SERIAL_STATE notification */
187       }
188       break;
189   }
190 }
191
192
193 /*
194  *  USB Endpoint 2 Event Callback
195  *   Called automatically on USB Endpoint 2 Event
196  *    Parameter:       event
197  */
198
199 void USB_EndPoint2 (DWORD event) {
200
201   switch (event) {
202     case USB_EVT_OUT:
203       CDC_BulkOut ();                /* data received from Host */
204       break;
205     case USB_EVT_IN:
206       CDC_BulkIn ();                 /* data expected from Host */
207       break;
208   }
209 }
210
211
212 /*
213  *  USB Endpoint 3 Event Callback
214  *   Called automatically on USB Endpoint 3 Event
215  *    Parameter:       event
216  */
217
218 void USB_EndPoint3 (DWORD event) {
219 }
220
221
222 /*
223  *  USB Endpoint 4 Event Callback
224  *   Called automatically on USB Endpoint 4 Event
225  *    Parameter:       event
226  */
227
228 void USB_EndPoint4 (DWORD event) {
229 }
230
231
232 /*
233  *  USB Endpoint 5 Event Callback
234  *   Called automatically on USB Endpoint 5 Event
235  *    Parameter:       event
236  */
237
238 void USB_EndPoint5 (DWORD event) {
239 }
240
241
242 /*
243  *  USB Endpoint 6 Event Callback
244  *   Called automatically on USB Endpoint 6 Event
245  *    Parameter:       event
246  */
247
248 void USB_EndPoint6 (DWORD event) {
249 }
250
251
252 /*
253  *  USB Endpoint 7 Event Callback
254  *   Called automatically on USB Endpoint 7 Event
255  *    Parameter:       event
256  */
257
258 void USB_EndPoint7 (DWORD event) {
259 }
260
261
262 /*
263  *  USB Endpoint 8 Event Callback
264  *   Called automatically on USB Endpoint 8 Event
265  *    Parameter:       event
266  */
267
268 void USB_EndPoint8 (DWORD event) {
269 }
270
271
272 /*
273  *  USB Endpoint 9 Event Callback
274  *   Called automatically on USB Endpoint 9 Event
275  *    Parameter:       event
276  */
277
278 void USB_EndPoint9 (DWORD event) {
279 }
280
281
282 /*
283  *  USB Endpoint 10 Event Callback
284  *   Called automatically on USB Endpoint 10 Event
285  *    Parameter:       event
286  */
287
288 void USB_EndPoint10 (DWORD event) {
289 }
290
291
292 /*
293  *  USB Endpoint 11 Event Callback
294  *   Called automatically on USB Endpoint 11 Event
295  *    Parameter:       event
296  */
297
298 void USB_EndPoint11 (DWORD event) {
299 }
300
301
302 /*
303  *  USB Endpoint 12 Event Callback
304  *   Called automatically on USB Endpoint 12 Event
305  *    Parameter:       event
306  */
307
308 void USB_EndPoint12 (DWORD event) {
309 }
310
311
312 /*
313  *  USB Endpoint 13 Event Callback
314  *   Called automatically on USB Endpoint 13 Event
315  *    Parameter:       event
316  */
317
318 void USB_EndPoint13 (DWORD event) {
319 }
320
321
322 /*
323  *  USB Endpoint 14 Event Callback
324  *   Called automatically on USB Endpoint 14 Event
325  *    Parameter:       event
326  */
327
328 void USB_EndPoint14 (DWORD event) {
329 }
330
331
332 /*
333  *  USB Endpoint 15 Event Callback
334  *   Called automatically on USB Endpoint 15 Event
335  *    Parameter:       event
336  */
337
338 void USB_EndPoint15 (DWORD event) {
339 }
Note: See TracBrowser for help on using the browser.