2 * @brief USB Device definitions for the LPC17xx microcontrollers
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * All rights reserved.
\r
9 * Software that is described herein is for illustrative purposes only
\r
10 * which provides customers with programming information regarding the
\r
11 * LPC products. This software is supplied "AS IS" without any warranties of
\r
12 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
13 * all warranties, express or implied, including all implied warranties of
\r
14 * merchantability, fitness for a particular purpose and non-infringement of
\r
15 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
16 * or liability for the use of the software, conveys no license or rights under any
\r
17 * patent, copyright, mask work right, or any other intellectual property rights in
\r
18 * or to any products. NXP Semiconductors reserves the right to make changes
\r
19 * in the software without notification. NXP Semiconductors also makes no
\r
20 * representation or warranty that such application will be suitable for the
\r
21 * specified use without further testing or modification.
\r
24 * Permission to use, copy, modify, and distribute this software and its
\r
25 * documentation is hereby granted, under NXP Semiconductors' and its
\r
26 * licensor's relevant copyrights in the software, without fee, provided that it
\r
27 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
28 * copyright, permission, and disclaimer notice must appear in all copies of
\r
32 /** @ingroup Group_Device
\r
33 * @defgroup Group_Device_LPC17xx Device Management (LPC17xx)
\r
34 * @brief USB Device definitions for the LPC17xx microcontrollers.
\r
36 * Architecture specific USB Device definitions for the LPC microcontrollers.
\r
41 #ifndef __USBDEVICE_LPC17XX_H__
\r
42 #define __USBDEVICE_LPC17XX_H__
\r
44 #include "../../../../../Common/Common.h"
\r
45 #include "../../USBController.h"
\r
46 #include "../../StdDescriptors.h"
\r
47 #include "../../USBInterrupt.h"
\r
48 #include "../../HAL/HAL.h"
\r
49 #include "../../Endpoint.h"
\r
51 #if defined(__cplusplus)
\r
55 #if !defined(__INCLUDE_FROM_USB_DRIVER)
\r
56 #error Do not include this file directly. Include lpcroot/libraries/LPCUSBlib/Drivers/USB/USB.h instead.
\r
59 #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
\r
60 #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
\r
63 #if defined(__DOXYGEN__)
\r
64 /** Mask for the Options parameter of the @ref USB_Init() function. This indicates that the
\r
65 * USB interface should be initialized in low speed (1.5Mb/s) mode.
\r
67 #define USB_DEVICE_OPT_LOWSPEED (1 << 0)
\r
69 /** Mask for the Options parameter of the @ref USB_Init() function. This indicates that the
\r
70 * USB interface should be initialized in full speed (12Mb/s) mode.
\r
72 #define USB_DEVICE_OPT_FULLSPEED (0 << 0)
\r
74 #if (!defined(NO_INTERNAL_SERIAL) && \
\r
75 (defined(__DOXYGEN__)) )
\r
76 /** String descriptor index for the device's unique serial number string descriptor within the device.
\r
77 * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
\r
78 * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain
\r
79 * a unique serial number internally, and setting the device descriptors serial number string index to this value
\r
80 * will cause it to use the internal serial number.
\r
82 * On unsupported devices, this will evaluate to @ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
\r
83 * number for the device.
\r
85 #define USE_INTERNAL_SERIAL 0xDC
\r
86 /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller
\r
89 #define INTERNAL_SERIAL_LENGTH_BITS 80
\r
90 /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller
\r
93 #define INTERNAL_SERIAL_START_ADDRESS 0x0E
\r
95 #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
\r
97 #define INTERNAL_SERIAL_LENGTH_BITS 0
\r
98 #define INTERNAL_SERIAL_START_ADDRESS 0
\r
101 /** Sends a Remote Wakeup request to the host. This signals to the host that the device should
\r
102 * be taken out of suspended mode, and communications should resume.
\r
104 void USB_Device_SendRemoteWakeup(void);
\r
106 //Move to Endpoint_LPC17xx
\r
107 /*static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
\r
109 static inline uint16_t USB_Device_GetFrameNumber(void)
\r
113 SIE_WriteCommand(CMD_RD_FRAME);
\r
114 val = SIE_ReadCommandData(DAT_RD_FRAME);
\r
115 val = val | (SIE_ReadCommandData(DAT_RD_FRAME) << 8);
\r
120 #if !defined(NO_SOF_EVENTS)
\r
121 /** Enables the device mode Start Of Frame events. When enabled, this causes the
\r
122 * @ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,
\r
123 * at the start of each USB frame when enumerated in device mode.
\r
125 static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
\r
127 static inline void USB_Device_EnableSOFEvents(void)
\r
130 /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the
\r
131 * @ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.
\r
133 static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
\r
135 static inline void USB_Device_DisableSOFEvents(void)
\r
140 #if !defined(__DOXYGEN__)
\r
141 #if defined(USB_DEVICE_OPT_LOWSPEED)
\r
142 static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
\r
144 static inline void USB_Device_SetLowSpeed(void)
\r
147 static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;
\r
149 static inline void USB_Device_SetFullSpeed(void)
\r
154 //Move to Endpoint_LPC17XX
\r
155 /*static inline void USB_Device_SetDeviceAddress(uint8_t corenum, const uint8_t Address) ATTR_ALWAYS_INLINE;
\r
157 static inline void USB_Device_SetDeviceAddress(uint8_t corenum, const uint8_t Address)
\r
159 SIE_WriteCommandData(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | Address)); Don't wait for next
\r
160 SIE_WriteCommandData(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | Address)); Setup Status Phase
\r
163 static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
\r
165 static inline bool USB_Device_IsAddressSet(void)
\r
167 return true; /* TODO temporarily */
\r
170 #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)
\r
171 static inline void USB_Device_GetSerialString(uint16_t *const UnicodeString) ATTR_NON_NULL_PTR_ARG(1);
\r
173 static inline void USB_Device_GetSerialString(uint16_t *const UnicodeString)
\r
175 uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
\r
176 GlobalInterruptDisable();
\r
178 uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS;
\r
180 for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) {
\r
181 uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
\r
183 if (SerialCharNum & 0x01) {
\r
188 SerialByte &= 0x0F;
\r
190 UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
\r
191 (('A' - 10) + SerialByte) : ('0' + SerialByte));
\r
194 SetGlobalInterruptMask(CurrentGlobalInt);
\r
201 #if defined(__cplusplus)
\r