2 * @brief Common USB Device definitions for all architectures
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * Copyright(C) Dean Camera, 2011, 2012
\r
7 * All rights reserved.
\r
10 * Software that is described herein is for illustrative purposes only
\r
11 * which provides customers with programming information regarding the
\r
12 * LPC products. This software is supplied "AS IS" without any warranties of
\r
13 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
14 * all warranties, express or implied, including all implied warranties of
\r
15 * merchantability, fitness for a particular purpose and non-infringement of
\r
16 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
17 * or liability for the use of the software, conveys no license or rights under any
\r
18 * patent, copyright, mask work right, or any other intellectual property rights in
\r
19 * or to any products. NXP Semiconductors reserves the right to make changes
\r
20 * in the software without notification. NXP Semiconductors also makes no
\r
21 * representation or warranty that such application will be suitable for the
\r
22 * specified use without further testing or modification.
\r
25 * Permission to use, copy, modify, and distribute this software and its
\r
26 * documentation is hereby granted, under NXP Semiconductors' and its
\r
27 * licensor's relevant copyrights in the software, without fee, provided that it
\r
28 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
29 * copyright, permission, and disclaimer notice must appear in all copies of
\r
33 /** @ingroup Group_USB
\r
34 * @defgroup Group_Device Device Management
\r
35 * @brief USB Device management definitions for USB device mode.
\r
37 * USB Device mode related definitions common to all architectures. This module contains definitions which
\r
38 * are used when the USB controller is initialized in device mode.
\r
43 #ifndef __USBDEVICE_H__
\r
44 #define __USBDEVICE_H__
\r
47 #include "../../../Common/Common.h"
\r
48 #include "USBMode.h"
\r
49 #include "StdDescriptors.h"
\r
50 #include "USBInterrupt.h"
\r
51 #include "Endpoint.h"
\r
53 /* Enable C linkage for C++ Compilers: */
\r
54 #if defined(__cplusplus)
\r
58 /* Preprocessor Checks: */
\r
59 #if !defined(__INCLUDE_FROM_USB_DRIVER)
\r
60 #error Do not include this file directly. Include lpcroot/libraries/LPCUSBlib/Drivers/USB/USB.h instead.
\r
63 /* Public Interface - May be used in end-application: */
\r
65 /** Enum for the various states of the USB Device state machine. Only some states are
\r
66 * implemented in the nxpUSBlib library - other states are left to the user to implement.
\r
68 * For information on each possible USB device state, refer to the USB 2.0 specification.
\r
70 * \see @ref USB_DeviceState, which stores the current device state machine state.
\r
72 enum USB_Device_States_t
\r
74 DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates
\r
75 * that the device is not currently connected to a host.
\r
77 DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates
\r
78 * that the device is connected to a host, but enumeration has not
\r
81 DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates
\r
82 * that the device's USB bus has been reset by the host and it is
\r
83 * now waiting for the host to begin the enumeration process.
\r
85 DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates
\r
86 * that the device has been addressed by the USB Host, but is not
\r
89 DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates
\r
90 * that the device has been enumerated by the host and is ready
\r
91 * for USB communications to begin.
\r
93 DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates
\r
94 * that the USB bus has been suspended by the host, and the device
\r
95 * should power down to a minimal power level until the bus is
\r
100 /* Function Prototypes: */
\r
101 /** @brief Function to retrieve a given descriptor's size and memory location from the given descriptor type value,
\r
102 * index and language ID. This function MUST be overridden in the user application (added with full, identical
\r
103 * prototype and name so that the library can call it to retrieve descriptor data.
\r
104 * @param corenum : ID Number of USB Core to be processed.
\r
105 * @param wValue : The type of the descriptor to retrieve in the upper byte, and the index in the
\r
106 * lower byte (when more than one descriptor of the given type exists, such as the
\r
107 * case of string descriptors). The type may be one of the standard types defined
\r
108 * in the DescriptorTypes_t enum, or may be a class-specific descriptor type value.
\r
109 * @param wIndex : The language ID of the string to return if the \c wValue type indicates
\r
110 * @ref DTYPE_String, otherwise zero for standard descriptors, or as defined in a
\r
111 * class-specific standards.
\r
112 * @param DescriptorAddress : Pointer to the descriptor in memory. This should be set by the routine to
\r
113 * the address of the descriptor.
\r
114 * @param MemoryAddressSpace : A value from the @ref USB_DescriptorMemorySpaces_t enum to indicate the memory
\r
115 * space in which the descriptor is stored. This parameter does not exist when one
\r
116 * of the \c USE_*_DESCRIPTORS compile time options is used, or on architectures which
\r
117 * use a unified address space.
\r
119 * @note By default, the library expects all descriptors to be located in flash memory via the \c PROGMEM attribute.
\r
120 * If descriptors should be located in RAM or EEPROM instead (to speed up access in the case of RAM, or to
\r
121 * allow the descriptors to be changed dynamically at runtime) either the \c USE_RAM_DESCRIPTORS or the
\r
122 * \c USE_EEPROM_DESCRIPTORS tokens may be defined in the project makefile and passed to the compiler by the -D
\r
125 * @return Size in bytes of the descriptor if it exists, zero or @ref NO_DESCRIPTOR otherwise.
\r
127 uint16_t CALLBACK_USB_GetDescriptor(uint8_t corenum, const uint16_t wValue,
\r
128 const uint8_t wIndex,
\r
129 const void** const DescriptorAddress
\r
130 #if (defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)) && \
\r
131 !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))
\r
132 , uint8_t* MemoryAddressSpace
\r
134 ) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(4);
\r
136 #if defined(__LPC18XX__) || defined(__LPC43XX__)
\r
137 #include "DCD/LPC18XX/Device_LPC18xx.h"
\r
138 #elif defined(__LPC175X_6X__) || defined(__LPC177X_8X__) || defined(__LPC407X_8X__)
\r
139 #include "DCD/LPC17XX/Device_LPC17xx.h"
\r
140 #elif defined(__LPC11U1X__) || defined(__LPC11U2X_3X__) || defined(__LPC1347__)
\r
141 #include "DCD/LPC11UXX/Device_LPC11Uxx.h"
\r
144 /* Disable C linkage for C++ Compilers: */
\r
145 #if defined(__cplusplus)
\r