LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
USBController_LPC.h
Go to the documentation of this file.
1 /*
2  * @brief USB Controller definitions for the LPC microcontrollers
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
41 #ifndef __USBCONTROLLER_LPC_H__
42 #define __USBCONTROLLER_LPC_H__
43 
44 /* Includes: */
45  #include "../../../../Common/Common.h"
46  #include "../USBMode.h"
47  #include "../Events.h"
48  #include "../USBTask.h"
49  #include "../USBInterrupt.h"
50 
51  #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
52  #include "../Host.h"
53  #include "../OTG.h"
54  #include "../Pipe.h"
55  #include "../HostStandardReq.h"
56  #include "../PipeStream.h"
57  #endif
58 
59  #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
60  #include "../Device.h"
61  #include "../Endpoint.h"
62  #include "../DeviceStandardReq.h"
63  #include "../EndpointStream.h"
64  #endif
65 
66 /* Enable C linkage for C++ Compilers: */
67  #if defined(__cplusplus)
68 extern "C" {
69  #endif
70 
71 /* Preprocessor Checks and Defines: */
72  #if !defined(__INCLUDE_FROM_USB_DRIVER)
73  #error Do not include this file directly. Include lpcroot/libraries/LPCUSBlib/Drivers/USB/USB.h instead.
74  #endif
75 
76 /* Public Interface - May be used in end-application: */
77 /* Macros: */
85  #define USB_OPT_REG_DISABLED (1 << 1)
86 
93  #define USB_OPT_REG_ENABLED (0 << 1)
94 
99  #define USB_OPT_MANUAL_PLL (1 << 2)
100 
105  #define USB_OPT_AUTO_PLL (0 << 2)
106 
107 
108  #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)
109 
116  #define USB_STREAM_TIMEOUT_MS 100
117  #endif
118 
119 /* Inline Functions: */
120  #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || \
121  defined(__DOXYGEN__)
122 
131 
132 static inline bool USB_VBUS_GetStatus(void)
133 {
134  return (USBSTA & (1 << VBUS)) ? true : false;
135 }
136 
137  #endif
138 
144 static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;
145 
146 static inline void USB_Detach(void)
147 {}
148 
158 static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;
159 
160 static inline void USB_Attach(void)
161 {}
162 
163 /* Function Prototypes: */
180 void USB_Init(void);
181 
186 void USB_Disable(void);
187 
191 void USB_ResetInterface(uint8_t corenum);
192 
193 /* Global Variables: */
194  #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)
195 
208 extern volatile uint8_t USB_CurrentMode;
209  #elif defined(USB_HOST_ONLY)
210  #define USB_CurrentMode USB_MODE_Host
211  #elif defined(USB_DEVICE_ONLY)
212  #define USB_CurrentMode USB_MODE_Device
213  #endif
214 
215  #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)
216 
222 extern volatile uint8_t USB_Options;
223  #elif defined(USE_STATIC_OPTIONS)
224  #define USB_Options USE_STATIC_OPTIONS
225  #endif
226 
227 /* Enums: */
238 };
239 
240 /* Private Interface - For use in library only: */
241  #if !defined(__DOXYGEN__)
242 /* Function Prototypes: */
243  #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)
244  #if defined(USB_CAN_BE_DEVICE)
245 static void USB_Init_Device(uint8_t corenum);
246 
247  #endif
248 
249  #if defined(USB_CAN_BE_HOST)
250 static void USB_Init_Host(uint8_t corenum);
251 
252  #endif
253  #endif
254 
255 /* Inline Functions: */
257 static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE;
258 
259 static inline void USB_PLL_On(void)
260 {}
261 
263 static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE;
264 
265 static inline void USB_PLL_Off(void)
266 {}
267 
269 static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
270 
271 static inline bool USB_PLL_IsReady(void)
272 {
273  return true; // implement later if needed
274 }
275 
277 static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE;
278 
279 static inline void USB_REG_On(void)
280 {}
281 
283 static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE;
284 
285 static inline void USB_REG_Off(void)
286 {}
287 
289 static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;
290 
291 static inline void USB_OTGPAD_On(void)
292 {}
293 
295 static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;
296 
297 static inline void USB_OTGPAD_Off(void)
298 {}
299 
301 static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;
302 
303 static inline void USB_CLK_Freeze(void)
304 {}
305 
307 static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;
308 
309 static inline void USB_CLK_Unfreeze(void)
310 {}
311 
313 static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;
314 
315 static inline void USB_Controller_Enable(void)
316 {}
317 
319 static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;
320 
321 static inline void USB_Controller_Disable(void)
322 {}
323 
325 static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;
326 
327 static inline void USB_Controller_Reset(void)
328 {}
329 
330  #if defined(USB_CAN_BE_BOTH)
332 static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
333 
334 static inline uint8_t USB_GetUSBModeFromUID(void)
335 {
336  // if (USBSTA & (1 << ID))
337  // return USB_MODE_Device;
338  // else
339  // return USB_MODE_Host;
340  return 0;
341 }
342 
343  #endif
344 
345  #endif
346 
347 /* Disable C linkage for C++ Compilers: */
348  #if defined(__cplusplus)
349 }
350  #endif
351 
352 #endif
353