static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_ResetBus(void)\r
{\r
- AVR32_USBB_UHCON.reset = true;\r
+ AVR32_USBB.UHCON.reset = true;\r
}\r
\r
/** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has\r
static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline bool USB_Host_IsBusResetComplete(void)\r
{\r
- return AVR32_USBB_UHCON.reset;\r
+ return AVR32_USBB.UHCON.reset;\r
}\r
\r
/** Resumes USB communications with an attached and enumerated device, by resuming the transmission\r
static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_ResumeBus(void)\r
{\r
- AVR32_USBB_UHCON.sofe = true;\r
+ AVR32_USBB.UHCON.sofe = true;\r
}\r
\r
/** Suspends the USB bus, preventing any communications from occurring between the host and attached\r
static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_SuspendBus(void)\r
{\r
- AVR32_USBB_UHCON.sofe = false;\r
+ AVR32_USBB.UHCON.sofe = false;\r
}\r
\r
/** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,\r
static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline bool USB_Host_IsBusSuspended(void)\r
{\r
- return AVR32_USBB_UHCON.sofe;\r
+ return AVR32_USBB.UHCON.sofe;\r
}\r
\r
/** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or\r
static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline bool USB_Host_IsDeviceFullSpeed(void)\r
{\r
- return (AVR32_USBB_USBSTA.speed == AVR32_USBB_SPEED_FULL);\r
+ return (AVR32_USBB.USBSTA.speed == AVR32_USBB_SPEED_FULL);\r
}\r
\r
/** Determines if the attached device is currently issuing a Remote Wakeup request, requesting\r
static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline bool USB_Host_IsRemoteWakeupSent(void)\r
{\r
- return AVR32_USBB_UHINT.rxrsmi;\r
+ return AVR32_USBB.UHINT.rxrsmi;\r
}\r
\r
/** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */\r
static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_ClearRemoteWakeupSent(void)\r
{\r
- AVR32_USBB_UHINTCLR.rxrsmic = true;\r
+ AVR32_USBB.UHINTCLR.rxrsmic = true;\r
}\r
\r
/** Accepts a Remote Wakeup request from an attached device. This must be issued in response to\r
static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_ResumeFromWakeupRequest(void)\r
{\r
- AVR32_USBB_UHCON.resume = true;\r
+ AVR32_USBB.UHCON.resume = true;\r
}\r
\r
/** Determines if a resume from Remote Wakeup request is currently being sent to an attached\r
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)\r
{\r
- return AVR32_USBB_UHCON.resume;\r
+ return AVR32_USBB.UHCON.resume;\r
}\r
\r
/* Function Prototypes: */\r
static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_VBUS_Auto_Enable(void)\r
{\r
- AVR32_USBB_USBCON.vbushwc = false;\r
+ AVR32_USBB.USBCON.vbushwc = false;\r
}\r
\r
static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_VBUS_Manual_Enable(void)\r
{\r
- AVR32_USBB_USBCON.vbushwc = true;\r
+ AVR32_USBB.USBCON.vbushwc = true;\r
\r
// TODO: Manual VBUS pin output setup\r
}\r
static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_VBUS_Auto_On(void)\r
{\r
- AVR32_USBB_USBSTASET.vbusreqs = true;\r
+ AVR32_USBB.USBSTASET.vbusrqs = true;\r
}\r
\r
static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_VBUS_Auto_Off(void)\r
{\r
- AVR32_USBB_USBSTACLR.vbusreqc = true;\r
+ AVR32_USBB.USBSTACLR.vbusrqc = true;\r
}\r
\r
static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
static inline void USB_Host_SetDeviceAddress(const uint8_t Address)\r
{\r
- AVR32_USBB_UHADDR1.uhaddrp0 = Address;\r
- AVR32_USBB_UHADDR1.uhaddrp1 = Address;\r
- AVR32_USBB_UHADDR1.uhaddrp2 = Address;\r
- AVR32_USBB_UHADDR1.uhaddrp3 = Address;\r
- AVR32_USBB_UHADDR2.uhaddrp4 = Address;\r
- AVR32_USBB_UHADDR2.uhaddrp5 = Address;\r
- AVR32_USBB_UHADDR2.uhaddrp6 = Address;\r
+ AVR32_USBB.UHADDR1.uhaddr_p0 = Address;\r
+ AVR32_USBB.UHADDR1.uhaddr_p1 = Address;\r
+ AVR32_USBB.UHADDR1.uhaddr_p2 = Address;\r
+ AVR32_USBB.UHADDR1.uhaddr_p3 = Address;\r
+ AVR32_USBB.UHADDR2.uhaddr_p4 = Address;\r
+ AVR32_USBB.UHADDR2.uhaddr_p5 = Address;\r
+ AVR32_USBB.UHADDR2.uhaddr_p6 = Address;\r
}\r
\r
/* Enums: */\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
+ /* External Variables: */\r
+ extern uint8_t USB_SelectedPipe;\r
+ #endif\r
+\r
/* Public Interface - May be used in end-application: */\r
/* Macros: */\r
/** \name Pipe Error Flag Masks */\r
//@{\r
/** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */\r
- #define PIPE_ERRORFLAG_OVERFLOW ((1 << AVR32_USBB_UPSTA0_OVERFI_OFFSET) << 8)\r
-\r
- /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */\r
- #define PIPE_ERRORFLAG_UNDERFLOW ((1 << AVR32_USBB_UPSTA0_UNDERFI_OFFSET) << 8)\r
+ #define PIPE_ERRORFLAG_OVERFLOW (AVR32_USBB_UPSTA0_OVERFI_MASK << 8)\r
\r
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */\r
- #define PIPE_ERRORFLAG_CRC16 (1 << AVR32_USBB_UPERR0_CRC16_OFFSET)\r
+ #define PIPE_ERRORFLAG_CRC16 AVR32_USBB_UPERR0_CRC16_MASK\r
\r
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */\r
- #define PIPE_ERRORFLAG_TIMEOUT (1 << AVR32_USBB_UPERR0_TIMEOUT_OFFSET)\r
+ #define PIPE_ERRORFLAG_TIMEOUT AVR32_USBB_UPERR0_TIMEOUT_MASK\r
\r
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */\r
- #define PIPE_ERRORFLAG_PID (1 << AVR32_USBB_UPERR0_PID_OFFSET)\r
+ #define PIPE_ERRORFLAG_PID AVR32_USBB_UPERR0_PID_MASK\r
\r
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */\r
- #define PIPE_ERRORFLAG_DATAPID (1 << AVR32_USBB_UPERR0_DATAPID_OFFSET)\r
+ #define PIPE_ERRORFLAG_DATAPID AVR32_USBB_UPERR0_DATAPID_MASK\r
\r
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */\r
- #define PIPE_ERRORFLAG_DATATGL (1 << AVR32_USBB_UPERR0_DATATGL_OFFSET)\r
+ #define PIPE_ERRORFLAG_DATATGL AVR32_USBB_UPERR0_DATATGL_MASK\r
//@}\r
\r
/** \name Pipe Token Masks */\r
static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_EnablePipe(void)\r
{\r
- AVR32_USBB.uprst |= (AVR32_USBB_PEN0_MASK << PipeNumber);\r
+ AVR32_USBB.uprst |= (AVR32_USBB_PEN0_MASK << USB_SelectedPipe);\r
}\r
\r
/** Disables the currently selected pipe so that data cannot be sent and received through it to and\r
static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_DisablePipe(void)\r
{\r
- AVR32_USBB.uprst &= ~(AVR32_USBB_PEN0_MASK << PipeNumber);\r
+ AVR32_USBB.uprst &= ~(AVR32_USBB_PEN0_MASK << USB_SelectedPipe);\r
}\r
\r
/** Determines if the currently selected pipe is enabled, but not necessarily configured.\r
static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline bool Pipe_IsEnabled(void)\r
{\r
- return ((AVR32_USBB.uprst & (AVR32_USBB_PEN0_MASK << PipeNumber)) ? true : false);\r
+ return ((AVR32_USBB.uprst & (AVR32_USBB_PEN0_MASK << USB_SelectedPipe)) ? true : false);\r
}\r
\r
/** Gets the current pipe token, indicating the pipe's data direction and type.\r
static inline void Pipe_ClearError(void)\r
{\r
((uint32_t*)AVR32_USBB_UPERR0)[USB_SelectedPipe] = 0;\r
+ ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].overfic = true;\r
}\r
\r
/** Determines if the master pipe error flag is set for the currently selected pipe, indicating that\r
static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline bool Pipe_IsError(void)\r
{\r
- return ((((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].perri) ? true : false);\r
+ return ((((uint32_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe] &\r
+ (AVR32_USBB_PERRI_MASK | AVR32_USBB_OVERFI_MASK)) ? true : false);\r
}\r
\r
/** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This\r
static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline uint8_t Pipe_GetErrorFlags(void)\r
{\r
- return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT |\r
- PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID |\r
- PIPE_ERRORFLAG_DATATGL)) |\r
- (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW)));\r
+ \r
+ return ((((uint32_t*)AVR32_USBB_UPERR0)[USB_SelectedPipe] &\r
+ (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT |\r
+ PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID |\r
+ PIPE_ERRORFLAG_DATATGL)) |\r
+ ((((uint32_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe] << 8) &\r
+ PIPE_ERRORFLAG_OVERFLOW));\r
}\r
\r
/** Retrieves the number of busy banks in the currently selected pipe, which have been queued for\r
static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline bool Pipe_IsOUTReady(void)\r
{\r
- return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxouti;\r
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].txouti;\r
}\r
\r
/** Determines if no SETUP request is currently being sent to the attached device on the selected\r
static inline void Pipe_ClearIN(void)\r
{\r
((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxinic = true;\r
- ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].fifoconc = true;\r
+ ((avr32_usbb_upcon0clr_t*)AVR32_USBB_UPCON0CLR)[USB_SelectedPipe].fifoconc = true;\r
}\r
\r
/** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing\r
static inline void Pipe_ClearOUT(void)\r
{\r
((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].txoutic = true;\r
- ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].fifoconc = true;\r
+ ((avr32_usbb_upcon0clr_t*)AVR32_USBB_UPCON0CLR)[USB_SelectedPipe].fifoconc = true;\r
}\r
\r
/** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on\r
static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
static inline bool Pipe_IsStalled(void)\r
{\r
- return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxstalledi;\r
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxstalldi;\r
}\r
\r
/** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the\r
static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE;\r
static inline void Pipe_ClearStall(void)\r
{\r
- ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxstalledic = true;\r
+ ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxstalldic = true;\r
}\r
\r
/** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.\r
\r
/* Function Prototypes: */\r
void Pipe_ClearPipes(void);\r
-\r
- /* External Variables: */\r
- extern uint8_t USB_SelectedPipe;\r
#endif\r
\r
/* Disable C linkage for C++ Compilers: */\r