2 * @brief Endpoint data stream transmission and reception management for the LPC microcontrollers
\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 #if defined(USB_CAN_BE_DEVICE)
\r
37 #include "EndpointStream.h"
\r
39 #if !defined(CONTROL_ONLY_DEVICE)
\r
40 uint8_t Endpoint_Discard_Stream(uint8_t corenum,
\r
42 uint16_t *const BytesProcessed)
\r
45 for (i = 0; i < Length; i++)
\r
46 Endpoint_Discard_8(corenum);
\r
47 return ENDPOINT_RWSTREAM_NoError;
\r
50 uint8_t Endpoint_Null_Stream(uint8_t corenum,
\r
52 uint16_t *const BytesProcessed)
\r
56 while ( !Endpoint_IsINReady(corenum) ) { /*-- Wait until ready --*/
\r
59 for (i = 0; i < Length; i++)
\r
60 Endpoint_Write_8(corenum, 0);
\r
61 return ENDPOINT_RWSTREAM_NoError;
\r
64 uint8_t Endpoint_Write_Stream_LE(uint8_t corenum,
\r
65 const void *const Buffer,
\r
67 uint16_t *const BytesProcessed)
\r
71 while ( !Endpoint_IsINReady(corenum) ) { /*-- Wait until ready --*/
\r
74 for (i = 0; i < Length; i++)
\r
75 Endpoint_Write_8(corenum, ((uint8_t *) Buffer)[i]);
\r
77 return ENDPOINT_RWSTREAM_NoError;
\r
80 uint8_t Endpoint_Write_Stream_BE(uint8_t corenum,
\r
81 const void *const Buffer,
\r
83 uint16_t *const BytesProcessed)
\r
87 for (i = 0; i < Length; i++)
\r
88 Endpoint_Write_8(corenum, ((uint8_t *) Buffer)[Length - 1 - i]);
\r
89 return ENDPOINT_RWSTREAM_NoError;
\r
92 uint8_t Endpoint_Read_Stream_LE(uint8_t corenum,
\r
95 uint16_t *const BytesProcessed)
\r
98 if (endpointselected[corenum] == ENDPOINT_CONTROLEP) {
\r
99 if (usb_data_buffer_size[corenum] == 0) {
\r
100 return ENDPOINT_RWSTREAM_IncompleteTransfer;
\r
103 else if (usb_data_buffer_OUT_size[corenum] == 0) {
\r
104 return ENDPOINT_RWSTREAM_IncompleteTransfer;
\r
107 for (i = 0; i < Length; i++) {
\r
108 #if defined(__LPC175X_6X__) || defined(__LPC177X_8X__) || defined(__LPC407X_8X__)
\r
109 if (endpointselected[corenum] != ENDPOINT_CONTROLEP) {
\r
110 while (usb_data_buffer_OUT_size[corenum] == 0) ; /* Current Fix for LPC17xx, havent checked for others */
\r
113 ((uint8_t *) Buffer)[i] = Endpoint_Read_8(corenum);
\r
115 return ENDPOINT_RWSTREAM_NoError;
\r
118 uint8_t Endpoint_Read_Stream_BE(void *const Buffer,
\r
120 uint16_t *const BytesProcessed)
\r
122 return ENDPOINT_RWSTREAM_NoError;
\r
127 uint8_t Endpoint_Write_Control_Stream_LE(uint8_t corenum, const void *const Buffer,
\r
130 Endpoint_Write_Stream_LE(corenum, (uint8_t *) Buffer, MIN(Length, USB_ControlRequest.wLength), NULL);
\r
131 Endpoint_ClearIN(corenum);
\r
132 // while (!(Endpoint_IsOUTReceived()))
\r
135 return ENDPOINT_RWCSTREAM_NoError;
\r
138 uint8_t Endpoint_Write_Control_Stream_BE(const void *const Buffer,
\r
141 return ENDPOINT_RWCSTREAM_NoError;
\r
144 uint8_t Endpoint_Read_Control_Stream_LE(uint8_t corenum, void *const Buffer,
\r
147 while (!Endpoint_IsOUTReceived(corenum)) ; // FIXME: this safe checking is fine for LPC18xx
\r
148 Endpoint_Read_Stream_LE(corenum, Buffer, Length, NULL); // but hangs LPC17xx --> comment out
\r
149 Endpoint_ClearOUT(corenum);
\r
150 return ENDPOINT_RWCSTREAM_NoError;
\r
153 uint8_t Endpoint_Read_Control_Stream_BE(void *const Buffer,
\r
156 return ENDPOINT_RWCSTREAM_NoError;
\r