LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
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__)
37
#include "
DCD/LPC18XX/Endpoint_LPC18xx.h
"
38
#elif defined(__LPC17XX__) || defined(__LPC177X_8X__)
39
#include "
DCD/LPC17XX/Endpoint_LPC17xx.h
"
40
#elif defined(__LPC11UXX__) || defined(__LPC13UXX__)
41
#include "
DCD/LPC11UXX/Endpoint_LPC11Uxx.h
"
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: */
98
enum
Endpoint_WaitUntilReady_ErrorCodes_t
{
99
ENDPOINT_READYWAIT_NoError
= 0,
100
ENDPOINT_READYWAIT_EndpointStalled
= 1,
103
ENDPOINT_READYWAIT_DeviceDisconnected
= 2,
106
ENDPOINT_READYWAIT_BusSuspended
= 3,
110
ENDPOINT_READYWAIT_Timeout
= 4,
114
};
115
122
PRAGMA_ALWAYS_INLINE
123
static
inline
uint8_t
Endpoint_GetCurrentEndpoint
(
void
)
ATTR_WARN_UNUSED_RESULT
ATTR_ALWAYS_INLINE
;
124
125
static inline uint8_t
Endpoint_GetCurrentEndpoint
(
void
)
126
{
127
return
endpointselected
;
128
}
129
141
PRAGMA_ALWAYS_INLINE
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
{
146
endpointselected
=
EndpointNumber
;
147
// usb_data_buffer_index = 0;
148
}
149
157
PRAGMA_ALWAYS_INLINE
158
static
inline
uint8_t
Endpoint_Read_8
(
void
)
ATTR_WARN_UNUSED_RESULT
ATTR_ALWAYS_INLINE
;
159
160
static inline uint8_t
Endpoint_Read_8
(
void
)
161
{
162
uint8_t tem;
163
if
(
endpointselected
==
ENDPOINT_CONTROLEP
) {
164
tem =
usb_data_buffer
[
usb_data_buffer_index
];
165
usb_data_buffer_index
++;
166
usb_data_buffer_size
--;
167
}
168
else
{
169
tem =
usb_data_buffer_OUT
[
usb_data_buffer_OUT_index
];
170
usb_data_buffer_OUT_index
++;
171
usb_data_buffer_OUT_size
--;
172
}
173
return
tem;
174
}
175
180
PRAGMA_ALWAYS_INLINE
181
static
inline
uint8_t
Endpoint_GetEndpointDirection
(
void
)
ATTR_WARN_UNUSED_RESULT
ATTR_ALWAYS_INLINE
;
182
183
static inline uint8_t
Endpoint_GetEndpointDirection
(
void
)
184
{
185
return
(
endpointhandle
[
endpointselected
] % 2) ?
ENDPOINT_DIR_IN
:
ENDPOINT_DIR_OUT
;
186
}
187
200
PRAGMA_ALWAYS_INLINE
201
static
inline
bool
Endpoint_IsReadWriteAllowed
(
void
)
ATTR_WARN_UNUSED_RESULT
ATTR_ALWAYS_INLINE
;
202
203
static inline
bool
Endpoint_IsReadWriteAllowed
(
void
)
204
{
205
return
(
Endpoint_GetEndpointDirection
() ==
ENDPOINT_DIR_OUT
) ?
Endpoint_IsOUTReceived
() :
Endpoint_IsINReady
();
206
}
207
216
PRAGMA_ALWAYS_INLINE
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
{
221
if
(
endpointselected
==
ENDPOINT_CONTROLEP
) {
222
usb_data_buffer
[
usb_data_buffer_index
] = Data;
223
usb_data_buffer_index
++;
224
}
225
else
{
226
usb_data_buffer_IN
[
usb_data_buffer_IN_index
] = Data;
227
usb_data_buffer_IN_index
++;
228
}
229
}
230
237
PRAGMA_ALWAYS_INLINE
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
254
PRAGMA_ALWAYS_INLINE
255
static
inline
uint16_t
Endpoint_Read_16_LE
(
void
)
ATTR_WARN_UNUSED_RESULT
ATTR_ALWAYS_INLINE
;
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
276
PRAGMA_ALWAYS_INLINE
277
static
inline
uint16_t
Endpoint_Read_16_BE
(
void
)
ATTR_WARN_UNUSED_RESULT
ATTR_ALWAYS_INLINE
;
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
299
PRAGMA_ALWAYS_INLINE
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
317
PRAGMA_ALWAYS_INLINE
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
332
PRAGMA_ALWAYS_INLINE
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
351
PRAGMA_ALWAYS_INLINE
352
static
inline
uint32_t
Endpoint_Read_32_LE
(
void
)
ATTR_WARN_UNUSED_RESULT
ATTR_ALWAYS_INLINE
;
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
375
PRAGMA_ALWAYS_INLINE
376
static
inline
uint32_t
Endpoint_Read_32_BE
(
void
)
ATTR_WARN_UNUSED_RESULT
ATTR_ALWAYS_INLINE
;
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
400
PRAGMA_ALWAYS_INLINE
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
420
PRAGMA_ALWAYS_INLINE
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
437
PRAGMA_ALWAYS_INLINE
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
software
LPCUSBLib
Drivers
USB
Core
LPC
Endpoint_LPC.h
Generated on Fri Nov 16 2012 13:36:47 for LPCOpen Platform by
1.8.2