Add new ARCH option to the makefiles to (eventually) specify the target device archit...
[pub/USBasp.git] / LUFA / Drivers / USB / HighLevel / EndpointStream.h
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 /** \file
32 * \brief USB device endpoint stream function definitions.
33 *
34 * This file contains structures, function prototypes and macros related to the sending and receiving of
35 * arbitrary data streams through the device's data endpoints when the library is initialized in USB device mode.
36 *
37 * \note This file should not be included directly. It is automatically included as needed by the USB driver
38 * dispatch header located in LUFA/Drivers/USB/USB.h.
39 */
40
41 /** \ingroup Group_EndpointRW
42 * \defgroup Group_EndpointStreamRW Read/Write of Multi-Byte Streams
43 *
44 * Functions, macros, variables, enums and types related to data reading and writing of data streams from
45 * and to endpoints.
46 *
47 * @{
48 */
49
50 #ifndef __ENDPOINT_STREAM_H__
51 #define __ENDPOINT_STREAM_H__
52
53 /* Includes: */
54 #include <avr/pgmspace.h>
55 #include <avr/eeprom.h>
56 #include <stdbool.h>
57
58 #include "../../../Common/Common.h"
59 #include "USBTask.h"
60
61 /* Enable C linkage for C++ Compilers: */
62 #if defined(__cplusplus)
63 extern "C" {
64 #endif
65
66 /* Preprocessor Checks: */
67 #if !defined(__INCLUDE_FROM_USB_DRIVER)
68 #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
69 #endif
70
71 /* Public Interface - May be used in end-application: */
72 /* Enums: */
73 /** Enum for the possible error return codes of the \c Endpoint_*_Stream_* functions. */
74 enum Endpoint_Stream_RW_ErrorCodes_t
75 {
76 ENDPOINT_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */
77 ENDPOINT_RWSTREAM_EndpointStalled = 1, /**< The endpoint was stalled during the stream
78 * transfer by the host or device.
79 */
80 ENDPOINT_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
81 * the transfer.
82 */
83 ENDPOINT_RWSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and
84 * no USB endpoint traffic can occur until the bus
85 * has resumed.
86 */
87 ENDPOINT_RWSTREAM_Timeout = 4, /**< The host failed to accept or send the next packet
88 * within the software timeout period set by the
89 * \ref USB_STREAM_TIMEOUT_MS macro.
90 */
91 ENDPOINT_RWSTREAM_IncompleteTransfer = 5, /**< Indicates that the endpoint bank became full or empty before
92 * the complete contents of the current stream could be
93 * transferred. The endpoint stream function should be called
94 * again to process the next chunk of data in the transfer.
95 */
96 };
97
98 /** Enum for the possible error return codes of the \c Endpoint_*_Control_Stream_* functions. */
99 enum Endpoint_ControlStream_RW_ErrorCodes_t
100 {
101 ENDPOINT_RWCSTREAM_NoError = 0, /**< Command completed successfully, no error. */
102 ENDPOINT_RWCSTREAM_HostAborted = 1, /**< The aborted the transfer prematurely. */
103 ENDPOINT_RWCSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during
104 * the transfer.
105 */
106 ENDPOINT_RWCSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and
107 * no USB endpoint traffic can occur until the bus
108 * has resumed.
109 */
110 };
111
112 /* Function Prototypes: */
113
114 /** \name Stream functions for null data */
115 //@{
116
117 /** Reads and discards the given number of bytes from the currently selected endpoint's bank,
118 * discarding fully read packets from the host as needed. The last packet is not automatically
119 * discarded once the remaining bytes has been read; the user is responsible for manually
120 * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
121 *
122 * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
123 * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
124 * storage location, the transfer will instead be performed as a series of chunks. Each time
125 * the endpoint bank becomes empty while there is still data to process (and after the current
126 * packet has been acknowledged) the BytesProcessed location will be updated with the total number
127 * of bytes processed in the stream, and the function will exit with an error code of
128 * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
129 * in the user code - to continue the transfer, call the function again with identical parameters
130 * and it will resume until the BytesProcessed value reaches the total transfer length.
131 *
132 * <b>Single Stream Transfer Example:</b>
133 * \code
134 * uint8_t ErrorCode;
135 *
136 * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
137 * {
138 * // Stream failed to complete - check ErrorCode here
139 * }
140 * \endcode
141 *
142 * <b>Partial Stream Transfers Example:</b>
143 * \code
144 * uint8_t ErrorCode;
145 * uint16_t BytesProcessed;
146 *
147 * BytesProcessed = 0;
148 * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
149 * {
150 * // Stream not yet complete - do other actions here, abort if required
151 * }
152 *
153 * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
154 * {
155 * // Stream failed to complete - check ErrorCode here
156 * }
157 * \endcode
158 *
159 * \note This routine should not be used on CONTROL type endpoints.
160 *
161 * \param[in] Length Number of bytes to discard via the currently selected endpoint.
162 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
163 * transaction should be updated, \c NULL if the entire stream should be read at once.
164 *
165 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
166 */
167 uint8_t Endpoint_Discard_Stream(uint16_t Length,
168 uint16_t* const BytesProcessed);
169
170 /** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending
171 * full packets to the host as needed. The last packet is not automatically sent once the
172 * remaining bytes have been written; the user is responsible for manually sending the last
173 * packet to the host via the \ref Endpoint_ClearIN() macro.
174 *
175 * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
176 * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
177 * storage location, the transfer will instead be performed as a series of chunks. Each time
178 * the endpoint bank becomes full while there is still data to process (and after the current
179 * packet transmission has been initiated) the BytesProcessed location will be updated with the
180 * total number of bytes processed in the stream, and the function will exit with an error code of
181 * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
182 * in the user code - to continue the transfer, call the function again with identical parameters
183 * and it will resume until the BytesProcessed value reaches the total transfer length.
184 *
185 * <b>Single Stream Transfer Example:</b>
186 * \code
187 * uint8_t ErrorCode;
188 *
189 * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
190 * {
191 * // Stream failed to complete - check ErrorCode here
192 * }
193 * \endcode
194 *
195 * <b>Partial Stream Transfers Example:</b>
196 * \code
197 * uint8_t ErrorCode;
198 * uint16_t BytesProcessed;
199 *
200 * BytesProcessed = 0;
201 * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
202 * {
203 * // Stream not yet complete - do other actions here, abort if required
204 * }
205 *
206 * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
207 * {
208 * // Stream failed to complete - check ErrorCode here
209 * }
210 * \endcode
211 *
212 * \note This routine should not be used on CONTROL type endpoints.
213 *
214 * \param[in] Length Number of zero bytes to send via the currently selected endpoint.
215 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
216 * transaction should be updated, \c NULL if the entire stream should be read at once.
217 *
218 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
219 */
220 uint8_t Endpoint_Null_Stream(uint16_t Length,
221 uint16_t* const BytesProcessed);
222
223 //@}
224
225 /** \name Stream functions for RAM source/destination data */
226 //@{
227
228 /** Writes the given number of bytes to the endpoint from the given buffer in little endian,
229 * sending full packets to the host as needed. The last packet filled is not automatically sent;
230 * the user is responsible for manually sending the last written packet to the host via the
231 * \ref Endpoint_ClearIN() macro.
232 *
233 * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
234 * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
235 * storage location, the transfer will instead be performed as a series of chunks. Each time
236 * the endpoint bank becomes full while there is still data to process (and after the current
237 * packet transmission has been initiated) the BytesProcessed location will be updated with the
238 * total number of bytes processed in the stream, and the function will exit with an error code of
239 * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
240 * in the user code - to continue the transfer, call the function again with identical parameters
241 * and it will resume until the BytesProcessed value reaches the total transfer length.
242 *
243 * <b>Single Stream Transfer Example:</b>
244 * \code
245 * uint8_t DataStream[512];
246 * uint8_t ErrorCode;
247 *
248 * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
249 * NULL)) != ENDPOINT_RWSTREAM_NoError)
250 * {
251 * // Stream failed to complete - check ErrorCode here
252 * }
253 * \endcode
254 *
255 * <b>Partial Stream Transfers Example:</b>
256 * \code
257 * uint8_t DataStream[512];
258 * uint8_t ErrorCode;
259 * uint16_t BytesProcessed;
260 *
261 * BytesProcessed = 0;
262 * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
263 * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
264 * {
265 * // Stream not yet complete - do other actions here, abort if required
266 * }
267 *
268 * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
269 * {
270 * // Stream failed to complete - check ErrorCode here
271 * }
272 * \endcode
273 *
274 * \note This routine should not be used on CONTROL type endpoints.
275 *
276 * \param[in] Buffer Pointer to the source data buffer to read from.
277 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
278 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
279 * transaction should be updated, \c NULL if the entire stream should be written at once.
280 *
281 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
282 */
283 uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,
284 uint16_t Length,
285 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
286
287 /** Writes the given number of bytes to the endpoint from the given buffer in big endian,
288 * sending full packets to the host as needed. The last packet filled is not automatically sent;
289 * the user is responsible for manually sending the last written packet to the host via the
290 * \ref Endpoint_ClearIN() macro.
291 *
292 * \note This routine should not be used on CONTROL type endpoints.
293 *
294 * \param[in] Buffer Pointer to the source data buffer to read from.
295 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
296 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
297 * transaction should be updated, \c NULL if the entire stream should be written at once.
298 *
299 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
300 */
301 uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,
302 uint16_t Length,
303 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
304
305 /** Reads the given number of bytes from the endpoint from the given buffer in little endian,
306 * discarding fully read packets from the host as needed. The last packet is not automatically
307 * discarded once the remaining bytes has been read; the user is responsible for manually
308 * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
309 *
310 * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,
311 * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid
312 * storage location, the transfer will instead be performed as a series of chunks. Each time
313 * the endpoint bank becomes empty while there is still data to process (and after the current
314 * packet has been acknowledged) the BytesProcessed location will be updated with the total number
315 * of bytes processed in the stream, and the function will exit with an error code of
316 * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed
317 * in the user code - to continue the transfer, call the function again with identical parameters
318 * and it will resume until the BytesProcessed value reaches the total transfer length.
319 *
320 * <b>Single Stream Transfer Example:</b>
321 * \code
322 * uint8_t DataStream[512];
323 * uint8_t ErrorCode;
324 *
325 * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
326 * NULL)) != ENDPOINT_RWSTREAM_NoError)
327 * {
328 * // Stream failed to complete - check ErrorCode here
329 * }
330 * \endcode
331 *
332 * <b>Partial Stream Transfers Example:</b>
333 * \code
334 * uint8_t DataStream[512];
335 * uint8_t ErrorCode;
336 * uint16_t BytesProcessed;
337 *
338 * BytesProcessed = 0;
339 * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
340 * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
341 * {
342 * // Stream not yet complete - do other actions here, abort if required
343 * }
344 *
345 * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
346 * {
347 * // Stream failed to complete - check ErrorCode here
348 * }
349 * \endcode
350 *
351 * \note This routine should not be used on CONTROL type endpoints.
352 *
353 * \param[out] Buffer Pointer to the destination data buffer to write to.
354 * \param[in] Length Number of bytes to send via the currently selected endpoint.
355 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
356 * transaction should be updated, \c NULL if the entire stream should be read at once.
357 *
358 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
359 */
360 uint8_t Endpoint_Read_Stream_LE(void* const Buffer,
361 uint16_t Length,
362 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
363
364 /** Reads the given number of bytes from the endpoint from the given buffer in big endian,
365 * discarding fully read packets from the host as needed. The last packet is not automatically
366 * discarded once the remaining bytes has been read; the user is responsible for manually
367 * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.
368 *
369 * \note This routine should not be used on CONTROL type endpoints.
370 *
371 * \param[out] Buffer Pointer to the destination data buffer to write to.
372 * \param[in] Length Number of bytes to send via the currently selected endpoint.
373 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
374 * transaction should be updated, \c NULL if the entire stream should be read at once.
375 *
376 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
377 */
378 uint8_t Endpoint_Read_Stream_BE(void* const Buffer,
379 uint16_t Length,
380 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
381
382 /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,
383 * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
384 * in both failure and success states; the user is responsible for manually clearing the setup OUT to
385 * finalize the transfer via the \ref Endpoint_ClearOUT() macro.
386 *
387 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
388 * to clear the status stage when using this routine in a control transaction.
389 * \n\n
390 *
391 * \note This routine should only be used on CONTROL type endpoints.
392 *
393 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
394 * together; i.e. the entire stream data must be read or written at the one time.
395 *
396 * \param[in] Buffer Pointer to the source data buffer to read from.
397 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
398 *
399 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
400 */
401 uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,
402 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
403
404 /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,
405 * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared
406 * in both failure and success states; the user is responsible for manually clearing the setup OUT to
407 * finalize the transfer via the \ref Endpoint_ClearOUT() macro.
408 *
409 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
410 * to clear the status stage when using this routine in a control transaction.
411 * \n\n
412 *
413 * \note This routine should only be used on CONTROL type endpoints.
414 *
415 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
416 * together; i.e. the entire stream data must be read or written at the one time.
417 *
418 * \param[in] Buffer Pointer to the source data buffer to read from.
419 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
420 *
421 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
422 */
423 uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,
424 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
425
426 /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,
427 * discarding fully read packets from the host as needed. The device IN acknowledgement is not
428 * automatically sent after success or failure states; the user is responsible for manually sending the
429 * setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
430 *
431 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
432 * to clear the status stage when using this routine in a control transaction.
433 * \n\n
434 *
435 * \note This routine should only be used on CONTROL type endpoints.
436 *
437 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
438 * together; i.e. the entire stream data must be read or written at the one time.
439 *
440 * \param[out] Buffer Pointer to the destination data buffer to write to.
441 * \param[in] Length Number of bytes to send via the currently selected endpoint.
442 *
443 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
444 */
445 uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,
446 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
447
448 /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,
449 * discarding fully read packets from the host as needed. The device IN acknowledgement is not
450 * automatically sent after success or failure states; the user is responsible for manually sending the
451 * setup IN to finalize the transfer via the \ref Endpoint_ClearIN() macro.
452 *
453 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
454 * to clear the status stage when using this routine in a control transaction.
455 * \n\n
456 *
457 * \note This routine should only be used on CONTROL type endpoints.
458 *
459 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
460 * together; i.e. the entire stream data must be read or written at the one time.
461 *
462 * \param[out] Buffer Pointer to the destination data buffer to write to.
463 * \param[in] Length Number of bytes to send via the currently selected endpoint.
464 *
465 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
466 */
467 uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,
468 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
469 //@}
470
471 /** \name Stream functions for EEPROM source/destination data */
472 //@{
473
474 /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE().
475 *
476 * \param[in] Buffer Pointer to the source data buffer to read from.
477 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
478 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
479 * transaction should be updated, \c NULL if the entire stream should be written at once.
480 *
481 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
482 */
483 uint8_t Endpoint_Write_EStream_LE(const void* const Buffer,
484 uint16_t Length,
485 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
486
487 /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE().
488 *
489 * \param[in] Buffer Pointer to the source data buffer to read from.
490 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
491 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
492 * transaction should be updated, \c NULL if the entire stream should be written at once.
493 *
494 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
495 */
496 uint8_t Endpoint_Write_EStream_BE(const void* const Buffer,
497 uint16_t Length,
498 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
499
500 /** EEPROM buffer source version of \ref Endpoint_Read_Stream_LE().
501 *
502 * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
503 * \param[in] Length Number of bytes to send via the currently selected endpoint.
504 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
505 * transaction should be updated, \c NULL if the entire stream should be read at once.
506 *
507 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
508 */
509 uint8_t Endpoint_Read_EStream_LE(void* const Buffer,
510 uint16_t Length,
511 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
512
513 /** EEPROM buffer source version of \ref Endpoint_Read_Stream_BE().
514 *
515 * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.
516 * \param[in] Length Number of bytes to send via the currently selected endpoint.
517 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
518 * transaction should be updated, \c NULL if the entire stream should be read at once.
519 *
520 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
521 */
522 uint8_t Endpoint_Read_EStream_BE(void* const Buffer,
523 uint16_t Length,
524 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
525
526 /** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE.
527 *
528 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
529 * to clear the status stage when using this routine in a control transaction.
530 * \n\n
531 *
532 * \note This routine should only be used on CONTROL type endpoints.
533 *
534 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
535 * together; i.e. the entire stream data must be read or written at the one time.
536 *
537 * \param[in] Buffer Pointer to the source data buffer to read from.
538 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
539 *
540 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
541 */
542 uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer,
543 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
544
545 /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE().
546 *
547 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
548 * to clear the status stage when using this routine in a control transaction.
549 * \n\n
550 *
551 * \note This routine should only be used on CONTROL type endpoints.
552 *
553 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
554 * together; i.e. the entire stream data must be read or written at the one time.
555 *
556 * \param[in] Buffer Pointer to the source data buffer to read from.
557 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
558 *
559 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
560 */
561 uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer,
562 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
563
564 /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE().
565 *
566 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
567 * to clear the status stage when using this routine in a control transaction.
568 * \n\n
569 *
570 * \note This routine should only be used on CONTROL type endpoints.
571 *
572 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
573 * together; i.e. the entire stream data must be read or written at the one time.
574 *
575 * \param[out] Buffer Pointer to the destination data buffer to write to.
576 * \param[in] Length Number of bytes to send via the currently selected endpoint.
577 *
578 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
579 */
580 uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer,
581 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
582
583 /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE().
584 *
585 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
586 * to clear the status stage when using this routine in a control transaction.
587 * \n\n
588 *
589 * \note This routine should only be used on CONTROL type endpoints.
590 *
591 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
592 * together; i.e. the entire stream data must be read or written at the one time.
593 *
594 * \param[out] Buffer Pointer to the destination data buffer to write to.
595 * \param[in] Length Number of bytes to send via the currently selected endpoint.
596 *
597 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
598 */
599 uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer,
600 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
601 //@}
602
603 /** \name Stream functions for PROGMEM source/destination data */
604 //@{
605
606 /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE().
607 *
608 * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
609 *
610 * \param[in] Buffer Pointer to the source data buffer to read from.
611 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
612 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
613 * transaction should be updated, \c NULL if the entire stream should be written at once.
614 *
615 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
616 */
617 uint8_t Endpoint_Write_PStream_LE(const void* const Buffer,
618 uint16_t Length,
619 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
620
621 /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE().
622 *
623 * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
624 *
625 * \param[in] Buffer Pointer to the source data buffer to read from.
626 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
627 * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current
628 * transaction should be updated, \c NULL if the entire stream should be written at once.
629 *
630 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
631 */
632 uint8_t Endpoint_Write_PStream_BE(const void* const Buffer,
633 uint16_t Length,
634 uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);
635
636 /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE().
637 *
638 * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
639 *
640 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
641 * to clear the status stage when using this routine in a control transaction.
642 * \n\n
643 *
644 * \note This routine should only be used on CONTROL type endpoints.
645 *
646 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
647 * together; i.e. the entire stream data must be read or written at the one time.
648 *
649 * \param[in] Buffer Pointer to the source data buffer to read from.
650 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
651 *
652 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
653 */
654 uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer,
655 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
656
657 /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE().
658 *
659 * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
660 *
661 * \note This function automatically clears the control transfer's status stage. Do not manually attempt
662 * to clear the status stage when using this routine in a control transaction.
663 * \n\n
664 *
665 * \note This routine should only be used on CONTROL type endpoints.
666 *
667 * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained
668 * together; i.e. the entire stream data must be read or written at the one time.
669 *
670 * \param[in] Buffer Pointer to the source data buffer to read from.
671 * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.
672 *
673 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
674 */
675 uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer,
676 uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);
677 //@}
678
679 /* Disable C linkage for C++ Compilers: */
680 #if defined(__cplusplus)
681 }
682 #endif
683
684 #endif
685
686 /** @} */
687