#define __ENDPOINT_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
- \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
- #if defined(__AVR32__) || defined(__DOXYGEN__)\r
- /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
- * should be initialized in the OUT direction - i.e. data flows from host to device.\r
- */\r
- #define ENDPOINT_DIR_OUT 0\r
+ /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
+ * should be initialized in the OUT direction - i.e. data flows from host to device.\r
+ */\r
+ #define ENDPOINT_DIR_OUT (0 << EPDIR)\r
\r
- /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
- * should be initialized in the IN direction - i.e. data flows from device to host.\r
- */\r
- #define ENDPOINT_DIR_IN AVR32_USBB_EPDIR_IN\r
+ /** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint\r
+ * should be initialized in the IN direction - i.e. data flows from device to host.\r
+ */\r
+ #define ENDPOINT_DIR_IN (1 << EPDIR)\r
\r
- /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates\r
- * that the endpoint should have one single bank, which requires less USB FIFO memory but results\r
- * in slower transfers as only one USB device (the AVR or the host) can access the endpoint's\r
- * bank at the one time.\r
- */\r
- #define ENDPOINT_BANK_SINGLE AVR32_USBB_EPBK_SINGLE\r
- \r
- /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates\r
- * that the endpoint should have two banks, which requires more USB FIFO memory but results\r
- * in faster transfers as one USB device (the AVR or the host) can access one bank while the other\r
- * accesses the second bank.\r
- */\r
- #define ENDPOINT_BANK_DOUBLE AVR32_USBB_EPBK_DOUBLE\r
- #elif defined(__AVR__)\r
- #define ENDPOINT_DIR_OUT (0 << EPDIR)\r
- #define ENDPOINT_DIR_IN (1 << EPDIR)\r
- #define ENDPOINT_BANK_SINGLE (0 << EPBK0)\r
- #define ENDPOINT_BANK_DOUBLE (1 << EPBK0) \r
- #endif\r
+ /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates\r
+ * that the endpoint should have one single bank, which requires less USB FIFO memory but results\r
+ * in slower transfers as only one USB device (the AVR or the host) can access the endpoint's\r
+ * bank at the one time.\r
+ */\r
+ #define ENDPOINT_BANK_SINGLE (0 << EPBK0)\r
+\r
+ /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates\r
+ * that the endpoint should have two banks, which requires more USB FIFO memory but results\r
+ * in faster transfers as one USB device (the AVR or the host) can access one bank while the other\r
+ * accesses the second bank.\r
+ */\r
+ #define ENDPOINT_BANK_DOUBLE (1 << EPBK0)\r
\r
/** Endpoint address for the default control endpoint, which always resides in address 0. This is\r
* defined for convenience to give more readable code when used with the endpoint macros.\r
#define ENDPOINT_DOUBLEBANK_SUPPORTED(n) _ENDPOINT_GET_DOUBLEBANK(n)\r
\r
#if !defined(CONTROL_ONLY_DEVICE)\r
- #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || \\r
- defined(USB_SERIES_UC3B_AVR) || defined(__DOXYGEN__))\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)\r
/** Total number of endpoints (including the default control endpoint at address 0) which may\r
* be used in the device. Different USB AVR models support different amounts of endpoints,\r
* this value reflects the maximum number of endpoints for the currently selected AVR model.\r
*/\r
- #define ENDPOINT_TOTAL_ENDPOINTS 7\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 7\r
#else\r
- #define ENDPOINT_TOTAL_ENDPOINTS 5 \r
+ #define ENDPOINT_TOTAL_ENDPOINTS 5 \r
#endif\r
#else\r
- #define ENDPOINT_TOTAL_ENDPOINTS 1\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 1\r
#endif\r
\r
/* Pseudo-Function Macros: */\r
#define Endpoint_BytesInEndpoint() (((uint16_t)UEBCHX << 8) | UEBCLX) \r
#elif defined(USB_SERIES_2_AVR)\r
#define Endpoint_BytesInEndpoint() UEBCLX\r
- #elif defined(USB_SERIES_UC3B_AVR)\r
- #define Endpoint_BytesInEndpoint() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_BYCT_MASK) >> AVR32_USBB_BYCT)\r
#endif\r
\r
- #if defined(__AVR32__)\r
- #if !defined(CONTROL_ONLY_DEVICE)\r
- #define Endpoint_GetCurrentEndpoint() USB_SelectedEPNumber\r
- #define Endpoint_SelectEndpoint(epnum) MACROS{ USB_SelectedEPNumber = (epnum); }MACROE \r
- #define Endpoint_IsReadWriteAllowed() (__AVR32_EPREG_X(UESTA0) & AVR32_USBB_RWALL_MASK)\r
- #else\r
- #define Endpoint_GetCurrentEndpoint() ENDPOINT_CONTROLEP\r
- #define Endpoint_SelectEndpoint(epnum) (void)(epnum)\r
- #endif\r
-\r
- #define Endpoint_ResetFIFO(epnum) MACROS{ AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_MASK << (epnum)); \\r
- AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_MASK << (epnum)); }MACROE\r
- #define Endpoint_EnableEndpoint() MACROS{ AVR32_USBB.uerst |= (AVR32_USBB_UERST_EPEN0_MASK << USB_SelectedEPNumber); }MACROE\r
- #define Endpoint_DisableEndpoint() MACROS{ AVR32_USBB.uerst &= ~(AVR32_USBB_UERST_EPEN0_MASK << USB_SelectedEPNumber); }MACROE\r
- #define Endpoint_IsEnabled() ((AVR32_USBB.uerst & (AVR32_USBB_UERST_EPEN0_MASK << USB_SelectedEPNumber)) ? true : false)\r
- \r
- #define Endpoint_IsConfigured() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_UESTA0_CFGOK_MASK) ? true : false)\r
- #define Endpoint_GetEndpointInterrupts() (AVR32_USBB.UDINT >> AVR32_USBB_EP0INT)\r
- #define Endpoint_HasEndpointInterrupted(n) ((AVR32_USBB.UDINT & (AVR32_USBB_EP0INT << (n))) ? true : false)\r
- #define Endpoint_IsINReady() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_TXINI) ? true : false)\r
- #define Endpoint_IsOUTReceived() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_RXOUTI) ? true : false)\r
- #define Endpoint_IsSETUPReceived() ((__AVR32_EPREG_X(UESTA0) & AVR32_USBB_RXSTPI) ? true : false)\r
- #define Endpoint_ClearSETUP() MACROS{ __AVR32_EPREG_X(UESTA0CLR) = AVR32_USBB_RXSTPIC; }MACROE\r
- #define Endpoint_ClearIN() MACROS{ __AVR32_EPREG_X(UESTA0CLR) = AVR32_USBB_TXINIC; \\r
- __AVR32_EPREG_X(UECON0CLR) = AVR32_USBB_FIFOCONC; }MACROE\r
- #define Endpoint_ClearOUT() MACROS{ __AVR32_EPREG_X(UESTA0CLR) = AVR32_USBB_RXOUTI; \\r
- __AVR32_EPREG_X(UECON0CLR) = AVR32_USBB_FIFOCONC; }MACROE\r
- #define Endpoint_StallTransaction() MACROS{ __AVR32_EPREG_X(UECON0SET) = AVR32_USBB_STALLRQS; }MACROE\r
- #define Endpoint_ClearStall() MACROS{ __AVR32_EPREG_X(UECON0CLR) = AVR32_USBB_STALLRQC; }MACROE\r
- #define Endpoint_IsStalled() ((__AVR32_EPREG_X(UECON0) & AVR32_USBB_STALLRQ) ? true : false)\r
- #define Endpoint_ResetDataToggle() MACROS{ __AVR32_EPREG_X(UECON0CLR) = AVR32_USBB_RSTDTS; }MACROE\r
- #define Endpoint_GetEndpointDirection() ((__AVR32_EPREG_X(UECFG0) & ENDPOINT_DIR_IN) ? true : false)\r
- #define Endpoint_SetEndpointDirection(dir) MACROS{ __AVR32_EPREG_X(UECFG0) = \\r
- ((__AVR32_EPREG_X(UECFG0) & ENDPOINT_DIR_IN) | (dir)); }MACROE\r
- #elif defined(__AVR__)\r
- #if !defined(CONTROL_ONLY_DEVICE)\r
- #define Endpoint_GetCurrentEndpoint() (UENUM & ENDPOINT_EPNUM_MASK)\r
- #define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = (epnum); }MACROE\r
- #define Endpoint_IsReadWriteAllowed() ((UEINTX & (1 << RWAL)) ? true : false)\r
- #else\r
- #define Endpoint_GetCurrentEndpoint() ENDPOINT_CONTROLEP\r
- #define Endpoint_SelectEndpoint(epnum) (void)(epnum)\r
- #endif\r
-\r
- #define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << (epnum)); UERST = 0; }MACROE\r
- #define Endpoint_EnableEndpoint() MACROS{ UECONX |= (1 << EPEN); }MACROE\r
- #define Endpoint_DisableEndpoint() MACROS{ UECONX &= ~(1 << EPEN); }MACROE\r
- #define Endpoint_IsEnabled() ((UECONX & (1 << EPEN)) ? true : false)\r
- \r
- #define Endpoint_IsConfigured() ((UESTA0X & (1 << CFGOK)) ? true : false)\r
- #define Endpoint_GetEndpointInterrupts() UEINT\r
- #define Endpoint_HasEndpointInterrupted(n) ((UEINT & (1 << (n))) ? true : false)\r
- #define Endpoint_IsINReady() ((UEINTX & (1 << TXINI)) ? true : false)\r
- #define Endpoint_IsOUTReceived() ((UEINTX & (1 << RXOUTI)) ? true : false)\r
- #define Endpoint_IsSETUPReceived() ((UEINTX & (1 << RXSTPI)) ? true : false)\r
- #define Endpoint_ClearSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE\r
-\r
- #if !defined(CONTROL_ONLY_DEVICE)\r
- #define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \\r
- UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
- #define Endpoint_ClearOUT() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \\r
- UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
- #else\r
- #define Endpoint_ClearIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE\r
- #define Endpoint_ClearOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE \r
- #endif\r
-\r
- #define Endpoint_StallTransaction() MACROS{ UECONX |= (1 << STALLRQ); }MACROE\r
- #define Endpoint_ClearStall() MACROS{ UECONX |= (1 << STALLRQC); }MACROE\r
- #define Endpoint_IsStalled() ((UECONX & (1 << STALLRQ)) ? true : false)\r
- #define Endpoint_ResetDataToggle() MACROS{ UECONX |= (1 << RSTDT); }MACROE\r
- #define Endpoint_GetEndpointDirection() (UECFG0X & ENDPOINT_DIR_IN)\r
- #define Endpoint_SetEndpointDirection(dir) MACROS{ UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | (dir)); }MACROE \r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ #define Endpoint_GetCurrentEndpoint() (UENUM & ENDPOINT_EPNUM_MASK)\r
+ #else\r
+ #define Endpoint_GetCurrentEndpoint() ENDPOINT_CONTROLEP\r
#endif\r
+ \r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ #define Endpoint_SelectEndpoint(epnum) MACROS{ UENUM = (epnum); }MACROE\r
+ #else\r
+ #define Endpoint_SelectEndpoint(epnum) (void)(epnum)\r
+ #endif\r
+\r
+ #define Endpoint_ResetFIFO(epnum) MACROS{ UERST = (1 << (epnum)); UERST = 0; }MACROE\r
+\r
+ #define Endpoint_EnableEndpoint() MACROS{ UECONX |= (1 << EPEN); }MACROE\r
+\r
+ #define Endpoint_DisableEndpoint() MACROS{ UECONX &= ~(1 << EPEN); }MACROE\r
+\r
+ #define Endpoint_IsEnabled() ((UECONX & (1 << EPEN)) ? true : false)\r
+\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ #define Endpoint_IsReadWriteAllowed() ((UEINTX & (1 << RWAL)) ? true : false)\r
+ #endif\r
+ \r
+ #define Endpoint_IsConfigured() ((UESTA0X & (1 << CFGOK)) ? true : false)\r
+\r
+ #define Endpoint_GetEndpointInterrupts() UEINT\r
+\r
+ #define Endpoint_HasEndpointInterrupted(n) ((UEINT & (1 << (n))) ? true : false)\r
+ \r
+ #define Endpoint_IsINReady() ((UEINTX & (1 << TXINI)) ? true : false)\r
+ \r
+ #define Endpoint_IsOUTReceived() ((UEINTX & (1 << RXOUTI)) ? true : false)\r
+\r
+ #define Endpoint_IsSETUPReceived() ((UEINTX & (1 << RXSTPI)) ? true : false)\r
+\r
+ #define Endpoint_ClearSETUP() MACROS{ UEINTX &= ~(1 << RXSTPI); }MACROE\r
+\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ #define Endpoint_ClearIN() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << TXINI)); \\r
+ UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
+ #else\r
+ #define Endpoint_ClearIN() MACROS{ UEINTX &= ~(1 << TXINI); }MACROE\r
+ #endif\r
+\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ #define Endpoint_ClearOUT() MACROS{ uint8_t Temp = UEINTX; UEINTX = (Temp & ~(1 << RXOUTI)); \\r
+ UEINTX = (Temp & ~(1 << FIFOCON)); }MACROE\r
+ #else\r
+ #define Endpoint_ClearOUT() MACROS{ UEINTX &= ~(1 << RXOUTI); }MACROE \r
+ #endif\r
+\r
+ #define Endpoint_StallTransaction() MACROS{ UECONX |= (1 << STALLRQ); }MACROE\r
+\r
+ #define Endpoint_ClearStall() MACROS{ UECONX |= (1 << STALLRQC); }MACROE\r
+\r
+ #define Endpoint_IsStalled() ((UECONX & (1 << STALLRQ)) ? true : false)\r
+\r
+ #define Endpoint_ResetDataToggle() MACROS{ UECONX |= (1 << RSTDT); }MACROE\r
+ \r
+ #define Endpoint_GetEndpointDirection() (UECFG0X & ENDPOINT_DIR_IN)\r
+ \r
+ #define Endpoint_SetEndpointDirection(dir) MACROS{ UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | (dir)); }MACROE\r
#endif\r
\r
/* Enums: */\r
static inline uint8_t Endpoint_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline uint8_t Endpoint_Read_Byte(void)\r
{\r
- #if defined(__AVR32__)\r
- return __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
return UEDATX;\r
- #endif\r
}\r
\r
/** Writes one byte from the currently selected endpoint's bank, for IN direction endpoints.\r
static inline void Endpoint_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
static inline void Endpoint_Write_Byte(const uint8_t Byte)\r
{\r
- #if defined(__AVR32__)\r
- __AVR32_EPREG_X(UEDAT0) = Byte;\r
- #elif defined(__AVR__)\r
UEDATX = Byte;\r
- #endif\r
}\r
\r
/** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
{\r
uint8_t Dummy;\r
\r
- #if defined(__AVR32__)\r
- Dummy = __AVR32_EPREG_X(UEDAT0);\r
- #elif defined(__AVR__)\r
Dummy = UEDATX;\r
- #endif\r
}\r
\r
/** Reads two bytes from the currently selected endpoint'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] = UEDATX;\r
Data.Bytes[1] = UEDATX;\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] = UEDATX;\r
Data.Bytes[0] = UEDATX;\r
- #endif\r
\r
return Data.Word;\r
}\r
static inline void Endpoint_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
static inline void Endpoint_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
UEDATX = (Word & 0xFF);\r
UEDATX = (Word >> 8);\r
- #endif\r
}\r
\r
/** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN\r
static inline void Endpoint_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;\r
static inline void Endpoint_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
UEDATX = (Word >> 8);\r
UEDATX = (Word & 0xFF);\r
- #endif\r
}\r
\r
/** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.\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 = UEDATX;\r
Dummy = UEDATX;\r
- #endif\r
}\r
\r
/** Reads four bytes from the currently selected endpoint'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] = UEDATX;\r
Data.Bytes[1] = UEDATX;\r
Data.Bytes[2] = UEDATX;\r
Data.Bytes[3] = UEDATX;\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] = UEDATX;\r
Data.Bytes[2] = UEDATX;\r
Data.Bytes[1] = UEDATX;\r
Data.Bytes[0] = UEDATX;\r
- #endif\r
\r
return Data.DWord;\r
}\r
static inline void Endpoint_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
static inline void Endpoint_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
UEDATX = (DWord & 0xFF);\r
UEDATX = (DWord >> 8);\r
UEDATX = (DWord >> 16);\r
UEDATX = (DWord >> 24);\r
- #endif\r
}\r
\r
/** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN\r
static inline void Endpoint_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;\r
static inline void Endpoint_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
UEDATX = (DWord >> 24);\r
UEDATX = (DWord >> 16);\r
UEDATX = (DWord >> 8);\r
UEDATX = (DWord & 0xFF);\r
- #endif\r
}\r
\r
/** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints. \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 = UEDATX;\r
Dummy = UEDATX;\r
Dummy = UEDATX;\r
Dummy = UEDATX;\r
- #endif\r
}\r
\r
/* External Variables: */\r
* endpoint numbers can handle different maximum packet sizes - refer to the chosen USB AVR's\r
* datasheet to determine the maximum bank size for each endpoint.\r
*\r
- * The banking mode must be a ENDPOINT_BANK_* mask.\r
+ * The banking mode may be either \ref ENDPOINT_BANK_SINGLE or \ref ENDPOINT_BANK_DOUBLE.\r
*\r
* \note The default control endpoint does not have to be manually configured, as it is automatically\r
* configured by the library internally.\r
*\r
* \return Boolean true if the configuration succeeded, false otherwise\r
*/\r
- bool Endpoint_ConfigureEndpoint(const uintN_t Number, const uintN_t Type, const uintN_t Direction,\r
- const uint16_t Size, const uintN_t Banks);\r
+ bool Endpoint_ConfigureEndpoint(const uint8_t Number, const uint8_t Type, const uint8_t Direction,\r
+ const uint16_t Size, const uint8_t Banks);\r
\r
/** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data\r
* to be read or written to it.\r
* \param[in] Length Number of bytes to read for the currently selected endpoint 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 Endpoint_Stream_RW_ErrorCodes_t enum.\r
*/\r
uint8_t Endpoint_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 endpoint 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 Endpoint_Stream_RW_ErrorCodes_t enum.\r
*/\r
uint8_t Endpoint_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 send via the currently selected endpoint.\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 Endpoint_Stream_RW_ErrorCodes_t enum.\r
*/\r
uint8_t Endpoint_Read_EStream_LE(void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\r
* \param[in] Length Number of bytes to send via the currently selected endpoint.\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 Endpoint_Stream_RW_ErrorCodes_t enum.\r
*/\r
uint8_t Endpoint_Read_EStream_BE(void* Buffer, uint16_t Length __CALLBACK_PARAM) ATTR_NON_NULL_PTR_ARG(1);\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 endpoint into the buffer.\r
*\r
- * \note Not available on AVR32 UC3B targets.\r
- *\r
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
*/\r
uint8_t Endpoint_Write_Control_EStream_LE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\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 endpoint into the buffer.\r
*\r
- * \note Not available on AVR32 UC3B targets.\r
- *\r
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
*/\r
uint8_t Endpoint_Write_Control_EStream_BE(const void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
* \param[out] Buffer Pointer to the destination data buffer to write to.\r
* \param[in] Length Number of bytes to send via the currently selected endpoint.\r
*\r
- * \note Not available on AVR32 UC3B targets.\r
- *\r
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
*/\r
uint8_t Endpoint_Read_Control_EStream_LE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
* \param[out] Buffer Pointer to the destination data buffer to write to.\r
* \param[in] Length Number of bytes to send via the currently selected endpoint.\r
*\r
- * \note Not available on AVR32 UC3B targets.\r
- *\r
* \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
*/\r
uint8_t Endpoint_Read_Control_EStream_BE(void* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1); \r
/* Private Interface - For use in library only: */\r
#if !defined(__DOXYGEN__)\r
/* Macros: */\r
- #if defined(__AVR32__)\r
- #define Endpoint_AllocateMemory() MACROS{ __AVR32_EPREG_X(UECFG10) |= AVR32_USBB_UECFG0_ALLOC_MASK; }MACROE\r
- #define Endpoint_DeallocateMemory() MACROS{ __AVR32_EPREG_X(UECFG10) &= ~AVR32_USBB_UECFG0_ALLOC_MASK; }MACROE\r
-\r
- #define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \\r
- Endpoint_ConfigureEndpoint_Prv((Number), \\r
- (((Type) << AVR32_USBB_UECFG0_EPTYPE) | (Direction)), \\r
- (AVR32_USBB_UECFG0_ALLOC_MASK | (Banks) | \\r
- (__builtin_constant_p(Size) ? \\r
- Endpoint_BytesToEPSizeMask(Size) : \\r
- Endpoint_BytesToEPSizeMaskDynamic(Size))))\r
- #elif defined(__AVR__)\r
- #define Endpoint_AllocateMemory() MACROS{ UECFG1X |= (1 << ALLOC); }MACROE\r
- #define Endpoint_DeallocateMemory() MACROS{ UECFG1X &= ~(1 << ALLOC); }MACROE\r
-\r
- #define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \\r
- Endpoint_ConfigureEndpoint_Prv((Number), \\r
- (((Type) << EPTYPE0) | (Direction)), \\r
- ((1 << ALLOC) | (Banks) | \\r
- (__builtin_constant_p(Size) ? \\r
- Endpoint_BytesToEPSizeMask(Size) : \\r
- Endpoint_BytesToEPSizeMaskDynamic(Size))))\r
- #endif\r
+ #define Endpoint_AllocateMemory() MACROS{ UECFG1X |= (1 << ALLOC); }MACROE\r
+ #define Endpoint_DeallocateMemory() MACROS{ UECFG1X &= ~(1 << ALLOC); }MACROE\r
\r
#define _ENDPOINT_GET_MAXSIZE(n) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## n)\r
#define _ENDPOINT_GET_MAXSIZE2(details) _ENDPOINT_GET_MAXSIZE3(details)\r
#define ENDPOINT_DETAILS_EP4 64, true\r
#define ENDPOINT_DETAILS_EP5 64, true\r
#define ENDPOINT_DETAILS_EP6 64, true\r
- #elif defined(USB_SERIES_UC3B_AVR)\r
- #define ENDPOINT_DETAILS_EP0 64, false\r
- #define ENDPOINT_DETAILS_EP1 64, true\r
- #define ENDPOINT_DETAILS_EP2 64, true\r
- #define ENDPOINT_DETAILS_EP3 64, true\r
- #define ENDPOINT_DETAILS_EP4 64, true\r
- #define ENDPOINT_DETAILS_EP5 256, true\r
- #define ENDPOINT_DETAILS_EP6 256, true \r
- #elif defined(USB_SERIES_2_AVR)\r
+ #else\r
#define ENDPOINT_DETAILS_EP0 64, true\r
#define ENDPOINT_DETAILS_EP1 64, false\r
#define ENDPOINT_DETAILS_EP2 64, false\r
#define ENDPOINT_DETAILS_EP4 64, true \r
#endif\r
\r
+ #define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks) \\r
+ Endpoint_ConfigureEndpoint_Prv((Number), \\r
+ (((Type) << EPTYPE0) | (Direction)), \\r
+ ((1 << ALLOC) | (Banks) | \\r
+ (__builtin_constant_p(Size) ? \\r
+ Endpoint_BytesToEPSizeMask(Size) : \\r
+ Endpoint_BytesToEPSizeMaskDynamic(Size))))\r
+ \r
/* Function Prototypes: */\r
void Endpoint_ClearEndpoints(void);\r
- uintN_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size);\r
- bool Endpoint_ConfigureEndpoint_Prv(const uintN_t Number, const uintN_t UECFG0XData, const uintN_t UECFG1XData);\r
+ uint8_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size);\r
+ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData);\r
\r
/* Inline Functions: */\r
- static inline uintN_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;\r
- static inline uintN_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
{\r
- #if defined(__AVR32__)\r
- uint8_t MaskVal = 0;\r
- uint16_t CheckBytes = 8;\r
- \r
- while (CheckBytes < Bytes)\r
- {\r
- MaskVal++;\r
- CheckBytes <<= 1;\r
- }\r
- \r
- return (MaskVal << AVR32_USBB_EPSIZE);\r
- #else\r
uint8_t MaskVal = 0;\r
uint16_t CheckBytes = 8;\r
\r
}\r
\r
return (MaskVal << EPSIZE0);\r
- #endif\r
}\r
\r
#endif\r