2 * @brief Host Controller Driver functions
\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 #define __INCLUDE_FROM_USB_DRIVER
\r
33 #include "../USBMode.h"
\r
35 #ifdef USB_CAN_BE_HOST
\r
37 #if !defined(__LPC_OHCI__) && !defined(__LPC_EHCI__)
\r
38 #error "Either __LPC_OHCI__ or __LPC_EHCI__ must be defined"
\r
41 #include "../USBTask.h"
\r
44 #ifdef LPCUSBlib_DEBUG
\r
45 void assert_status_ok_message(HCD_STATUS status,
\r
49 uint32_t const line)
\r
51 if (HCD_STATUS_OK != status) {
\r
52 hcd_printf("%s\r\n", func);
\r
53 hcd_printf("\t%s: %d\r\n", file, line);
\r
54 hcd_printf("\tEvaluated HCD_STATUS = %d\r\n", (uint32_t) status);
\r
56 hcd_printf("\t%s\r\n", mess);
\r
63 void HcdDelayUS(uint32_t delay)
\r
65 volatile uint32_t i;
\r
67 for (i = 0; i < (4 * delay); i++) /* This logic was tested. It gives app. 1 micro sec delay */
\r
71 void HcdDelayMS(uint32_t delay)
\r
73 volatile uint32_t i;
\r
75 for (i = 0; i < delay; i++)
\r
79 HCD_STATUS OpenPipe_VerifyParameters(uint8_t HostID,
\r
81 HCD_USB_SPEED DeviceSpeed,
\r
82 uint8_t EndpointNumber,
\r
83 HCD_TRANSFER_TYPE TransferType,
\r
84 HCD_TRANSFER_DIR TransferDir,
\r
85 uint16_t MaxPacketSize,
\r
89 if ((HostID >= MAX_USB_CORE) ||
\r
90 ( DeviceAddr > 127) ||
\r
91 ( DeviceSpeed > HIGH_SPEED) ||
\r
92 (EndpointNumber & 0x70) ||
\r
93 ( TransferType > INTERRUPT_TRANSFER) ||
\r
94 ( TransferDir > OUT_TRANSFER) ) {
\r
95 ASSERT_STATUS_OK(HCD_STATUS_PARAMETER_INVALID);
\r
98 /* XXX by USB specs Low speed device should not have packet size > 8, but many market devices does */
\r
99 if ((DeviceSpeed == LOW_SPEED) && ((TransferType == BULK_TRANSFER) || (TransferType == ISOCHRONOUS_TRANSFER)) ) {
\r
100 ASSERT_STATUS_OK(HCD_STATUS_PARAMETER_INVALID);
\r
103 switch (TransferType) {
\r
104 case CONTROL_TRANSFER:
\r
105 if (MaxPacketSize > 64) {
\r
106 ASSERT_STATUS_OK(HCD_STATUS_PARAMETER_INVALID);
\r
110 case BULK_TRANSFER:
\r
111 if (((DeviceSpeed == FULL_SPEED) && (MaxPacketSize > 64)) ||
\r
112 ((DeviceSpeed == HIGH_SPEED) && (MaxPacketSize > 512)) ) {
\r
113 ASSERT_STATUS_OK(HCD_STATUS_PARAMETER_INVALID);
\r
117 case INTERRUPT_TRANSFER:
\r
118 if ((Interval == 0) ||
\r
119 ((DeviceSpeed == FULL_SPEED) && (MaxPacketSize > 64)) ||
\r
120 ((DeviceSpeed == HIGH_SPEED) && ((MaxPacketSize > 1024) || (Interval > 16) || (Mult == 0))) ) {
\r
121 ASSERT_STATUS_OK(HCD_STATUS_PARAMETER_INVALID);
\r
125 case ISOCHRONOUS_TRANSFER:
\r
126 if ((Interval == 0) || (Interval > 16) ||
\r
127 ((DeviceSpeed == FULL_SPEED) && (MaxPacketSize > 1023)) ||
\r
128 ((DeviceSpeed == HIGH_SPEED) && ((MaxPacketSize > 1024) || (Mult == 0))) ) {
\r
129 ASSERT_STATUS_OK(HCD_STATUS_PARAMETER_INVALID);
\r
133 return HCD_STATUS_OK;
\r