1 /*----------------------------------------------------------------------------
3 *----------------------------------------------------------------------------
5 * Purpose: USB Custom User Module
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.
16 * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17 *---------------------------------------------------------------------------*/
18 #include "lpc_types.h"
29 * USB Power Event Callback
30 * Called automatically on USB Power Event
31 * Parameter: power: On(TRUE)/Off(FALSE)
35 void USB_Power_Event (uint32_t power) {
41 * USB Reset Event Callback
42 * Called automatically on USB Reset Event
46 void USB_Reset_Event (void) {
53 * USB Suspend Event Callback
54 * Called automatically on USB Suspend Event
58 void USB_Suspend_Event (void) {
64 * USB Resume Event Callback
65 * Called automatically on USB Resume Event
69 void USB_Resume_Event (void) {
75 * USB Remote Wakeup Event Callback
76 * Called automatically on USB Remote Wakeup Event
80 void USB_WakeUp_Event (void) {
86 * USB Start of Frame Event Callback
87 * Called automatically on USB Start of Frame Event
91 void USB_SOF_Event (void) {
97 * USB Error Event Callback
98 * Called automatically on USB Error Event
99 * Parameter: error: Error Code
103 void USB_Error_Event (uint32_t error) {
109 * USB Set Configuration Event Callback
110 * Called automatically on USB Set Configuration Request
113 #if USB_CONFIGURE_EVENT
114 void USB_Configure_Event (void) {
116 if (USB_Configuration) { /* Check if USB is configured */
117 /* add your code here */
124 * USB Set Interface Event Callback
125 * Called automatically on USB Set Interface Request
128 #if USB_INTERFACE_EVENT
129 void USB_Interface_Event (void) {
135 * USB Set/Clear Feature Event Callback
136 * Called automatically on USB Set/Clear Feature Request
139 #if USB_FEATURE_EVENT
140 void USB_Feature_Event (void) {
145 #define P_EP(n) ((USB_EP_EVENT & (1 << (n))) ? USB_EndPoint##n : NULL)
147 /* USB Endpoint Events Callback Pointers */
148 void (* const USB_P_EP[16]) (uint32_t event) = {
169 * USB Endpoint 1 Event Callback
170 * Called automatically on USB Endpoint 1 Event
174 void USB_EndPoint1 (uint32_t event) {
176 static uint16_t serialState;
180 temp = CDC_GetSerialState();
181 if (serialState != temp) {
183 CDC_NotificationIn(); /* send SERIAL_STATE notification */
191 * USB Endpoint 2 Event Callback
192 * Called automatically on USB Endpoint 2 Event
196 void USB_EndPoint2 (uint32_t event) {
200 CDC_BulkOut (); /* data received from Host */
203 CDC_BulkIn (); /* data expected from Host */
210 * USB Endpoint 3 Event Callback
211 * Called automatically on USB Endpoint 3 Event
215 void USB_EndPoint3 (uint32_t event) {
220 * USB Endpoint 4 Event Callback
221 * Called automatically on USB Endpoint 4 Event
225 void USB_EndPoint4 (uint32_t event) {
230 * USB Endpoint 5 Event Callback
231 * Called automatically on USB Endpoint 5 Event
235 void USB_EndPoint5 (uint32_t event) {
240 * USB Endpoint 6 Event Callback
241 * Called automatically on USB Endpoint 6 Event
245 void USB_EndPoint6 (uint32_t event) {
250 * USB Endpoint 7 Event Callback
251 * Called automatically on USB Endpoint 7 Event
255 void USB_EndPoint7 (uint32_t event) {
260 * USB Endpoint 8 Event Callback
261 * Called automatically on USB Endpoint 8 Event
265 void USB_EndPoint8 (uint32_t event) {
270 * USB Endpoint 9 Event Callback
271 * Called automatically on USB Endpoint 9 Event
275 void USB_EndPoint9 (uint32_t event) {
280 * USB Endpoint 10 Event Callback
281 * Called automatically on USB Endpoint 10 Event
285 void USB_EndPoint10 (uint32_t event) {
290 * USB Endpoint 11 Event Callback
291 * Called automatically on USB Endpoint 11 Event
295 void USB_EndPoint11 (uint32_t event) {
300 * USB Endpoint 12 Event Callback
301 * Called automatically on USB Endpoint 12 Event
305 void USB_EndPoint12 (uint32_t event) {
310 * USB Endpoint 13 Event Callback
311 * Called automatically on USB Endpoint 13 Event
315 void USB_EndPoint13 (uint32_t event) {
320 * USB Endpoint 14 Event Callback
321 * Called automatically on USB Endpoint 14 Event
325 void USB_EndPoint14 (uint32_t event) {
330 * USB Endpoint 15 Event Callback
331 * Called automatically on USB Endpoint 15 Event
335 void USB_EndPoint15 (uint32_t event) {