3 Copyright (C) Dean Camera, 2011.
5 dean [at] fourwalledcubicle [dot] com
10 Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
32 * \brief USB device endpoint stream function definitions.
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.
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.
41 /** \ingroup Group_EndpointRW
42 * \defgroup Group_EndpointStreamRW Read/Write of Multi-Byte Streams
44 * Functions, macros, variables, enums and types related to data reading and writing of data streams from
50 #ifndef __ENDPOINT_STREAM_H__
51 #define __ENDPOINT_STREAM_H__
54 #include <avr/pgmspace.h>
55 #include <avr/eeprom.h>
58 #include "../../../Common/Common.h"
61 /* Enable C linkage for C++ Compilers: */
62 #if defined(__cplusplus)
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.
71 /* Public Interface - May be used in end-application: */
73 /** Enum for the possible error return codes of the \c Endpoint_*_Stream_* functions. */
74 enum Endpoint_Stream_RW_ErrorCodes_t
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.
80 ENDPOINT_RWSTREAM_DeviceDisconnected
= 2, /**< Device was disconnected from the host during
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
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.
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.
98 /** Enum for the possible error return codes of the \c Endpoint_*_Control_Stream_* functions. */
99 enum Endpoint_ControlStream_RW_ErrorCodes_t
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
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
112 /* Function Prototypes: */
114 /** \name Stream functions for null data */
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.
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.
132 * <b>Single Stream Transfer Example:</b>
136 * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
138 * // Stream failed to complete - check ErrorCode here
142 * <b>Partial Stream Transfers Example:</b>
145 * uint16_t BytesProcessed;
147 * BytesProcessed = 0;
148 * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
150 * // Stream not yet complete - do other actions here, abort if required
153 * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
155 * // Stream failed to complete - check ErrorCode here
159 * \note This routine should not be used on CONTROL type endpoints.
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.
165 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
167 uint8_t Endpoint_Discard_Stream(uint16_t Length
,
168 uint16_t* const BytesProcessed
);
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.
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.
185 * <b>Single Stream Transfer Example:</b>
189 * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)
191 * // Stream failed to complete - check ErrorCode here
195 * <b>Partial Stream Transfers Example:</b>
198 * uint16_t BytesProcessed;
200 * BytesProcessed = 0;
201 * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
203 * // Stream not yet complete - do other actions here, abort if required
206 * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
208 * // Stream failed to complete - check ErrorCode here
212 * \note This routine should not be used on CONTROL type endpoints.
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.
218 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
220 uint8_t Endpoint_Null_Stream(uint16_t Length
,
221 uint16_t* const BytesProcessed
);
225 /** \name Stream functions for RAM source/destination data */
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.
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.
243 * <b>Single Stream Transfer Example:</b>
245 * uint8_t DataStream[512];
248 * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
249 * NULL)) != ENDPOINT_RWSTREAM_NoError)
251 * // Stream failed to complete - check ErrorCode here
255 * <b>Partial Stream Transfers Example:</b>
257 * uint8_t DataStream[512];
259 * uint16_t BytesProcessed;
261 * BytesProcessed = 0;
262 * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),
263 * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
265 * // Stream not yet complete - do other actions here, abort if required
268 * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
270 * // Stream failed to complete - check ErrorCode here
274 * \note This routine should not be used on CONTROL type endpoints.
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.
281 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
283 uint8_t Endpoint_Write_Stream_LE(const void* const Buffer
,
285 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
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.
292 * \note This routine should not be used on CONTROL type endpoints.
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.
299 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
301 uint8_t Endpoint_Write_Stream_BE(const void* const Buffer
,
303 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
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.
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.
320 * <b>Single Stream Transfer Example:</b>
322 * uint8_t DataStream[512];
325 * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
326 * NULL)) != ENDPOINT_RWSTREAM_NoError)
328 * // Stream failed to complete - check ErrorCode here
332 * <b>Partial Stream Transfers Example:</b>
334 * uint8_t DataStream[512];
336 * uint16_t BytesProcessed;
338 * BytesProcessed = 0;
339 * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),
340 * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)
342 * // Stream not yet complete - do other actions here, abort if required
345 * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)
347 * // Stream failed to complete - check ErrorCode here
351 * \note This routine should not be used on CONTROL type endpoints.
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.
358 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
360 uint8_t Endpoint_Read_Stream_LE(void* const Buffer
,
362 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
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.
369 * \note This routine should not be used on CONTROL type endpoints.
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.
376 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
378 uint8_t Endpoint_Read_Stream_BE(void* const Buffer
,
380 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
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.
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.
391 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
399 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
401 uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer
,
402 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
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.
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.
413 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
421 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
423 uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer
,
424 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
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.
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.
435 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
443 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
445 uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer
,
446 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
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.
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.
457 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
465 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
467 uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer
,
468 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
471 /** \name Stream functions for EEPROM source/destination data */
474 /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE().
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.
481 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
483 uint8_t Endpoint_Write_EStream_LE(const void* const Buffer
,
485 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
487 /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE().
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.
494 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
496 uint8_t Endpoint_Write_EStream_BE(const void* const Buffer
,
498 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
500 /** EEPROM buffer source version of \ref Endpoint_Read_Stream_LE().
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.
507 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
509 uint8_t Endpoint_Read_EStream_LE(void* const Buffer
,
511 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
513 /** EEPROM buffer source version of \ref Endpoint_Read_Stream_BE().
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.
520 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
522 uint8_t Endpoint_Read_EStream_BE(void* const Buffer
,
524 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
526 /** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE.
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.
532 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
540 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
542 uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer
,
543 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
545 /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE().
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.
551 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
559 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
561 uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer
,
562 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
564 /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE().
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.
570 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
578 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
580 uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer
,
581 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
583 /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE().
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.
589 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
597 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
599 uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer
,
600 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
603 /** \name Stream functions for PROGMEM source/destination data */
606 /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE().
608 * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
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.
615 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
617 uint8_t Endpoint_Write_PStream_LE(const void* const Buffer
,
619 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
621 /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE().
623 * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
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.
630 * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.
632 uint8_t Endpoint_Write_PStream_BE(const void* const Buffer
,
634 uint16_t* const BytesProcessed
) ATTR_NON_NULL_PTR_ARG(1);
636 /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE().
638 * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
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.
644 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
652 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
654 uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer
,
655 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
657 /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE().
659 * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.
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.
665 * \note This routine should only be used on CONTROL type endpoints.
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.
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.
673 * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.
675 uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer
,
676 uint16_t Length
) ATTR_NON_NULL_PTR_ARG(1);
679 /* Disable C linkage for C++ Compilers: */
680 #if defined(__cplusplus)