LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
EndpointStream_LPC.c
Go to the documentation of this file.
1 /*
2  * @brief Endpoint data stream transmission and reception management 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 #define __INCLUDE_FROM_USB_DRIVER
33 #include "../USBMode.h"
34 
35 #if defined(USB_CAN_BE_DEVICE)
36 
37 #include "EndpointStream_LPC.h"
38 
39 #if !defined(CONTROL_ONLY_DEVICE)
41  uint16_t *const BytesProcessed)
42 {
43  uint32_t i;
44  for (i = 0; i < Length; i++)
47 }
48 
49 uint8_t Endpoint_Null_Stream(uint16_t Length,
50  uint16_t *const BytesProcessed)
51 {
52  uint32_t i;
53 
54  while ( !Endpoint_IsINReady() ) { /*-- Wait until ready --*/
55  Delay_MS(2);
56  }
57  for (i = 0; i < Length; i++)
60 }
61 
62 uint8_t Endpoint_Write_Stream_LE(const void *const Buffer,
63  uint16_t Length,
64  uint16_t *const BytesProcessed)
65 {
66  uint16_t i;
67 
68  while ( !Endpoint_IsINReady() ) { /*-- Wait until ready --*/
69  Delay_MS(2);
70  }
71  for (i = 0; i < Length; i++)
72  Endpoint_Write_8(((uint8_t *) Buffer)[i]);
73 
75 }
76 
77 uint8_t Endpoint_Write_Stream_BE(const void *const Buffer,
78  uint16_t Length,
79  uint16_t *const BytesProcessed)
80 {
81  uint16_t i;
82 
83  for (i = 0; i < Length; i++)
84  Endpoint_Write_8(((uint8_t *) Buffer)[Length - 1 - i]);
86 }
87 
88 uint8_t Endpoint_Read_Stream_LE(void *const Buffer,
89  uint16_t Length,
90  uint16_t *const BytesProcessed)
91 {
92  uint16_t i;
94  if (usb_data_buffer_size == 0) {
96  }
97  }
98  else if (usb_data_buffer_OUT_size == 0) {
100  }
101 
102  for (i = 0; i < Length; i++) {
103  #if defined(__LPC17XX__) || defined(__LPC177X_8X__)
105  while (usb_data_buffer_OUT_size == 0) ; /* Current Fix for LPC17xx, havent checked for others */
106  }
107  #endif
108  ((uint8_t *) Buffer)[i] = Endpoint_Read_8();
109  }
111 }
112 
113 uint8_t Endpoint_Read_Stream_BE(void *const Buffer,
114  uint16_t Length,
115  uint16_t *const BytesProcessed)
116 {
118 }
119 
120 #endif
121 
122 uint8_t Endpoint_Write_Control_Stream_LE(const void *const Buffer,
123  uint16_t Length)
124 {
125  Endpoint_Write_Stream_LE((uint8_t *) Buffer, MIN(Length, USB_ControlRequest.wLength), NULL);
127  // while (!(Endpoint_IsOUTReceived()))
128  // {
129  // }
131 }
132 
133 uint8_t Endpoint_Write_Control_Stream_BE(const void *const Buffer,
134  uint16_t Length)
135 {
137 }
138 
139 uint8_t Endpoint_Read_Control_Stream_LE(void *const Buffer,
140  uint16_t Length)
141 {
142  while (!Endpoint_IsOUTReceived()) ; // FIXME: this safe checking is fine for LPC18xx
143  Endpoint_Read_Stream_LE(Buffer, Length, NULL); // but hangs LPC17xx --> comment out
146 }
147 
148 uint8_t Endpoint_Read_Control_Stream_BE(void *const Buffer,
149  uint16_t Length)
150 {
152 }
153 
154 #endif