1 /*----------------------------------------------------------------------------
\r
2 * U S B - K e r n e l
\r
3 *----------------------------------------------------------------------------
\r
5 * Purpose: USB Custom User Module
\r
7 *----------------------------------------------------------------------------
\r
8 * This software is supplied "AS IS" without any warranties, express,
\r
9 * implied or statutory, including but not limited to the implied
\r
10 * warranties of fitness for purpose, satisfactory quality and
\r
11 * noninfringement. Keil extends you a royalty-free right to reproduce
\r
12 * and distribute executable files created using this software for use
\r
13 * on NXP Semiconductors LPC family microcontroller devices only. Nothing
\r
14 * else gives you the right to use this software.
\r
16 * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
\r
17 *---------------------------------------------------------------------------*/
\r
18 #include "lpc_types.h"
\r
23 #include "usbcore.h"
\r
24 #include "usbuser.h"
\r
25 #include "cdcuser.h"
\r
29 * USB Power Event Callback
\r
30 * Called automatically on USB Power Event
\r
31 * Parameter: power: On(TRUE)/Off(FALSE)
\r
35 void USB_Power_Event (uint32_t power) {
\r
41 * USB Reset Event Callback
\r
42 * Called automatically on USB Reset Event
\r
46 void USB_Reset_Event (void) {
\r
53 * USB Suspend Event Callback
\r
54 * Called automatically on USB Suspend Event
\r
57 #if USB_SUSPEND_EVENT
\r
58 void USB_Suspend_Event (void) {
\r
64 * USB Resume Event Callback
\r
65 * Called automatically on USB Resume Event
\r
68 #if USB_RESUME_EVENT
\r
69 void USB_Resume_Event (void) {
\r
75 * USB Remote Wakeup Event Callback
\r
76 * Called automatically on USB Remote Wakeup Event
\r
79 #if USB_WAKEUP_EVENT
\r
80 void USB_WakeUp_Event (void) {
\r
86 * USB Start of Frame Event Callback
\r
87 * Called automatically on USB Start of Frame Event
\r
91 void USB_SOF_Event (void) {
\r
97 * USB Error Event Callback
\r
98 * Called automatically on USB Error Event
\r
99 * Parameter: error: Error Code
\r
102 #if USB_ERROR_EVENT
\r
103 void USB_Error_Event (uint32_t error) {
\r
109 * USB Set Configuration Event Callback
\r
110 * Called automatically on USB Set Configuration Request
\r
113 #if USB_CONFIGURE_EVENT
\r
114 void USB_Configure_Event (void) {
\r
116 if (USB_Configuration) { /* Check if USB is configured */
\r
117 /* add your code here */
\r
124 * USB Set Interface Event Callback
\r
125 * Called automatically on USB Set Interface Request
\r
128 #if USB_INTERFACE_EVENT
\r
129 void USB_Interface_Event (void) {
\r
135 * USB Set/Clear Feature Event Callback
\r
136 * Called automatically on USB Set/Clear Feature Request
\r
139 #if USB_FEATURE_EVENT
\r
140 void USB_Feature_Event (void) {
\r
145 #define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)
\r
147 /* USB Endpoint Events Callback Pointers */
\r
148 void (* const USB_P_EP[16]) (uint32_t event) = {
\r
169 * USB Endpoint 1 Event Callback
\r
170 * Called automatically on USB Endpoint 1 Event
\r
174 void USB_EndPoint1 (uint32_t event) {
\r
176 static uint16_t serialState;
\r
180 temp = CDC_GetSerialState();
\r
181 if (serialState != temp) {
\r
182 serialState = temp;
\r
183 CDC_NotificationIn(); /* send SERIAL_STATE notification */
\r
191 * USB Endpoint 2 Event Callback
\r
192 * Called automatically on USB Endpoint 2 Event
\r
196 void USB_EndPoint2 (uint32_t event) {
\r
200 CDC_BulkOut (); /* data received from Host */
\r
203 CDC_BulkIn (); /* data expected from Host */
\r
210 * USB Endpoint 3 Event Callback
\r
211 * Called automatically on USB Endpoint 3 Event
\r
215 void USB_EndPoint3 (uint32_t event) {
\r
220 * USB Endpoint 4 Event Callback
\r
221 * Called automatically on USB Endpoint 4 Event
\r
225 void USB_EndPoint4 (uint32_t event) {
\r
230 * USB Endpoint 5 Event Callback
\r
231 * Called automatically on USB Endpoint 5 Event
\r
235 void USB_EndPoint5 (uint32_t event) {
\r
240 * USB Endpoint 6 Event Callback
\r
241 * Called automatically on USB Endpoint 6 Event
\r
245 void USB_EndPoint6 (uint32_t event) {
\r
250 * USB Endpoint 7 Event Callback
\r
251 * Called automatically on USB Endpoint 7 Event
\r
255 void USB_EndPoint7 (uint32_t event) {
\r
260 * USB Endpoint 8 Event Callback
\r
261 * Called automatically on USB Endpoint 8 Event
\r
265 void USB_EndPoint8 (uint32_t event) {
\r
270 * USB Endpoint 9 Event Callback
\r
271 * Called automatically on USB Endpoint 9 Event
\r
275 void USB_EndPoint9 (uint32_t event) {
\r
280 * USB Endpoint 10 Event Callback
\r
281 * Called automatically on USB Endpoint 10 Event
\r
285 void USB_EndPoint10 (uint32_t event) {
\r
290 * USB Endpoint 11 Event Callback
\r
291 * Called automatically on USB Endpoint 11 Event
\r
295 void USB_EndPoint11 (uint32_t event) {
\r
300 * USB Endpoint 12 Event Callback
\r
301 * Called automatically on USB Endpoint 12 Event
\r
305 void USB_EndPoint12 (uint32_t event) {
\r
310 * USB Endpoint 13 Event Callback
\r
311 * Called automatically on USB Endpoint 13 Event
\r
315 void USB_EndPoint13 (uint32_t event) {
\r
320 * USB Endpoint 14 Event Callback
\r
321 * Called automatically on USB Endpoint 14 Event
\r
325 void USB_EndPoint14 (uint32_t event) {
\r
330 * USB Endpoint 15 Event Callback
\r
331 * Called automatically on USB Endpoint 15 Event
\r
335 void USB_EndPoint15 (uint32_t event) {
\r