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
HCD.h
Go to the documentation of this file.
1
/*
2
* @brief Host Controller Driver functions
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
36
#ifndef __LPC_HCD_H__
37
#define __LPC_HCD_H__
38
39
#include "../../../../Common/Common.h"
40
#include "../StdRequestType.h"
// FIXME should be USBTask.h instead
41
#include "../HAL/HAL.h"
42
#include <string.h>
43
#include <stdio.h>
44
47
#define HCD_ENDPOINT_MAXPACKET_XFER_LEN 0xFFEEFFEE
48
51
#define YES 1
52
55
#define NO 0
56
59
#define HCD_MAX_ENDPOINT 8
60
63
#define HC_RESET_TIMEOUT 10
64
67
#define TRANSFER_TIMEOUT_MS 1000
68
71
#define PORT_RESET_PERIOD_MS 100
72
73
/* Control / Bulk transfer is always enabled */
77
#define INTERRUPT_LIST_ENABLE YES
78
82
#define ISO_LIST_ENABLE YES
83
86
typedef
enum
{
87
CONTROL_TRANSFER
,
88
ISOCHRONOUS_TRANSFER
,
89
BULK_TRANSFER
,
90
INTERRUPT_TRANSFER
91
}
HCD_TRANSFER_TYPE
;
92
95
typedef
enum
{
96
SETUP_TRANSFER
,
97
IN_TRANSFER
,
98
OUT_TRANSFER
99
}
HCD_TRANSFER_DIR
;
100
103
typedef
enum
{
104
FULL_SPEED
= 0,
105
LOW_SPEED
,
106
HIGH_SPEED
107
}
HCD_USB_SPEED
;
108
111
typedef
enum
{
112
HCD_STATUS_OK
= 0,
114
HCD_STATUS_TRANSFER_CRC
,
115
HCD_STATUS_TRANSFER_BitStuffing
,
116
HCD_STATUS_TRANSFER_DataToggleMismatch
,
117
HCD_STATUS_TRANSFER_Stall
,
118
HCD_STATUS_TRANSFER_DeviceNotResponding
,
120
HCD_STATUS_TRANSFER_PIDCheckFailure
,
121
HCD_STATUS_TRANSFER_UnexpectedPID
,
122
HCD_STATUS_TRANSFER_DataOverrun
,
123
HCD_STATUS_TRANSFER_DataUnderrun
,
124
HCD_STATUS_TRANSFER_CC_Reserved1
,
126
HCD_STATUS_TRANSFER_CC_Reserved2
,
127
HCD_STATUS_TRANSFER_BufferOverrun
,
128
HCD_STATUS_TRANSFER_BufferUnderrun
,
129
HCD_STATUS_TRANSFER_NotAccessed
,
130
HCD_STATUS_TRANSFER_Reserved
,
132
HCD_STATUS_STRUCTURE_IS_FREE
,
133
HCD_STATUS_TO_BE_REMOVED
,
134
HCD_STATUS_TRANSFER_QUEUED
,
135
HCD_STATUS_TRANSFER_COMPLETED
,
136
HCD_STATUS_TRANSFER_ERROR
,
138
HCD_STATUS_NOT_ENOUGH_MEMORY
,
139
HCD_STATUS_NOT_ENOUGH_ENDPOINT
,
140
HCD_STATUS_NOT_ENOUGH_GTD
,
141
HCD_STATUS_NOT_ENOUGH_ITD
,
142
HCD_STATUS_NOT_ENOUGH_QTD
,
144
HCD_STATUS_NOT_ENOUGH_HS_ITD
,
145
HCD_STATUS_NOT_ENOUGH_SITD
,
146
HCD_STATUS_DATA_OVERFLOW
,
147
HCD_STATUS_DEVICE_DISCONNECTED
,
148
HCD_STATUS_TRANSFER_TYPE_NOT_SUPPORTED
,
150
HCD_STATUS_PIPEHANDLE_INVALID
,
151
HCD_STATUS_PARAMETER_INVALID
152
}
HCD_STATUS
;
153
160
HCD_STATUS
HcdInitDriver
(uint8_t HostID);
161
168
HCD_STATUS
HcdDeInitDriver
(uint8_t HostID);
169
177
void
HcdIrqHandler
(uint8_t HostID);
178
185
HCD_STATUS
HcdRhPortReset
(uint8_t HostID);
186
193
HCD_STATUS
HcdRhPortEnable
(uint8_t HostID);
194
201
HCD_STATUS
HcdRhPortDisable
(uint8_t HostID);
202
210
HCD_STATUS
HcdGetDeviceSpeed
(uint8_t HostID,
HCD_USB_SPEED
*DeviceSpeed);
211
218
uint32_t
HcdGetFrameNumber
(uint8_t HostID);
219
237
HCD_STATUS
HcdOpenPipe
(uint8_t HostID,
238
uint8_t DeviceAddr,
239
HCD_USB_SPEED
DeviceSpeed,
240
uint8_t EndpointNo,
241
HCD_TRANSFER_TYPE
TransferType,
242
HCD_TRANSFER_DIR
TransferDir,
243
uint16_t MaxPacketSize,
244
uint8_t
Interval
,
245
uint8_t
Mult
,
246
uint8_t HSHubDevAddr,
247
uint8_t HSHubPortNum,
248
uint32_t
*
const
PipeHandle);
249
256
HCD_STATUS
HcdClosePipe
(
uint32_t
PipeHandle);
257
264
HCD_STATUS
HcdCancelTransfer
(
uint32_t
PipeHandle);
265
272
HCD_STATUS
HcdClearEndpointHalt
(
uint32_t
PipeHandle);
273
282
HCD_STATUS
HcdControlTransfer
(
uint32_t
PipeHandle,
283
const
USB_Request_Header_t
*
const
pDeviceRequest,
284
uint8_t *
const
buffer
);
285
295
HCD_STATUS
HcdDataTransfer
(
uint32_t
PipeHandle,
296
uint8_t *
const
buffer
,
297
uint32_t
const
length,
298
uint16_t *
const
pActualTransferred);
299
306
HCD_STATUS
HcdGetPipeStatus
(
uint32_t
PipeHandle);
307
315
void
HcdSetStreamPacketSize
(
uint32_t
PipeHandle, uint16_t packetsize);
316
317
#ifdef LPCUSBlib_DEBUG
318
#define hcd_printf printf
319
void
assert_status_ok_message
(
HCD_STATUS
status
,
320
char
const
*mess,
321
char
const
*func,
322
char
const
*file,
323
uint32_t
const
line);
324
325
#else
326
#define hcd_printf(...)
327
#define assert_status_ok_message(...)
328
#endif
329
330
#define ASSERT_STATUS_OK_MESSAGE(sts, message) \
331
do { \
332
HCD_STATUS status = (sts); \
333
assert_status_ok_message(status, message, __func__, __FILE__, __LINE__); \
334
if (HCD_STATUS_OK != status) { \
335
return status; \
336
} \
337
} while (0)
338
339
#define ASSERT_STATUS_OK(sts) ASSERT_STATUS_OK_MESSAGE(sts, NULL)
340
341
#if defined(__LPC_OHCI_C__) || defined(__LPC_EHCI_C__)
342
343
void
HcdDelayUS
(
uint32_t
delay
);
344
345
void
HcdDelayMS
(
uint32_t
delay
);
346
361
HCD_STATUS
OpenPipe_VerifyParameters
(uint8_t HostID,
362
uint8_t DeviceAddr,
363
HCD_USB_SPEED
DeviceSpeed,
364
uint8_t
EndpointNumber
,
365
HCD_TRANSFER_TYPE
TransferType,
366
HCD_TRANSFER_DIR
TransferDir,
367
uint16_t MaxPacketSize,
368
uint8_t
Interval
,
369
uint8_t
Mult
);
370
377
static
INLINE
uint32_t
Align32(
uint32_t
Value)
378
{
379
return
Value & 0xFFFFFFE0UL;
/* Bit 31 .. 5 */
380
}
381
389
static
INLINE
uint32_t
Aligned(
uint32_t
alignment,
uint32_t
Value)
390
{
391
return
Value & (~(alignment - 1));
392
}
393
400
static
INLINE
uint32_t
Align4k(
uint32_t
Value)
401
{
402
return
Value & 0xFFFFF000;
/* Bit 31 .. 5 */
403
}
404
411
static
INLINE
uint32_t
Offset4k(
uint32_t
Value)
412
{
413
return
Value & 0xFFF;
414
}
415
416
#endif
417
418
#endif
419
software
LPCUSBLib
Drivers
USB
Core
HCD
HCD.h
Generated on Fri May 10 2013 10:42:23 for LPCOpen Platform by
1.8.2