#define __PIPE_H__\r
\r
/* Includes: */\r
- #if defined(__AVR32__)\r
- #include <avr32/io.h>\r
- #include <stdint.h>\r
- #include <stdbool.h>\r
- #elif defined(__AVR__)\r
- #include <avr/io.h>\r
- #include <avr/pgmspace.h>\r
- #include <avr/eeprom.h>\r
- #include <stdbool.h>\r
- #endif\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
- #include "LowLevel.h"\r
#include "../HighLevel/USBTask.h"\r
\r
#if !defined(NO_STREAM_CALLBACKS) || defined(__DOXYGEN__)\r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
#endif\r
\r
- #if defined(__AVR32__) && !defined(__AVR32_EPREG_X)\r
- #define __AVR32_EPREG_X(x) ((volatile uint32_t*)AVR32_USBB_ ## x)[USB_SelectedEPNumber] \r
- #endif\r
-\r
/* Public Interface - May be used in end-application: */\r
/* Macros: */\r
/** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */\r
static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline uint8_t Pipe_Read_Byte(void)\r
{\r
- #if defined(__AVR32__)\r
- return __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
return UPDATX;\r
- #endif\r
}\r
\r
/** Writes one byte from the currently selected pipe's bank, for IN direction pipes.\r
static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_Write_Byte(const uint8_t Byte)\r
{\r
- #if defined(__AVR32__)\r
- __AVR32_EPREG_X(UEDAT0) = Byte;\r
- #elif defined(__AVR__)\r
UPDATX = Byte;\r
- #endif\r
}\r
\r
/** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.\r
{\r
uint8_t Dummy;\r
\r
- #if defined(__AVR32__)\r
- Dummy = __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
Dummy = UPDATX;\r
- #endif\r
}\r
\r
/** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT\r
uint8_t Bytes[2];\r
} Data;\r
\r
- #if defined(__AVR32__)\r
- Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);\r
- Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
Data.Bytes[0] = UPDATX;\r
Data.Bytes[1] = UPDATX;\r
- #endif\r
\r
return Data.Word;\r
}\r
uint8_t Bytes[2];\r
} Data;\r
\r
- #if defined(__AVR32__)\r
- Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);\r
- Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
Data.Bytes[1] = UPDATX;\r
Data.Bytes[0] = UPDATX;\r
- #endif\r
\r
return Data.Word;\r
}\r
static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_Write_Word_LE(const uint16_t Word)\r
{\r
- #if defined(__AVR32__)\r
- __AVR32_EPREG_X(UEDAT0) = (Word & 0xFF);\r
- __AVR32_EPREG_X(UEDAT0) = (Word >> 8);\r
- #elif defined(__AVR__)\r
UPDATX = (Word & 0xFF);\r
UPDATX = (Word >> 8);\r
- #endif\r
}\r
\r
/** Writes two bytes to the currently selected pipe's bank in big endian format, for IN\r
static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_Write_Word_BE(const uint16_t Word)\r
{\r
- #if defined(__AVR32__)\r
- __AVR32_EPREG_X(UEDAT0) = (Word >> 8);\r
- __AVR32_EPREG_X(UEDAT0) = (Word & 0xFF);\r
- #elif defined(__AVR__)\r
UPDATX = (Word >> 8);\r
UPDATX = (Word & 0xFF);\r
- #endif\r
}\r
\r
/** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.\r
{\r
uint8_t Dummy;\r
\r
- #if defined(__AVR32__)\r
- Dummy = __AVR32_EPREG_X(UEDAT0);\r
- Dummy = __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
Dummy = UPDATX;\r
Dummy = UPDATX;\r
- #endif\r
}\r
\r
/** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT\r
uint8_t Bytes[4];\r
} Data;\r
\r
- #if defined(__AVR32__)\r
- Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);\r
- Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);\r
- Data.Bytes[2] = __AVR32_EPREG_X(UEDAT0);\r
- Data.Bytes[3] = __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
Data.Bytes[0] = UPDATX;\r
Data.Bytes[1] = UPDATX;\r
Data.Bytes[2] = UPDATX;\r
Data.Bytes[3] = UPDATX;\r
- #endif\r
\r
return Data.DWord;\r
}\r
uint8_t Bytes[4];\r
} Data;\r
\r
- #if defined(__AVR32__)\r
- Data.Bytes[3] = __AVR32_EPREG_X(UEDAT0);\r
- Data.Bytes[2] = __AVR32_EPREG_X(UEDAT0);\r
- Data.Bytes[1] = __AVR32_EPREG_X(UEDAT0);\r
- Data.Bytes[0] = __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
Data.Bytes[3] = UPDATX;\r
Data.Bytes[2] = UPDATX;\r
Data.Bytes[1] = UPDATX;\r
Data.Bytes[0] = UPDATX;\r
- #endif\r
\r
return Data.DWord;\r
}\r
static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_Write_DWord_LE(const uint32_t DWord)\r
{\r
- #if defined(__AVR32__)\r
- __AVR32_EPREG_X(UEDAT0) = (DWord & 0xFF);\r
- __AVR32_EPREG_X(UEDAT0) = (DWord >> 8);\r
- __AVR32_EPREG_X(UEDAT0) = (DWord >> 16);\r
- __AVR32_EPREG_X(UEDAT0) = (DWord >> 24);\r
- #elif defined(__AVR__)\r
UPDATX = (DWord & 0xFF);\r
UPDATX = (DWord >> 8);\r
UPDATX = (DWord >> 16);\r
UPDATX = (DWord >> 24);\r
- #endif\r
}\r
\r
/** Writes four bytes to the currently selected pipe's bank in big endian format, for IN\r
static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_Write_DWord_BE(const uint32_t DWord)\r
{\r
- #if defined(__AVR32__)\r
- __AVR32_EPREG_X(UEDAT0) = (DWord >> 24);\r
- __AVR32_EPREG_X(UEDAT0) = (DWord >> 16);\r
- __AVR32_EPREG_X(UEDAT0) = (DWord >> 8);\r
- __AVR32_EPREG_X(UEDAT0) = (DWord & 0xFF);\r
- #elif defined(__AVR__)\r
UPDATX = (DWord >> 24);\r
UPDATX = (DWord >> 16);\r
UPDATX = (DWord >> 8);\r
UPDATX = (DWord & 0xFF);\r
- #endif\r
} \r
\r
/** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes. \r
{\r
uint8_t Dummy;\r
\r
- #if defined(__AVR32__)\r
- Dummy = __AVR32_EPREG_X(UEDAT0);\r
- Dummy = __AVR32_EPREG_X(UEDAT0);\r
- Dummy = __AVR32_EPREG_X(UEDAT0);\r
- Dummy = __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
Dummy = UPDATX;\r
Dummy = UPDATX;\r
Dummy = UPDATX;\r
Dummy = UPDATX;\r
- #endif\r
}\r
\r
/* External Variables: */\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
- * \note Not available on AVR32 UC3B targets.\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
* \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
- * \note Not available on AVR32 UC3B targets.\r
- *\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
* \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
- * \note Not available on AVR32 UC3B targets.\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
* \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
- * \note Not available on AVR32 UC3B targets.\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
void Pipe_ClearPipes(void);\r
\r
/* Inline Functions: */\r
- static inline uintN_t Pipe_BytesToEPSizeMask(uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;\r
- static inline uintN_t Pipe_BytesToEPSizeMask(uint16_t Bytes)\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(uint16_t Bytes)\r
{\r
- #if defined(__AVR32__)\r
- // TODO\r
- return 0;\r
- #elif defined(__AVR__)\r
if (Bytes <= 8)\r
return (0 << EPSIZE0);\r
else if (Bytes <= 16)\r
return (4 << EPSIZE0);\r
else\r
return (5 << EPSIZE0);\r
- #endif\r
}\r
\r
#endif\r