Spieler splodiert.
[hackover2013-badge-firmware.git] / core / usbcdc / 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 microcontroller devices only. Nothing else
14 * gives you the right to use this software.
15 *
16 * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
17 *---------------------------------------------------------------------------*/
18 #include "projectconfig.h"
19
20 #include "usb.h"
21 #include "usbcfg.h"
22 #include "usbhw.h"
23 #include "usbcore.h"
24 #include "usbuser.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[USB_LOGIC_EP_NUM]) (uint32_t event) = {
149 P_EP(0),
150 P_EP(1),
151 P_EP(2),
152 P_EP(3),
153 P_EP(4),
154 };
155
156
157 /*
158 * USB Endpoint 1 Event Callback
159 * Called automatically on USB Endpoint 1 Event
160 * Parameter: event
161 */
162
163 void USB_EndPoint1 (uint32_t event) {
164 uint16_t temp;
165 static uint16_t serialState;
166
167 switch (event) {
168 case USB_EVT_IN:
169 temp = CDC_GetSerialState();
170 if (serialState != temp) {
171 serialState = temp;
172 CDC_NotificationIn(); /* send SERIAL_STATE notification */
173 }
174 break;
175 }
176 }
177
178
179 /*
180 * USB Endpoint 2 Event Callback
181 * Called automatically on USB Endpoint 2 Event
182 * Parameter: event
183 */
184
185 void USB_EndPoint2 (uint32_t event) {
186 event = event;
187 }
188
189
190 /*
191 * USB Endpoint 3 Event Callback
192 * Called automatically on USB Endpoint 3 Event
193 * Parameter: event
194 */
195
196 void USB_EndPoint3 (uint32_t event) {
197 switch (event) {
198 case USB_EVT_OUT:
199 CDC_BulkOut (); /* data received from Host */
200 break;
201 case USB_EVT_IN:
202 CDC_BulkIn (); /* data expected from Host */
203 break;
204 }
205 }
206
207
This page took 0.06872 seconds and 5 git commands to generate.