\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */ \r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */ \r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Private Interface - For use in library only: */\r
#if !defined(__DOXYGEN__)\r
/* Macros: */\r
- #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE\r
- #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE\r
- #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE\r
- #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)\r
- #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)\r
+ #if defined(__AVR32__)\r
+ #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE\r
+ #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE\r
+ #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) ## CLR |= USB_INT_GET_INT_MASK(int) ## C; }MACROE\r
+ #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)\r
+ #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)\r
\r
- #define USB_INT_GET_EN_REG(a, b, c, d) a\r
- #define USB_INT_GET_EN_MASK(a, b, c, d) b\r
- #define USB_INT_GET_INT_REG(a, b, c, d) c\r
- #define USB_INT_GET_INT_MASK(a, b, c, d) d\r
+ #define USB_INT_GET_EN_REG(a, b, c, d) *((volatile uint32_t*)AVR32_USBB_ ## a)\r
+ #define USB_INT_GET_EN_MASK(a, b, c, d) AVR32_USBB_ ## b\r
+ #define USB_INT_GET_INT_REG(a, b, c, d) *((volatile uint32_t*)AVR32_USBB_ ## c)\r
+ #define USB_INT_GET_INT_MASK(a, b, c, d) AVR32_USBB_ ## d\r
\r
- #define USB_INT_VBUS USBCON, (1 << VBUSTE) , USBINT, (1 << VBUSTI)\r
- #define USB_INT_IDTI USBCON, (1 << IDTE) , USBINT, (1 << IDTI)\r
- #define USB_INT_WAKEUP UDIEN , (1 << WAKEUPE), UDINT , (1 << WAKEUPI)\r
- #define USB_INT_SUSPEND UDIEN , (1 << SUSPE) , UDINT , (1 << SUSPI)\r
- #define USB_INT_EORSTI UDIEN , (1 << EORSTE) , UDINT , (1 << EORSTI)\r
- #define USB_INT_DCONNI UHIEN , (1 << DCONNE) , UHINT , (1 << DCONNI)\r
- #define USB_INT_DDISCI UHIEN , (1 << DDISCE) , UHINT , (1 << DDISCI)\r
- #define USB_INT_BCERRI OTGIEN, (1 << BCERRE) , OTGINT, (1 << BCERRI)\r
- #define USB_INT_VBERRI OTGIEN, (1 << VBERRE) , OTGINT, (1 << VBERRI)\r
- #define USB_INT_SOFI UDIEN, (1 << SOFE) , UDINT , (1 << SOFI)\r
- #define USB_INT_HSOFI UHIEN, (1 << HSOFE) , UHINT , (1 << HSOFI)\r
- #define USB_INT_RSTI UHIEN , (1 << RSTE) , UHINT , (1 << RSTI)\r
- #define USB_INT_SRPI OTGIEN, (1 << SRPE) , OTGINT, (1 << SRPI)\r
- #define USB_INT_RXSTPI UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI)\r
+ #define USB_INT_VBUS USBCON, USBCON_VBUSTE_MASK, USBSTA, USBSTA_VBUSTI_MASK\r
+ #define USB_INT_IDTI USBCON, USBCON_IDTE_MASK , USBINT, USBCON_IDTI_MASK\r
+ #define USB_INT_WAKEUP UDIEN , UDIEN_WAKEUPE_MASK, UDINT , UDIEN_WAKEUPI_MASK\r
+ #define USB_INT_SUSPEND UDIEN , UDIEN_SUSPE_MASK , UDINT , UDIEN_SUSPI_MASK\r
+ #define USB_INT_EORSTI UDIEN , UDIEN_EORSTE_MASK , UDINT , UDIEN_EORSTI_MASK\r
+ #define USB_INT_SOFI UDIEN, UDIEN_SOFE_MASK , UDINT , UDIEN_SOFI_MASK\r
+ #define USB_INT_DCONNI UHIEN , UDIEN_DCONNE_MASK , UHINT , UHIEN_DCONNI_MASK\r
+ #define USB_INT_DDISCI UHIEN , UDIEN_DDISCE_MASK , UHINT , UHIEN_DDISCI_MASK\r
+ #define USB_INT_HSOFI UHIEN, UHIEN_HSOFE_MASK , UHINT , UHIEN_HSOFI_MASK\r
+ #define USB_INT_RSTI UHIEN , UHIEN_RSTE_MASK , UHINT , UHIEN_RSTI_MASK\r
+ #define USB_INT_RXSTPI UEIENX, UEIENX_RXSTPE_MASK, UEINTX, UEIENX_RXSTPI_MASK \r
+ #define USB_INT_BCERRI OTGIEN, OTGIEN_BCERRE_MASK, OTGINT, OTGIEN_BCERRI_MASK\r
+ #define USB_INT_VBERRI OTGIEN, OTGIEN_VBERRE_MASK, OTGINT, OTGIEN_VBERRI_MASK\r
+ #define USB_INT_SRPI OTGIEN, OTGIEN_SRPE_MASK , OTGINT, OTGIEN_SRPI_MASK\r
+ #elif defined(__AVR__)\r
+ #define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE\r
+ #define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE\r
+ #define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE\r
+ #define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false)\r
+ #define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false)\r
+\r
+ #define USB_INT_GET_EN_REG(a, b, c, d) a\r
+ #define USB_INT_GET_EN_MASK(a, b, c, d) b\r
+ #define USB_INT_GET_INT_REG(a, b, c, d) c\r
+ #define USB_INT_GET_INT_MASK(a, b, c, d) d\r
+\r
+ #define USB_INT_VBUS USBCON, (1 << VBUSTE) , USBINT, (1 << VBUSTI)\r
+ #define USB_INT_IDTI USBCON, (1 << IDTE) , USBINT, (1 << IDTI)\r
+ #define USB_INT_WAKEUP UDIEN , (1 << WAKEUPE), UDINT , (1 << WAKEUPI)\r
+ #define USB_INT_SUSPEND UDIEN , (1 << SUSPE) , UDINT , (1 << SUSPI)\r
+ #define USB_INT_EORSTI UDIEN , (1 << EORSTE) , UDINT , (1 << EORSTI)\r
+ #define USB_INT_SOFI UDIEN, (1 << SOFE) , UDINT , (1 << SOFI)\r
+ #define USB_INT_DCONNI UHIEN , (1 << DCONNE) , UHINT , (1 << DCONNI)\r
+ #define USB_INT_DDISCI UHIEN , (1 << DDISCE) , UHINT , (1 << DDISCI)\r
+ #define USB_INT_HSOFI UHIEN, (1 << HSOFE) , UHINT , (1 << HSOFI)\r
+ #define USB_INT_RSTI UHIEN , (1 << RSTE) , UHINT , (1 << RSTI)\r
+ #define USB_INT_BCERRI OTGIEN, (1 << BCERRE) , OTGINT, (1 << BCERRI)\r
+ #define USB_INT_VBERRI OTGIEN, (1 << VBERRE) , OTGINT, (1 << VBERRI)\r
+ #define USB_INT_SRPI OTGIEN, (1 << SRPE) , OTGINT, (1 << SRPI)\r
+ #define USB_INT_RXSTPI UEIENX, (1 << RXSTPE) , UEINTX, (1 << RXSTPI)\r
+ #endif\r
\r
/* Function Prototypes: */\r
void USB_INT_ClearAllInterrupts(void);\r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
extern USB_Request_Header_t USB_ControlRequest;\r
\r
#if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
- #if !defined(HOST_STATE_AS_GPIOR) || defined(__DOXYGEN__)\r
+ #if (!defined(__AVR32__) && !defined(HOST_STATE_AS_GPIOR)) || defined(__DOXYGEN__)\r
/** Indicates the current host state machine state. When in host mode, this indicates the state\r
* via one of the values of the \ref USB_Host_States_t enum values.\r
*\r
#endif\r
\r
#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
- #if !defined(DEVICE_STATE_AS_GPIOR) || defined(__DOXYGEN__)\r
+ #if (!defined(__AVR32__) && !defined(DEVICE_STATE_AS_GPIOR)) || defined(__DOXYGEN__)\r
/** Indicates the current device state machine state. When in device mode, this indicates the state\r
* via one of the values of the \ref USB_Device_States_t enum values.\r
*\r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
#endif\r
\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
uint8_t USB_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;\r
#endif\r
\r
-uint8_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size)\r
+uintN_t Endpoint_BytesToEPSizeMaskDynamic(const uint16_t Size)\r
{\r
return Endpoint_BytesToEPSizeMask(Size);\r
}\r
\r
-bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, const uint8_t UECFG0XData, const uint8_t UECFG1XData)\r
+bool Endpoint_ConfigureEndpoint_Prv(const uintN_t Number, const uintN_t UECFG0XData, const uintN_t UECFG1XData)\r
{\r
Endpoint_SelectEndpoint(Number);\r
Endpoint_EnableEndpoint();\r
#endif\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.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
/* Macros: */\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 (1 << EPDIR)\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
\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
+ /** 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
\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
+ /** 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
\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) || defined(__DOXYGEN__)\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
/** 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(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
+ #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_RWAL_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 << (epen)); }MACROE\r
+ #define Endpoint_DisableEndpoint() MACROS{ AVR32_USBB.UERST &= ~(AVR32_USBB_UERST_EPEN0_MASK << (epen)); }MACROE\r
+ #define Endpoint_IsEnabled() ((AVR32_USBB.UERST & (AVR32_USBB_UERST_EPEN0_MASK << (epen))) ? 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
#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)\r
{\r
#if defined(__AVR32__)\r
- return 0; // TODO\r
+ return __AVR32_EPREG_X(UEDAT0);\r
#elif defined(__AVR__)\r
return UEDATX;\r
#endif\r
static inline void Endpoint_Write_Byte(const uint8_t Byte)\r
{\r
#if defined(__AVR32__)\r
- // TODO\r
+ __AVR32_EPREG_X(UEDAT0) = Byte;\r
#elif defined(__AVR__)\r
UEDATX = Byte;\r
#endif\r
uint8_t Dummy;\r
\r
#if defined(__AVR32__)\r
- // TODO\r
+ Dummy = __AVR32_EPREG_X(UEDAT0);\r
#elif defined(__AVR__)\r
Dummy = UEDATX;\r
#endif\r
} Data;\r
\r
#if defined(__AVR32__)\r
- // TODO\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
} Data;\r
\r
#if defined(__AVR32__)\r
- // TODO\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
static inline void Endpoint_Write_Word_LE(const uint16_t Word)\r
{\r
#if defined(__AVR32__)\r
- // TODO\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
static inline void Endpoint_Write_Word_BE(const uint16_t Word)\r
{\r
#if defined(__AVR32__)\r
- // TODO\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
uint8_t Dummy;\r
\r
#if defined(__AVR32__)\r
- // TODO\r
+ Dummy = __AVR32_EPREG_X(UEDAT0);\r
+ Dummy = __AVR32_EPREG_X(UEDAT0);\r
#elif defined(__AVR__)\r
Dummy = UEDATX;\r
Dummy = UEDATX;\r
} Data;\r
\r
#if defined(__AVR32__)\r
- // TODO\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;\r
\r
#if defined(__AVR32__)\r
- // TODO\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
static inline void Endpoint_Write_DWord_LE(const uint32_t DWord)\r
{\r
#if defined(__AVR32__)\r
- // TODO\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
static inline void Endpoint_Write_DWord_BE(const uint32_t DWord)\r
{\r
#if defined(__AVR32__)\r
- // TODO\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
uint8_t Dummy;\r
\r
#if defined(__AVR32__)\r
- // TODO\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
* 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 may be either \ref ENDPOINT_BANK_SINGLE or \ref ENDPOINT_BANK_DOUBLE.\r
+ * The banking mode must be a ENDPOINT_BANK_* mask.\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 uint8_t Number, const uint8_t Type, const uint8_t Direction,\r
- const uint16_t Size, const uint8_t Banks);\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
\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
- #define Endpoint_AllocateMemory() MACROS{ UECFG1X |= (1 << ALLOC); }MACROE\r
- #define Endpoint_DeallocateMemory() MACROS{ UECFG1X &= ~(1 << ALLOC); }MACROE\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
\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
- #else\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
#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
- 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
+ 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
\r
/* Inline Functions: */\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
+ 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
{\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
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
*/\r
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void);\r
#else\r
- #define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE\r
-\r
- #define USB_Host_IsBusResetComplete() ((UHCON & (1 << RESET)) ? false : true)\r
-\r
- #define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE \r
-\r
- #define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE \r
- \r
- #define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true)\r
- \r
- #define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false)\r
-\r
- #define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false)\r
-\r
- #define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE\r
-\r
- #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE\r
- \r
- #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true)\r
+ #if defined(__AVR32__)\r
+ #define USB_Host_ResetBus() MACROS{ AVR32_USBB.UHCON.reset = true; }MACROE\r
+ #define USB_Host_IsBusResetComplete() AVR32_USBB.UHCON.reset\r
+ #define USB_Host_ResumeBus() MACROS{ AVR32_USBB.UHCON.sofen = true; }MACROE \r
+ #define USB_Host_SuspendBus() MACROS{ AVR32_USBB.UHCON.sofen = false; }MACROE \r
+ #define USB_Host_IsBusSuspended() AVR32_USBB.UHCON.sofen\r
+ #define USB_Host_IsDeviceFullSpeed() (AVR32_USBB.USBSTA.speed == 0) \r
+ #define USB_Host_IsRemoteWakeupSent() AVR32_USBB.UHINT.rxrsmi\r
+ #define USB_Host_ClearRemoteWakeupSent() MACROS{ AVR32_USBB.UHINTCLR.rxrsmic = true; }MACROE\r
+ #define USB_Host_ResumeFromWakeupRequest() MACROS{ AVR32_USBB.UHCON.resume = true; }MACROE\r
+ #define USB_Host_IsResumeFromWakeupRequestSent() AVR32_USBB.UHCON.resume \r
+ #elif defined(__AVR__)\r
+ #define USB_Host_ResetBus() MACROS{ UHCON |= (1 << RESET); }MACROE\r
+ #define USB_Host_IsBusResetComplete() ((UHCON & (1 << RESET)) ? false : true)\r
+ #define USB_Host_ResumeBus() MACROS{ UHCON |= (1 << SOFEN); }MACROE \r
+ #define USB_Host_SuspendBus() MACROS{ UHCON &= ~(1 << SOFEN); }MACROE \r
+ #define USB_Host_IsBusSuspended() ((UHCON & (1 << SOFEN)) ? false : true)\r
+ #define USB_Host_IsDeviceFullSpeed() ((USBSTA & (1 << SPEED)) ? true : false)\r
+ #define USB_Host_IsRemoteWakeupSent() ((UHINT & (1 << RXRSMI)) ? true : false)\r
+ #define USB_Host_ClearRemoteWakeupSent() MACROS{ UHINT &= ~(1 << RXRSMI); }MACROE\r
+ #define USB_Host_ResumeFromWakeupRequest() MACROS{ UHCON |= (1 << RESUME); }MACROE\r
+ #define USB_Host_IsResumeFromWakeupRequestSent() ((UHCON & (1 << RESUME)) ? false : true)\r
+ #endif\r
#endif\r
\r
/* Function Prototypes: */\r
/* Private Interface - For use in library only: */\r
#if !defined(__DOXYGEN__)\r
/* Macros: */\r
- #define USB_Host_HostMode_On() MACROS{ USBCON |= (1 << HOST); }MACROE\r
- #define USB_Host_HostMode_Off() MACROS{ USBCON &= ~(1 << HOST); }MACROE\r
+ #if defined(__AVR32__)\r
+ #define USB_Host_HostMode_On() MACROS{ AVR32_USBB.USBCON.uimod = false; }MACROE\r
+ #define USB_Host_HostMode_Off() MACROS{ AVR32_USBB.USBCON.uimod = true; }MACROE\r
+\r
+ #define USB_Host_VBUS_Auto_Enable() MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |= (1 << UVCONE); }MACROE\r
+ #define USB_Host_VBUS_Manual_Enable() MACROS{ OTGCON |= (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
+\r
+ #define USB_Host_VBUS_Auto_On() MACROS{ OTGCON |= (1 << VBUSREQ); }MACROE\r
+ #define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE\r
\r
- #define USB_Host_VBUS_Auto_Enable() MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |= (1 << UVCONE); }MACROE\r
- #define USB_Host_VBUS_Manual_Enable() MACROS{ OTGCON |= (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
+ #define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE\r
+ #define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE\r
\r
- #define USB_Host_VBUS_Auto_On() MACROS{ OTGCON |= (1 << VBUSREQ); }MACROE\r
- #define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE\r
+ #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }MACROE \r
+ #elif defined(__AVR__)\r
+ #define USB_Host_HostMode_On() MACROS{ USBCON |= (1 << HOST); }MACROE\r
+ #define USB_Host_HostMode_Off() MACROS{ USBCON &= ~(1 << HOST); }MACROE\r
\r
- #define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE\r
- #define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE\r
+ #define USB_Host_VBUS_Auto_Enable() MACROS{ OTGCON &= ~(1 << VBUSHWC); UHWCON |= (1 << UVCONE); }MACROE\r
+ #define USB_Host_VBUS_Manual_Enable() MACROS{ OTGCON |= (1 << VBUSHWC); UHWCON &= ~(1 << UVCONE); DDRE |= (1 << 7); }MACROE\r
\r
- #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }MACROE\r
+ #define USB_Host_VBUS_Auto_On() MACROS{ OTGCON |= (1 << VBUSREQ); }MACROE\r
+ #define USB_Host_VBUS_Manual_On() MACROS{ PORTE |= (1 << 7); }MACROE\r
\r
+ #define USB_Host_VBUS_Auto_Off() MACROS{ OTGCON |= (1 << VBUSRQC); }MACROE\r
+ #define USB_Host_VBUS_Manual_Off() MACROS{ PORTE &= ~(1 << 7); }MACROE\r
+\r
+ #define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR = ((addr) & 0x7F); }MACROE\r
+ #endif\r
+ \r
/* Enums: */\r
enum USB_Host_WaitMSErrorCodes_t\r
{\r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
volatile uint8_t USB_Options;\r
#endif\r
\r
+#if defined(__AVR32__) && !defined(CONTROL_ONLY_DEVICE)\r
+uint8_t USB_SelectedEPNumber;\r
+#endif\r
+\r
void USB_Init(\r
#if defined(USB_CAN_BE_BOTH)\r
const uint8_t Mode\r
#endif\r
)\r
{\r
+ #if defined(__AVR32__)\r
+ USB_SelectedEPNumber = 0;\r
+ #endif\r
+\r
#if defined(USB_CAN_BE_BOTH)\r
USB_CurrentMode = Mode;\r
#endif\r
#ifndef __USBLOWLEVEL_H__\r
#define __USBLOWLEVEL_H__\r
\r
+ /* External Variables: */\r
+ #if defined(__AVR32__)\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ extern uint8_t USB_SelectedEPNumber;\r
+ #else\r
+ #define USB_SelectedEPNumber 0\r
+ #endif\r
+ #endif\r
+ \r
/* Includes: */\r
#if defined(__AVR32__)\r
#include <avr32/io.h>\r
\r
/* Preprocessor Checks and Defines: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
#if !defined(F_CLOCK)\r
#define USB_Controller_Disable() MACROS{ USBCON &= ~(1 << USBE); }MACROE\r
#define USB_Controller_Reset() MACROS{ const uint8_t Temp = USBCON; USBCON = (Temp & ~(1 << USBE)); \\r
USBCON = (Temp | (1 << USBE)); }MACROE\r
- \r
/* Inline Functions: */\r
#if defined(USB_CAN_BE_BOTH)\r
static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline uint8_t USB_GetUSBModeFromUID(void)\r
{\r
+ #if defined(__AVR32__)\r
+ if (AVR32_USBB.USBSTA.id)\r
+ return USB_MODE_DEVICE;\r
+ else\r
+ return USB_MODE_HOST; \r
+ #elif defined(__AVR__)\r
if (USBSTA & (1 << ID))\r
return USB_MODE_DEVICE;\r
else\r
return USB_MODE_HOST;\r
+ #endif\r
}\r
#endif\r
\r
\r
/* Preprocessor Checks: */\r
#if !defined(__INCLUDE_FROM_USB_DRIVER)\r
- #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
#endif\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.h instead.\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
#endif\r
\r
/* Public Interface - May be used in end-application: */\r
static inline uint8_t Pipe_Read_Byte(void)\r
{\r
#if defined(__AVR32__)\r
- return 0; // TODO\r
+ return __AVR32_EPREG_X(UEDAT0);\r
#elif defined(__AVR__)\r
return UPDATX;\r
#endif\r
static inline void Pipe_Write_Byte(const uint8_t Byte)\r
{\r
#if defined(__AVR32__)\r
- // TODO\r
+ __AVR32_EPREG_X(UEDAT0) = Byte;\r
#elif defined(__AVR__)\r
UPDATX = Byte;\r
#endif\r
uint8_t Dummy;\r
\r
#if defined(__AVR32__)\r
- // TODO\r
+ Dummy = __AVR32_EPREG_X(UEDAT0);\r
#elif defined(__AVR__)\r
Dummy = UPDATX;\r
#endif\r
} Data;\r
\r
#if defined(__AVR32__)\r
- // TODO\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
} Data;\r
\r
#if defined(__AVR32__)\r
- // TODO\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
static inline void Pipe_Write_Word_LE(const uint16_t Word)\r
{\r
#if defined(__AVR32__)\r
- // TODO\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
static inline void Pipe_Write_Word_BE(const uint16_t Word)\r
{\r
#if defined(__AVR32__)\r
- // TODO\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
uint8_t Dummy;\r
\r
#if defined(__AVR32__)\r
- // TODO\r
+ Dummy = __AVR32_EPREG_X(UEDAT0);\r
+ Dummy = __AVR32_EPREG_X(UEDAT0);\r
#elif defined(__AVR__)\r
Dummy = UPDATX;\r
Dummy = UPDATX;\r
} Data;\r
\r
#if defined(__AVR32__)\r
- // TODO\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;\r
\r
#if defined(__AVR32__)\r
- // TODO\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)\r
{\r
#if defined(__AVR32__)\r
- // TODO\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
static inline void Pipe_Write_DWord_BE(const uint32_t DWord)\r
{\r
#if defined(__AVR32__)\r
- // TODO\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
uint8_t Dummy;\r
\r
#if defined(__AVR32__)\r
- // TODO\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
* \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 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
+ 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
{\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
#if !defined(__DOXYGEN__)\r
#define __INCLUDE_FROM_USB_DRIVER\r
#endif\r
+ \r
+ #if defined(__AVR32__)\r
+ #define __AVR32_EPREG_X(x) ((volatile uint32_t*)AVR32_USBB_ ## x)[USB_SelectedEPNumber] \r
+ #endif\r
\r
/* Includes: */\r
#include "HighLevel/USBMode.h"\r
* may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR\r
* reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except\r
* implicitly via the library APIs.\r
+ * \note This compile time option is ignored for the AVR32 UC3B architecture.\r
*\r
* <b>FIXED_NUM_CONFIGURATIONS</b>=<i>x</i> - ( \ref Group_Device ) \n\r
* By default, the library determines the number of configurations a USB device supports by reading the device descriptor. This reduces\r
* may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR\r
* reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except\r
* implicitly via the library APIs.\r
+ * \note This compile time option is ignored for the AVR32 UC3B architecture.\r
*\r
* <b>USB_HOST_TIMEOUT_MS</b>=<i>x</i> - ( \ref Group_Host ) \n\r
* When a control transfer is initiated in host mode to an attached device, a timeout is used to abort the transfer if the attached\r