| 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
Device_LPC17xx.h
Go to the documentation of this file.
1 /*
2 * @brief USB Device definitions for the LPC17xx 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 __USBDEVICE_LPC17XX_H__
42 #define __USBDEVICE_LPC17XX_H__
43
44 #include "../../../../../Common/Common.h"
45 #include "../../USBController.h"
46 #include "../../StdDescriptors.h"
47 #include "../../USBInterrupt.h"
48 #include "../../HAL/HAL.h"
49 #include "../../Endpoint.h"
50
51 #if defined(__cplusplus)
52 extern "C" {
53 #endif
54
55 #if !defined(__INCLUDE_FROM_USB_DRIVER)
56 #error Do not include this file directly. Include lpcroot/libraries/LPCUSBlib/Drivers/USB/USB.h instead.
57 #endif
58
59 #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
60 #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
61 #endif
62
63 #if defined(__DOXYGEN__)
64
67 #define USB_DEVICE_OPT_LOWSPEED (1 << 0)
68 #endif
69
72 #define USB_DEVICE_OPT_FULLSPEED (0 << 0)
73
74 #if (!defined(NO_INTERNAL_SERIAL) && \
75 (defined(__DOXYGEN__)) )
76
85 #define USE_INTERNAL_SERIAL 0xDC
86
89 #define INTERNAL_SERIAL_LENGTH_BITS 80
90
93 #define INTERNAL_SERIAL_START_ADDRESS 0x0E
94 #else
95 #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
96
97 #define INTERNAL_SERIAL_LENGTH_BITS 0
98 #define INTERNAL_SERIAL_START_ADDRESS 0
99 #endif
100
104 void USB_Device_SendRemoteWakeup(void);
105
106 //Move to Endpoint_LPC17xx
107 /*static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
108
109 static inline uint16_t USB_Device_GetFrameNumber(void)
110 {
111 uint32_t val;
112
113 SIE_WriteCommand(CMD_RD_FRAME);
114 val = SIE_ReadCommandData(DAT_RD_FRAME);
115 val = val | (SIE_ReadCommandData(DAT_RD_FRAME) << 8);
116
117 return val;
118 }*/
119
120 #if !defined(NO_SOF_EVENTS)
121
125 static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;
126
127 static inline void USB_Device_EnableSOFEvents(void)
128 {}
129
133 static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;
134
135 static inline void USB_Device_DisableSOFEvents(void)
136 {}
137
138 #endif
139
140 #if !defined(__DOXYGEN__)
141 #if defined(USB_DEVICE_OPT_LOWSPEED)
142 static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
143
144 static inline void USB_Device_SetLowSpeed(void)
145 {}
146
147 static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;
148
149 static inline void USB_Device_SetFullSpeed(void)
150 {}
151
152 #endif
153
154 //Move to Endpoint_LPC17XX
155 /*static inline void USB_Device_SetDeviceAddress(uint8_t corenum, const uint8_t Address) ATTR_ALWAYS_INLINE;
156
157 static inline void USB_Device_SetDeviceAddress(uint8_t corenum, const uint8_t Address)
158 {
159 SIE_WriteCommandData(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | Address)); Don't wait for next
160 SIE_WriteCommandData(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | Address)); Setup Status Phase
161 }*/
162
163 static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
164
165 static inline bool USB_Device_IsAddressSet(void)
166 {
167 return true; /* TODO temporarily */
168 }
169
170 #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)
171 static inline void USB_Device_GetSerialString(uint16_t *const UnicodeString) ATTR_NON_NULL_PTR_ARG(1);
172
173 static inline void USB_Device_GetSerialString(uint16_t *const UnicodeString)
174 {
175 uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();
176 GlobalInterruptDisable();
177
178 uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS;
179
180 for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++) {
181 uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
182
183 if (SerialCharNum & 0x01) {
184 SerialByte >>= 4;
185 SigReadAddress++;
186 }
187
188 SerialByte &= 0x0F;
189
190 UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
191 (('A' - 10) + SerialByte) : ('0' + SerialByte));
192 }
193
194 SetGlobalInterruptMask(CurrentGlobalInt);
195 }
196
197 #endif
198
199 #endif
200
201 #if defined(__cplusplus)
202 }
203 #endif
204
205 #endif
206