LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Endpoint_LPC.h
Go to the documentation of this file.
1 /*
2  * @brief Endpoint declarations and functions 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 
32 
33 #ifndef __ENDPOINT_LPC_H__
34 #define __ENDPOINT_LPC_H__
35 
36 #if defined(__LPC18XX__) || defined(__LPC43XX__)
38 #elif defined(__LPC17XX__) || defined(__LPC177X_8X__)
40 #elif defined(__LPC11UXX__) || defined(__LPC13UXX__)
42 #endif
43 
44 #include "../../../../Common/Common.h"
45 #include "../USBTask.h"
46 #include "../USBInterrupt.h"
47 
48 /* Public Interface - May be used in end-application: */
49 /* Macros: */
57 #define ENDPOINT_BANK_SINGLE (0 << 1)
58 
64 #define ENDPOINT_BANK_DOUBLE (1 << 1)
65 
66 
67 #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
68 
71 #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 64
72 #endif
73 
81 #define ENDPOINT_MAX_SIZE(EPIndex) 512
82 
83 #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__)
84 
88 #define ENDPOINT_TOTAL_ENDPOINTS ENDPOINT_DETAILS_MAXEP
89 #else
90 #define ENDPOINT_TOTAL_ENDPOINTS 1
91 #endif
92 
93 /* Enums: */
114 };
115 
124 
125 static inline uint8_t Endpoint_GetCurrentEndpoint(void)
126 {
127  return endpointselected;
128 }
129 
142 static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
143 
144 static inline void Endpoint_SelectEndpoint(const uint8_t EndpointNumber)
145 {
147  // usb_data_buffer_index = 0;
148 }
149 
159 
160 static inline uint8_t Endpoint_Read_8(void)
161 {
162  uint8_t tem;
167  }
168  else {
172  }
173  return tem;
174 }
175 
182 
183 static inline uint8_t Endpoint_GetEndpointDirection(void)
184 {
186 }
187 
202 
203 static inline bool Endpoint_IsReadWriteAllowed(void)
204 {
206 }
207 
217 static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE;
218 
219 static inline void Endpoint_Write_8(const uint8_t Data)
220 {
224  }
225  else {
228  }
229 }
230 
238 static inline void Endpoint_Discard_8(void) ATTR_ALWAYS_INLINE;
239 
240 static inline void Endpoint_Discard_8(void)
241 {
242  volatile uint8_t dummy;
243  dummy = Endpoint_Read_8();
244 }
245 
256 
257 static inline uint16_t Endpoint_Read_16_LE(void)
258 {
259  uint16_t tem = 0;
260  uint8_t tem1, tem2;
261 
262  tem1 = Endpoint_Read_8();
263  tem2 = Endpoint_Read_8();
264  tem = (tem2 << 8) | tem1;
265  return tem;
266 }
267 
278 
279 static inline uint16_t Endpoint_Read_16_BE(void)
280 {
281  uint16_t tem = 0;
282  uint8_t tem1, tem2;
283 
284  tem1 = Endpoint_Read_8();
285  tem2 = Endpoint_Read_8();
286  tem = (tem1 << 8) | tem2;
287  return tem;
288 }
289 
300 static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE;
301 
302 static inline void Endpoint_Write_16_LE(const uint16_t Data)
303 {
304  Endpoint_Write_8(Data & 0xFF);
305  Endpoint_Write_8((Data >> 8) & 0xFF);
306 }
307 
318 static inline void Endpoint_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE;
319 
320 static inline void Endpoint_Write_16_BE(const uint16_t Data)
321 {
322  Endpoint_Write_8((Data >> 8) & 0xFF);
323  Endpoint_Write_8(Data & 0xFF);
324 }
325 
333 static inline void Endpoint_Discard_16(void) ATTR_ALWAYS_INLINE;
334 
335 static inline void Endpoint_Discard_16(void)
336 {
337  uint8_t tem;
338  tem = Endpoint_Read_8();
339  tem = Endpoint_Read_8();
340  tem = tem;
341 }
342 
353 
354 static inline uint32_t Endpoint_Read_32_LE(void)
355 {
356  uint32_t tem = 0;
357  uint8_t tem1, tem2, tem3, tem4;
358 
359  tem1 = Endpoint_Read_8();
360  tem2 = Endpoint_Read_8();
361  tem3 = Endpoint_Read_8();
362  tem4 = Endpoint_Read_8();
363  tem = (tem4 << 24) | (tem3 << 16) | (tem2 << 8) | tem1;
364  return tem;
365 }
366 
377 
378 static inline uint32_t Endpoint_Read_32_BE(void)
379 {
380  uint32_t tem = 0;
381  uint8_t tem1, tem2, tem3, tem4;
382 
383  tem1 = Endpoint_Read_8();
384  tem2 = Endpoint_Read_8();
385  tem3 = Endpoint_Read_8();
386  tem4 = Endpoint_Read_8();
387  tem = (tem1 << 24) | (tem2 << 16) | (tem3 << 8) | tem4;
388  return tem;
389 }
390 
401 static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE;
402 
403 static inline void Endpoint_Write_32_LE(const uint32_t Data)
404 {
405  Endpoint_Write_8(Data & 0xFF);
406  Endpoint_Write_8((Data >> 8) & 0xFF);
407  Endpoint_Write_8((Data >> 16) & 0xFF);
408  Endpoint_Write_8((Data >> 24) & 0xFF);
409 }
410 
421 static inline void Endpoint_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE;
422 
423 static inline void Endpoint_Write_32_BE(const uint32_t Data)
424 {
425  Endpoint_Write_8((Data >> 24) & 0xFF);
426  Endpoint_Write_8((Data >> 16) & 0xFF);
427  Endpoint_Write_8((Data >> 8) & 0xFF);
428  Endpoint_Write_8(Data & 0xFF);
429 }
430 
438 static inline void Endpoint_Discard_32(void) ATTR_ALWAYS_INLINE;
439 
440 static inline void Endpoint_Discard_32(void)
441 {
442  uint8_t tem;
443  tem = Endpoint_Read_8();
444  tem = Endpoint_Read_8();
445  tem = Endpoint_Read_8();
446  tem = Endpoint_Read_8();
447  tem = tem;
448 }
449 
450 void Endpoint_GetSetupPackage(uint8_t *pData);
451 
452 #endif