2 * @brief Pipe 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_HOST)
\r
37 #include "PipeStream.h"
\r
39 uint8_t Pipe_Discard_Stream(const uint8_t corenum,
\r
41 uint16_t *const BytesProcessed)
\r
44 uint16_t BytesInTransfer = 0;
\r
46 // Pipe_SetPipeToken(PIPE_TOKEN_IN);
\r
47 ErrorCode = Pipe_WaitUntilReady(corenum);
\r
52 if (BytesProcessed != NULL) {
\r
53 Length -= *BytesProcessed;
\r
57 if (!(Pipe_IsReadWriteAllowed(corenum))) {
\r
58 Pipe_ClearIN(corenum);
\r
60 if (BytesProcessed != NULL) {
\r
61 *BytesProcessed += BytesInTransfer;
\r
62 return PIPE_RWSTREAM_IncompleteTransfer;
\r
64 ErrorCode = Pipe_WaitUntilReady(corenum);
\r
77 return PIPE_RWSTREAM_NoError;
\r
80 uint8_t Pipe_Null_Stream(const uint8_t corenum,
\r
82 uint16_t *const BytesProcessed)
\r
84 if (BytesProcessed != NULL) {
\r
85 Length -= *BytesProcessed;
\r
89 Pipe_Write_8(corenum, 0);
\r
93 return PIPE_RWSTREAM_NoError;
\r
96 uint8_t Pipe_Write_Stream_LE(const uint8_t corenum,
\r
97 const void *const Buffer,
\r
99 uint16_t *const BytesProcessed)
\r
101 uint8_t *DataStream = (uint8_t *) Buffer;
\r
102 if (BytesProcessed != NULL) {
\r
103 Length -= *BytesProcessed;
\r
104 DataStream += *BytesProcessed;
\r
108 Pipe_Write_8(corenum, *DataStream);
\r
113 return PIPE_RWSTREAM_NoError;
\r
116 uint8_t Pipe_Read_Stream_LE(const uint8_t corenum,
\r
117 void *const Buffer,
\r
119 uint16_t *const BytesProcessed) /* TODO Blocking due to Pipe_WaitUntilReady */
\r
121 uint8_t *DataStream = (uint8_t *) Buffer;
\r
124 ErrorCode = Pipe_WaitUntilReady(corenum);
\r
129 if (BytesProcessed != NULL) {
\r
130 Length -= *BytesProcessed;
\r
131 DataStream += *BytesProcessed;
\r
135 if (Pipe_IsReadWriteAllowed(corenum)) {
\r
136 *DataStream = Pipe_Read_8(corenum);
\r
141 Pipe_ClearIN(corenum);
\r
142 HcdDataTransfer(PipeInfo[corenum][pipeselected[corenum]].PipeHandle,
\r
143 PipeInfo[corenum][pipeselected[corenum]].Buffer,
\r
144 MIN(Length, PipeInfo[corenum][pipeselected[corenum]].BufferSize),
\r
145 &PipeInfo[corenum][pipeselected[corenum]].ByteTransfered);
\r
146 ErrorCode = Pipe_WaitUntilReady(corenum);
\r
153 return PIPE_RWSTREAM_NoError;
\r
156 uint8_t Pipe_Write_Stream_BE(const void *const Buffer,
\r
158 uint16_t *const BytesProcessed)
\r
160 return PIPE_RWSTREAM_NoError;
\r
163 uint8_t Pipe_Read_Stream_BE(void *const Buffer,
\r
165 uint16_t *const BytesProcessed)
\r
167 return PIPE_RWSTREAM_NoError;
\r
170 uint8_t Pipe_Write_PStream_LE(const void *const Buffer,
\r
172 uint16_t *const BytesProcessed)
\r
174 return PIPE_RWSTREAM_NoError;
\r
177 uint8_t Pipe_Write_PStream_BE(const void *const Buffer,
\r
179 uint16_t *const BytesProcessed)
\r
181 return PIPE_RWSTREAM_NoError;
\r
184 uint8_t Pipe_Write_EStream_LE(const void *const Buffer,
\r
186 uint16_t *const BytesProcessed)
\r
188 return PIPE_RWSTREAM_NoError;
\r
191 uint8_t Pipe_Write_EStream_BE(const void *const Buffer,
\r
193 uint16_t *const BytesProcessed)
\r
195 return PIPE_RWSTREAM_NoError;
\r
198 uint8_t Pipe_Read_EStream_LE(void *const Buffer,
\r
200 uint16_t *const BytesProcessed)
\r
202 return PIPE_RWSTREAM_NoError;
\r
205 uint8_t Pipe_Read_EStream_BE(void *const Buffer,
\r
207 uint16_t *const BytesProcessed)
\r
209 return PIPE_RWSTREAM_NoError;
\r
212 uint8_t Pipe_Streaming(uint8_t corenum, uint8_t* const buffer, uint32_t const transferlength, uint16_t const packetsize)
\r
214 uint32_t pipehdl = PipeInfo[corenum][pipeselected[corenum]].PipeHandle;
\r
215 if (HCD_STATUS_OK == HcdGetPipeStatus(pipehdl))
\r
217 HcdSetStreamPacketSize(pipehdl,packetsize);
\r
218 HcdDataTransfer(pipehdl,buffer,transferlength,&PipeInfo[corenum][pipeselected[corenum]].ByteTransfered);
\r
219 return PIPE_RWSTREAM_NoError;
\r
221 else return PIPE_RWSTREAM_IncompleteTransfer;
\r