* Functions, macros, variables, enums and types related to data reading and writing from and to pipes.\r
*/\r
\r
+/** \ingroup Group_PipeRW \r
+ * @defgroup Group_PipePrimitiveRW Read/Write of Primitive Data Types\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to pipes.\r
+ */ \r
+\r
+/** \ingroup Group_PipeRW \r
+ * @defgroup Group_PipeStreamRW Read/Write of Multi-Byte Streams\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of data streams from\r
+ * and to pipes.\r
+ */ \r
+ \r
/** @defgroup Group_PipePacketManagement Pipe Packet Management\r
*\r
* Functions, macros, variables, enums and types related to packet management of pipes.\r
\r
/* Includes: */\r
#include <avr/io.h>\r
+ #include <avr/pgmspace.h>\r
+ #include <avr/eeprom.h>\r
#include <stdbool.h>\r
\r
#include "../../../Common/Common.h"\r
/* Inline Functions: */\r
/** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \return Next byte in the currently selected pipe's FIFO buffer\r
*/\r
\r
/** Writes one byte from the currently selected pipe's bank, for IN direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \param[in] Byte Next byte to write into the the currently selected pipe's FIFO buffer\r
*/\r
\r
/** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*/\r
static inline void Pipe_Discard_Byte(void) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_Discard_Byte(void)\r
/** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT\r
* direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \return Next word in the currently selected pipe's FIFO buffer\r
*/\r
/** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT\r
* direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \return Next word in the currently selected pipe's FIFO buffer\r
*/\r
/** Writes two bytes to the currently selected pipe's bank in little endian format, for IN\r
* direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \param[in] Word Next word to write to the currently selected pipe's FIFO buffer\r
*/\r
/** Writes two bytes to the currently selected pipe's bank in big endian format, for IN\r
* direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \param[in] Word Next word to write to the currently selected pipe's FIFO buffer\r
*/\r
\r
/** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*/\r
static inline void Pipe_Discard_Word(void) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_Discard_Word(void)\r
/** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT\r
* direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \return Next double word in the currently selected pipe's FIFO buffer\r
*/\r
/** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT\r
* direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \return Next double word in the currently selected pipe's FIFO buffer\r
*/\r
/** Writes four bytes to the currently selected pipe's bank in little endian format, for IN\r
* direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer\r
*/\r
/** Writes four bytes to the currently selected pipe's bank in big endian format, for IN\r
* direction pipes.\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*\r
* \param[in] DWord Next double word to write to the currently selected pipe's FIFO buffer\r
*/\r
\r
/** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. \r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipePrimitiveRW\r
*/\r
static inline void Pipe_Discard_DWord(void) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_Discard_DWord(void)\r
extern uint8_t USB_ControlPipeSize;\r
\r
/* Function Prototypes: */\r
+ #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
+ #define _CALLBACK_PARAM , StreamCallbackPtr_t Callback\r
+ #else\r
+ #define _CALLBACK_PARAM \r
+ #endif\r
+\r
/** Configures the specified pipe number with the given pipe type, token, target endpoint number in the\r
* attached device, bank size and banking mode. Pipes should be allocated in ascending order by their\r
* address in the device (i.e. pipe 1 should be configured before pipe 2 and so on) to prevent fragmentation\r
*/\r
uint8_t Pipe_WaitUntilReady(void); \r
\r
+ /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host\r
+ * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the\r
+ * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro.\r
+ * Between each USB packet, the given stream callback function is executed repeatedly until the next packet is ready,\r
+ * allowing for early aborts of stream transfers.\r
+ *\r
+ * The callback routine should be created according to the information in \ref Group_StreamCallbacks.\r
+ * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are\r
+ * disabled and this function has the Callback parameter omitted.\r
+ *\r
+ * The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \ingroup Group_PipeStreamRW\r
+ *\r
+ * \param[in] Length Number of bytes to send via the currently selected pipe.\r
+ * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Discard_Stream(uint16_t Length _CALLBACK_PARAM);\r
+\r
/** Writes the given number of bytes to the pipe from the given buffer in little endian,\r
* sending full packets to the device as needed. The last packet filled is not automatically sent;\r
* the user is responsible for manually sending the last written packet to the host via the\r
* The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipeStreamRW\r
*\r
* \param[in] Buffer Pointer to the source data buffer to read from.\r
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
*\r
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
*/\r
- uint8_t Pipe_Write_Stream_LE(const void* Buffer, uint16_t Length\r
- #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
- , StreamCallbackPtr_t Callback\r
- #endif\r
- ) ATTR_NON_NULL_PTR_ARG(1); \r
+ uint8_t Pipe_Write_Stream_LE(const void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1); \r
\r
+ /** EEPROM buffer source version of \ref Pipe_Write_Stream_LE.\r
+ *\r
+ * \ingroup Group_PipeStreamRW\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_EStream_LE(const void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
+ /** FLASH buffer source version of \ref Pipe_Write_Stream_LE.\r
+ *\r
+ * \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \ingroup Group_PipeStreamRW\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_PStream_LE(const void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
/** Writes the given number of bytes to the pipe from the given buffer in big endian,\r
* sending full packets to the device as needed. The last packet filled is not automatically sent;\r
* the user is responsible for manually sending the last written packet to the host via the\r
* The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipeStreamRW\r
*\r
* \param[in] Buffer Pointer to the source data buffer to read from.\r
* \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
*\r
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
*/\r
- uint8_t Pipe_Write_Stream_BE(const void* Buffer, uint16_t Length\r
- #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
- , StreamCallbackPtr_t Callback\r
- #endif\r
- ) ATTR_NON_NULL_PTR_ARG(1);\r
+ uint8_t Pipe_Write_Stream_BE(const void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
\r
- /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host\r
- * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the\r
- * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro.\r
- * Between each USB packet, the given stream callback function is executed repeatedly until the next packet is ready,\r
- * allowing for early aborts of stream transfers.\r
+ /** EEPROM buffer source version of \ref Pipe_Write_Stream_BE.\r
*\r
- * The callback routine should be created according to the information in \ref Group_StreamCallbacks.\r
- * If the token NO_STREAM_CALLBACKS is passed via the -D option to the compiler, stream callbacks are\r
- * disabled and this function has the Callback parameter omitted.\r
+ * \ingroup Group_PipeStreamRW\r
*\r
- * The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
- * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback\r
*\r
- * \ingroup Group_PipeRW\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_EStream_BE(const void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
+ /** FLASH buffer source version of \ref Pipe_Write_Stream_BE.\r
*\r
- * \param[in] Length Number of bytes to send via the currently selected pipe.\r
+ * \note The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \ingroup Group_PipeStreamRW\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
* \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback\r
*\r
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
*/\r
- uint8_t Pipe_Discard_Stream(uint16_t Length\r
- #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
- , StreamCallbackPtr_t Callback\r
- #endif\r
- );\r
+ uint8_t Pipe_Write_PStream_BE(const void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
\r
/** Reads the given number of bytes from the pipe into the given buffer in little endian,\r
* sending full packets to the device as needed. The last packet filled is not automatically sent;\r
* The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipeStreamRW\r
*\r
* \param[out] Buffer Pointer to the source data buffer to write to.\r
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
*\r
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
*/\r
- uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length\r
- #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
- , StreamCallbackPtr_t Callback\r
- #endif\r
- ) ATTR_NON_NULL_PTR_ARG(1);\r
+ uint8_t Pipe_Read_Stream_LE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Pipe_Read_Stream_LE.\r
+ *\r
+ * \ingroup Group_PipeStreamRW\r
+ *\r
+ * \param[out] Buffer Pointer to the source data buffer to write to.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_EStream_LE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
\r
/** Reads the given number of bytes from the pipe into the given buffer in big endian,\r
* sending full packets to the device as needed. The last packet filled is not automatically sent;\r
* The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
* having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
*\r
- * \ingroup Group_PipeRW\r
+ * \ingroup Group_PipeStreamRW\r
*\r
* \param[out] Buffer Pointer to the source data buffer to write to.\r
* \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
*\r
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
*/\r
- uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length\r
- #if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
- , StreamCallbackPtr_t Callback\r
- #endif\r
- ) ATTR_NON_NULL_PTR_ARG(1);\r
+ uint8_t Pipe_Read_Stream_BE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
\r
+ /** EEPROM buffer source version of \ref Pipe_Read_Stream_BE.\r
+ *\r
+ * \ingroup Group_PipeStreamRW\r
+ *\r
+ * \param[out] Buffer Pointer to the source data buffer to write to.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param[in] Callback Name of a callback routine to call between successive USB packet transfers, NULL if no callback\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_EStream_BE(void* Buffer, uint16_t Length _CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
/* Private Interface - For use in library only: */\r
#if !defined(__DOXYGEN__)\r
/* Macros: */\r