| LPCOpen Platform v1.03 LPCOpen Platform for NXP LPC Microcontrollers

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Host.h
Go to the documentation of this file.
1 /*
2 * @brief Common USB Host definitions for all architectures
3 *
4 * @note
5 * Copyright(C) NXP Semiconductors, 2012
6 * Copyright(C) Dean Camera, 2011, 2012
7 * All rights reserved.
8 *
9 * @par
10 * Software that is described herein is for illustrative purposes only
11 * which provides customers with programming information regarding the
12 * LPC products. This software is supplied "AS IS" without any warranties of
13 * any kind, and NXP Semiconductors and its licensor disclaim any and
14 * all warranties, express or implied, including all implied warranties of
15 * merchantability, fitness for a particular purpose and non-infringement of
16 * intellectual property rights. NXP Semiconductors assumes no responsibility
17 * or liability for the use of the software, conveys no license or rights under any
18 * patent, copyright, mask work right, or any other intellectual property rights in
19 * or to any products. NXP Semiconductors reserves the right to make changes
20 * in the software without notification. NXP Semiconductors also makes no
21 * representation or warranty that such application will be suitable for the
22 * specified use without further testing or modification.
23 *
24 * @par
25 * Permission to use, copy, modify, and distribute this software and its
26 * documentation is hereby granted, under NXP Semiconductors' and its
27 * licensor's relevant copyrights in the software, without fee, provided that it
28 * is used in conjunction with NXP Semiconductors microcontrollers. This
29 * copyright, permission, and disclaimer notice must appear in all copies of
30 * this code.
31 */
32
43 #ifndef __USBHOST_H__
44 #define __USBHOST_H__
45
46 /* Includes: */
47 #include "../../../Common/Common.h"
48 #include "USBMode.h"
49
50 /* Enable C linkage for C++ Compilers: */
51 #if defined(__cplusplus)
52 extern "C" {
53 #endif
54
55 /* Preprocessor Checks: */
56 #if !defined(__INCLUDE_FROM_USB_DRIVER)
57 #error Do not include this file directly. Include lpcroot/libraries/LPCUSBlib/Drivers/USB/USB.h instead.
58 #endif
59
60 /* Public Interface - May be used in end-application: */
61 /* Enums: */
70 enum USB_Host_States_t
71 {
72 HOST_STATE_WaitForDevice = 0,
76 HOST_STATE_Unattached = 1,
79 HOST_STATE_Powered = 2,
83 HOST_STATE_Powered_WaitForDeviceSettle = 3,
86 HOST_STATE_Powered_WaitForConnect = 4,
90 HOST_STATE_Powered_DoReset = 5,
93 HOST_STATE_Powered_ConfigPipe = 6,
96 HOST_STATE_Default = 7,
100 HOST_STATE_Default_PostReset = 8,
104 HOST_STATE_Default_PostAddressSet = 9,
110 HOST_STATE_Addressed = 10,
113 HOST_STATE_Configured = 11,
116 };
117
118 #include "StdDescriptors.h"
119 #include "Pipe.h"
120 #include "USBInterrupt.h"
121
122 /* Macros: */
128 #define USB_HOST_DEVICEADDRESS 1
129
130 #if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__)
131
138 #define USB_HOST_TIMEOUT_MS 1000
139 #endif
140
141 #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__)
142
151 #define HOST_DEVICE_SETTLE_DELAY_MS 1000
152 #endif
153
158 enum USB_Host_ErrorCodes_t {
159 HOST_ERROR_VBusVoltageDip = 0,
165 };
166
171 enum USB_Host_EnumerationErrorCodes_t {
172 HOST_ENUMERROR_NoError = 0,
176 HOST_ENUMERROR_WaitStage = 1,
180 HOST_ENUMERROR_NoDeviceDetected = 2,
183 HOST_ENUMERROR_ControlError = 3,
186 HOST_ENUMERROR_PipeConfigError = 4,
189 };
190
195 uint8_t USB_Host_GetActiveHost(void);
196
199 extern uint8_t USB_Host_ControlPipeSize[MAX_USB_CORE];
200
201 /* Inline Functions: */
202 #if !defined(NO_SOF_EVENTS)
203
212 static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
213
214 static inline void USB_Host_EnableSOFEvents(void)
215 {}
216
224 static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
225
226 static inline void USB_Host_DisableSOFEvents(void)
227 {}
228
229 #endif
230
239 static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;
240
241 static inline void USB_Host_ResetBus(void)
242 {}
243
249 static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
250
251 static inline bool USB_Host_IsBusResetComplete(void)
252 {
253 return true;
254 }
255
262 static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;
263
264 static inline void USB_Host_ResumeBus(void)
265 {}
266
273 static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;
274
275 static inline void USB_Host_SuspendBus(void)
276 {}
277
285 static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
286
287 static inline bool USB_Host_IsBusSuspended(void)
288 {
289 return false;
290 }
291
298 static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
299
300 static inline bool USB_Host_IsDeviceFullSpeed(void)
301 {
302 return true; // implement later when needed
303 }
304
311 static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
312
313 static inline bool USB_Host_IsRemoteWakeupSent(void)
314 {
315 return false;
316 }
317
319 static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;
320
321 static inline void USB_Host_ClearRemoteWakeupSent(void)
322 {}
323
328 static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;
329
330 static inline void USB_Host_ResumeFromWakeupRequest(void)
331 {}
332
339 static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
340
341 static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)
342 {
343 return false;
344 }
345
346 /* Private Interface - For use in library only: */
347 #if !defined(__DOXYGEN__)
348 /* Macros: */
349 static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;
350
351 static inline void USB_Host_HostMode_On(void)
352 {}
353
354 static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;
355
356 static inline void USB_Host_HostMode_Off(void)
357 {}
358
359 static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;
360
361 static inline void USB_Host_VBUS_Auto_Enable(void)
362 {}
363
364 static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;
365
366 static inline void USB_Host_VBUS_Manual_Enable(void)
367 {}
368
369 static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;
370
371 static inline void USB_Host_VBUS_Auto_On(void)
372 {}
373
374 static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;
375
376 static inline void USB_Host_VBUS_Manual_On(void)
377 {}
378
379 static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;
380
381 static inline void USB_Host_VBUS_Auto_Off(void)
382 {}
383
384 static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;
385
386 static inline void USB_Host_VBUS_Manual_Off(void)
387 {}
388
389 static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
390
391 static inline void USB_Host_SetDeviceAddress(const uint8_t Address)
392 {}
393
394 /* Enums: */
397 enum USB_Host_WaitMSErrorCodes_t {
398 HOST_WAITERROR_Successful = 0,
399 HOST_WAITERROR_DeviceDisconnect = 1,
400 HOST_WAITERROR_PipeError = 2,
401 HOST_WAITERROR_SetupStalled = 3,
402 };
403
404 /* Function Prototypes: */
411 void USB_Host_ProcessNextHostState(uint8_t corenum);
412
418 uint8_t USB_Host_WaitMS(uint8_t MS);
419
425 uint16_t USB_Host_GetFrameNumber(void);
426
427 #if defined(__INCLUDE_FROM_HOST_C)
428 // static void USB_Host_ResetDevice(void);
429 #endif
430 #endif
431
432
433 /* Disable C linkage for C++ Compilers: */
434 #if defined(__cplusplus)
435 }
436 #endif
437
438 #endif
439