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