Add start of an architecture port to the Atmel USB XMEGA devices.
[pub/USBasp.git] / LUFA / Drivers / USB / Core / XMEGA / EndpointStream_XMEGA.c
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2011.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.lufa-lib.org
7 */
8
9 /*
10 Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 #define __INCLUDE_FROM_USB_DRIVER
32 #include "../USBMode.h"
33
34 #if defined(USB_CAN_BE_DEVICE)
35
36 #include "EndpointStream_XMEGA.h"
37
38 #if !defined(CONTROL_ONLY_DEVICE)
39 uint8_t Endpoint_Discard_Stream(uint16_t Length,
40 uint16_t* const BytesProcessed)
41 {
42 return 0; // TODO
43 }
44
45 uint8_t Endpoint_Null_Stream(uint16_t Length,
46 uint16_t* const BytesProcessed)
47 {
48 return 0; // TODO
49 }
50
51 #define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE
52 #define TEMPLATE_BUFFER_TYPE const void*
53 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
54 #define TEMPLATE_BUFFER_OFFSET(Length) 0
55 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
56 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
57 #include "Template/Template_Endpoint_RW.c"
58
59 #define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE
60 #define TEMPLATE_BUFFER_TYPE const void*
61 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
62 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
63 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
64 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
65 #include "Template/Template_Endpoint_RW.c"
66
67 #define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE
68 #define TEMPLATE_BUFFER_TYPE void*
69 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
70 #define TEMPLATE_BUFFER_OFFSET(Length) 0
71 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
72 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
73 #include "Template/Template_Endpoint_RW.c"
74
75 #define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE
76 #define TEMPLATE_BUFFER_TYPE void*
77 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
78 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
79 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
80 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
81 #include "Template/Template_Endpoint_RW.c"
82
83 #if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
84 #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE
85 #define TEMPLATE_BUFFER_TYPE const void*
86 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
87 #define TEMPLATE_BUFFER_OFFSET(Length) 0
88 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
89 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
90 #include "Template/Template_Endpoint_RW.c"
91
92 #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE
93 #define TEMPLATE_BUFFER_TYPE const void*
94 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
95 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
96 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
97 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
98 #include "Template/Template_Endpoint_RW.c"
99 #endif
100
101 #if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
102 #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE
103 #define TEMPLATE_BUFFER_TYPE const void*
104 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
105 #define TEMPLATE_BUFFER_OFFSET(Length) 0
106 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
107 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
108 #include "Template/Template_Endpoint_RW.c"
109
110 #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE
111 #define TEMPLATE_BUFFER_TYPE const void*
112 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()
113 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
114 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
115 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
116 #include "Template/Template_Endpoint_RW.c"
117
118 #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE
119 #define TEMPLATE_BUFFER_TYPE void*
120 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
121 #define TEMPLATE_BUFFER_OFFSET(Length) 0
122 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
123 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
124 #include "Template/Template_Endpoint_RW.c"
125
126 #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE
127 #define TEMPLATE_BUFFER_TYPE void*
128 #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()
129 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
130 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
131 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
132 #include "Template/Template_Endpoint_RW.c"
133 #endif
134
135 #endif
136
137 #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE
138 #define TEMPLATE_BUFFER_OFFSET(Length) 0
139 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
140 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
141 #include "Template/Template_Endpoint_Control_W.c"
142
143 #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE
144 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
145 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
146 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)
147 #include "Template/Template_Endpoint_Control_W.c"
148
149 #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE
150 #define TEMPLATE_BUFFER_OFFSET(Length) 0
151 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
152 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
153 #include "Template/Template_Endpoint_Control_R.c"
154
155 #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE
156 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
157 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
158 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()
159 #include "Template/Template_Endpoint_Control_R.c"
160
161 #if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)
162 #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE
163 #define TEMPLATE_BUFFER_OFFSET(Length) 0
164 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
165 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
166 #include "Template/Template_Endpoint_Control_W.c"
167
168 #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE
169 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
170 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
171 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))
172 #include "Template/Template_Endpoint_Control_W.c"
173 #endif
174
175 #if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)
176 #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE
177 #define TEMPLATE_BUFFER_OFFSET(Length) 0
178 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
179 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
180 #include "Template/Template_Endpoint_Control_W.c"
181
182 #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE
183 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
184 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
185 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))
186 #include "Template/Template_Endpoint_Control_W.c"
187
188 #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE
189 #define TEMPLATE_BUFFER_OFFSET(Length) 0
190 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount
191 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
192 #include "Template/Template_Endpoint_Control_R.c"
193
194 #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE
195 #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)
196 #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount
197 #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())
198 #include "Template/Template_Endpoint_Control_R.c"
199 #endif
200
201 #endif