]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC/ThirdParty/USB_CDC/usbuser.c
b0226ac2a34df6ce7d27eacaea34245c158790dd
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_UDP_and_CLI_LPC1830_GCC / ThirdParty / USB_CDC / usbuser.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
19 #include "lpc18xx.H"
20 #include "lpc_types.h"
21
22 #include "usb.h"
23 #include "usbcfg.h"
24 #include "usbhw.h"
25 #include "usbcore.h"
26 #include "usbuser.h"
27 #include "cdcuser.h"
28
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 (uint32_t  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 (uint32_t 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[USB_EP_NUM]) (uint32_t event) = {
152   P_EP(0),
153   P_EP(1),
154   P_EP(2),
155   P_EP(3),
156 };
157
158
159 /*
160  *  USB Endpoint 1 Event Callback
161  *   Called automatically on USB Endpoint 1 Event
162  *    Parameter:       event
163  */
164
165 void USB_EndPoint1 (uint32_t event) {
166         ( void ) event;
167 }
168
169
170 /*
171  *  USB Endpoint 2 Event Callback
172  *   Called automatically on USB Endpoint 2 Event
173  *    Parameter:       event
174  */
175
176 void USB_EndPoint2 (uint32_t event) {
177   switch (event) {
178   case USB_EVT_OUT_NAK:
179       CDC_BulkOutNak();
180       break;
181     case USB_EVT_OUT:
182       CDC_BulkOut ();                /* data received from Host */
183       break;
184     case USB_EVT_IN:
185       CDC_BulkIn ();                 /* data expected from Host */
186       break;
187   }
188 }
189
190
191 /*
192  *  USB Endpoint 3 Event Callback
193  *   Called automatically on USB Endpoint 3 Event
194  *    Parameter:       event
195  */
196
197 void USB_EndPoint3 (uint32_t event) {
198         ( void ) event;
199 }
200
201
202 /*
203  *  USB Endpoint 4 Event Callback
204  *   Called automatically on USB Endpoint 4 Event
205  *    Parameter:       event
206  */
207
208 void USB_EndPoint4 (uint32_t event) {
209         ( void ) event;
210 }
211
212
213 /*
214  *  USB Endpoint 5 Event Callback
215  *   Called automatically on USB Endpoint 5 Event
216  *    Parameter:       event
217  */
218
219 void USB_EndPoint5 (uint32_t event) {
220   ( void ) event;
221 }