aboutsummaryrefslogtreecommitdiffstats
path: root/LUFA/Drivers/USB
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2011-02-26 20:22:33 +0000
committerDean Camera <dean@fourwalledcubicle.com>2011-02-26 20:22:33 +0000
commitcf2411435cf41ca4dbfcc3d89c6287743db79625 (patch)
tree9c68d72e708b6fa86066f644f23e5a8722986984 /LUFA/Drivers/USB
parent66c38cd940714287e4e11729bf688211902b464d (diff)
downloadlufa-cf2411435cf41ca4dbfcc3d89c6287743db79625.tar.gz
lufa-cf2411435cf41ca4dbfcc3d89c6287743db79625.tar.bz2
lufa-cf2411435cf41ca4dbfcc3d89c6287743db79625.zip
Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared when Pipe_ClearError() is called.
More UC3B architecture porting.
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r--LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h12
-rw-r--r--LUFA/Drivers/USB/Core/HostStandardReq.c12
-rw-r--r--LUFA/Drivers/USB/Core/OTG.h2
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.h57
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h52
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/OTG_UC3B.h149
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.c68
-rw-r--r--LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h190
8 files changed, 171 insertions, 371 deletions
diff --git a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h
index 201ac0bd2..4a5596832 100644
--- a/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h
+++ b/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.h
@@ -410,10 +410,11 @@
return ((UPCONX & (1 << PFREEZE)) ? true : false);
}
- /** Clears the master pipe error flag. */
+ /** Clears the error flags for the currently selected pipe. */
static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_ClearError(void)
{
+ UPERRX = 0;
UPINTX &= ~(1 << PERRI);
}
@@ -430,15 +431,6 @@
return ((UPINTX & (1 << PERRI)) ? true : false);
}
- /** Clears all the currently selected pipe's hardware error flags, but does not clear the master error
- * flag for the pipe.
- */
- static inline void Pipe_ClearErrorFlags(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ClearErrorFlags(void)
- {
- UPERRX = 0;
- }
-
/** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This
* value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred.
*
diff --git a/LUFA/Drivers/USB/Core/HostStandardReq.c b/LUFA/Drivers/USB/Core/HostStandardReq.c
index 16d0ffb17..f74490f93 100644
--- a/LUFA/Drivers/USB/Core/HostStandardReq.c
+++ b/LUFA/Drivers/USB/Core/HostStandardReq.c
@@ -38,11 +38,11 @@
uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
{
- uint8_t* HeaderStream = (uint8_t*)&USB_ControlRequest;
- uint8_t* DataStream = (uint8_t*)BufferPtr;
- bool BusSuspended = USB_Host_IsBusSuspended();
- uint8_t ReturnStatus = HOST_SENDCONTROL_Successful;
- uint16_t DataLen = USB_ControlRequest.wLength;
+ uint8_t* HeaderStream = (uint8_t*)&USB_ControlRequest;
+ uint8_t* DataStream = (uint8_t*)BufferPtr;
+ bool BusSuspended = USB_Host_IsBusSuspended();
+ uint8_t ReturnStatus = HOST_SENDCONTROL_Successful;
+ uint16_t DataLen = USB_ControlRequest.wLength;
USB_Host_ResumeBus();
@@ -50,7 +50,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
goto End_Of_Control_Send;
Pipe_SetPipeToken(PIPE_TOKEN_SETUP);
- Pipe_ClearErrorFlags();
+ Pipe_ClearError();
Pipe_Unfreeze();
diff --git a/LUFA/Drivers/USB/Core/OTG.h b/LUFA/Drivers/USB/Core/OTG.h
index 296d7a080..45f365dca 100644
--- a/LUFA/Drivers/USB/Core/OTG.h
+++ b/LUFA/Drivers/USB/Core/OTG.h
@@ -55,8 +55,6 @@
#if (ARCH == ARCH_AVR8)
#include "AVR8/OTG_AVR8.h"
- #elif (ARCH == ARCH_UC3B)
- #include "UC3B/OTG_UC3B.h"
#endif
/* Preprocessor Checks: */
diff --git a/LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.h b/LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.h
index bc347b436..b95415c84 100644
--- a/LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.h
+++ b/LUFA/Drivers/USB/Core/UC3B/Endpoint_UC3B.h
@@ -119,9 +119,9 @@
#endif
/* Inline Functions: */
- static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST
+ static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST
ATTR_ALWAYS_INLINE;
- static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)
+ static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)
{
uint8_t MaskVal = 0;
uint16_t CheckBytes = 8;
@@ -151,12 +151,12 @@
/** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
* should be initialized in the OUT direction - i.e. data flows from host to device.
*/
- #define ENDPOINT_DIR_OUT (0 << AVR32_USBB_UECFG0_EPDIR_OFFSET)
+ #define ENDPOINT_DIR_OUT AVR32_USBB_UECFG0_EPDIR_OUT
/** Endpoint data direction mask for \ref Endpoint_ConfigureEndpoint(). This indicates that the endpoint
* should be initialized in the IN direction - i.e. data flows from device to host.
*/
- #define ENDPOINT_DIR_IN (1 << AVR32_USBB_UECFG0_EPDIR_OFFSET)
+ #define ENDPOINT_DIR_IN AVR32_USBB_UECFG0_EPDIR_IN
//@}
/** \name Endpoint Bank Mode Masks */
@@ -166,21 +166,21 @@
* in slower transfers as only one USB device (the AVR or the host) can access the endpoint's
* bank at the one time.
*/
- #define ENDPOINT_BANK_SINGLE (0 << AVR32_USBB_UECFG0_EPBK0_OFFSET)
+ #define ENDPOINT_BANK_SINGLE AVR32_USBB_UECFG0_EPBK0_SINGLE
/** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
* that the endpoint should have two banks, which requires more USB FIFO memory but results
* in faster transfers as one USB device (the AVR or the host) can access one bank while the other
* accesses the second bank.
*/
- #define ENDPOINT_BANK_DOUBLE (1 << AVR32_USBB_UECFG0_EPBK0_OFFSET)
+ #define ENDPOINT_BANK_DOUBLE AVR32_USBB_UECFG0_EPBK0_DOUBLE
/** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
* that the endpoint should have three banks, which requires more USB FIFO memory but results
* in faster transfers as one USB device (the AVR or the host) can access one bank while the other
* accesses the remaining banks.
*/
- #define ENDPOINT_BANK_TRIPLE (2 << AVR32_USBB_UECFG0_EPBK0_OFFSET)
+ #define ENDPOINT_BANK_TRIPLE AVR32_USBB_UECFG0_TRIPLE
//@}
/** Endpoint address for the default control endpoint, which always resides in address 0. This is
@@ -309,9 +309,10 @@
const uint16_t Size,
const uint8_t Banks)
{
- return Endpoint_ConfigureEndpoint_Prv(Number, ((Type << AVR32_USBB_EPTYPE_OFFSET) | AVR32_USBB_ALLOC |
- (Direction << AVR32_USBB_EPDIR_OFFSET) |
- (Banks << AVR32_USBB_EPBK_OFFSET) |
+ return Endpoint_ConfigureEndpoint_Prv(Number, (AVR32_USBB_ALLOC_MASK |
+ ((uint32_t)Type << AVR32_USBB_EPTYPE_OFFSET) |
+ ((uint32_t)Direction << AVR32_USBB_EPDIR_OFFSET) |
+ ((uint32_t)Banks << AVR32_USBB_EPBK_OFFSET) |
Endpoint_BytesToEPSizeMask(Size)));
}
@@ -365,8 +366,8 @@
static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
static inline void Endpoint_ResetFIFO(const uint8_t EndpointNumber)
{
- AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_OFFSET << EndpointNumber);
- AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_OFFSET << EndpointNumber);
+ AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_MASK << EndpointNumber);
+ AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_MASK << EndpointNumber);
}
/** Enables the currently selected endpoint so that data can be sent and received through it to
@@ -377,7 +378,7 @@
static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_EnableEndpoint(void)
{
- AVR32_USBB.uerst |= (AVR32_USBB_EPEN0 << USB_SelectedEndpoint);
+ AVR32_USBB.uerst |= (AVR32_USBB_EPEN0_MASK << USB_SelectedEndpoint);
}
/** Disables the currently selected endpoint so that data cannot be sent and received through it
@@ -386,7 +387,7 @@
static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_DisableEndpoint(void)
{
- AVR32_USBB.uerst &= ~(AVR32_USBB_EPEN0_OFFSET << USB_SelectedEndpoint);
+ AVR32_USBB.uerst &= ~(AVR32_USBB_EPEN0_MASK << USB_SelectedEndpoint);
}
/** Determines if the currently selected endpoint is enabled, but not necessarily configured.
@@ -396,7 +397,7 @@
static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Endpoint_IsEnabled(void)
{
- return ((AVR32_USBB.uerst & (AVR32_USBB_EPEN0_OFFSET << USB_SelectedEndpoint)) ? true : false);
+ return ((AVR32_USBB.uerst & (AVR32_USBB_EPEN0_MASK << USB_SelectedEndpoint)) ? true : false);
}
/** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for
@@ -464,10 +465,10 @@
static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t Endpoint_GetEndpointInterrupts(void)
{
- return ((AVR32_USBB.udint & (AVR32_USBB_EP6INTES_MASK | AVR32_USBB_EP5INTES_MASK |
- AVR32_USBB_EP4INTES_MASK | AVR32_USBB_EP3INTES_MASK |
- AVR32_USBB_EP2INTES_MASK | AVR32_USBB_EP1INTES_MASK |
- AVR32_USBB_EP0INTES_MASK)) >> AVR32_USBB_EP0INT_OFFSET);
+ return ((AVR32_USBB.udint & (AVR32_USBB_EP6INT_MASK | AVR32_USBB_EP5INT_MASK |
+ AVR32_USBB_EP4INT_MASK | AVR32_USBB_EP3INT_MASK |
+ AVR32_USBB_EP2INT_MASK | AVR32_USBB_EP1INT_MASK |
+ AVR32_USBB_EP0INT_MASK)) >> AVR32_USBB_EP0INT_OFFSET);
}
/** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type
@@ -480,7 +481,7 @@
static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Endpoint_HasEndpointInterrupted(const uint8_t EndpointNumber)
{
- return ((Endpoint_GetEndpointInterrupts() & (1 << EndpointNumber)) ? true : false);
+ return ((Endpoint_GetEndpointInterrupts() & (AVR32_USBB_EP0INT_MASK << EndpointNumber)) ? true : false);
}
/** Determines if the selected IN endpoint is ready for a new packet to be sent to the host.
@@ -529,7 +530,7 @@
static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_ClearSETUP(void)
{
- ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxstpi = true;
+ ((avr32_usbb_uesta0clr_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxstpic = true;
}
/** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the
@@ -540,8 +541,8 @@
static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_ClearIN(void)
{
- ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].txini = true;
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifocon = true;
+ ((avr32_usbb_uesta0clr_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].txinic = true;
+ ((avr32_usbb_uecon0clr_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifoconc = true;
}
/** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint
@@ -552,8 +553,8 @@
static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_ClearOUT(void)
{
- ((avr32_usbb_uesta0_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxouti = true;
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifocon = true;
+ ((avr32_usbb_uesta0clr_t*)AVR32_USBB_UESTA0CLR)[USB_SelectedEndpoint].rxoutic = true;
+ ((avr32_usbb_uecon0clr_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].fifoconc = true;
}
/** Stalls the current endpoint, indicating to the host that a logical problem occurred with the
@@ -570,7 +571,7 @@
static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_StallTransaction(void)
{
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].stallrq = true;
+ ((avr32_usbb_uecon0set_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].stallrqs = true;
}
/** Clears the STALL condition on the currently selected endpoint.
@@ -580,7 +581,7 @@
static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_ClearStall(void)
{
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].stallrq = true;
+ ((avr32_usbb_uecon0clr_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint].stallrqc = true;
}
/** Determines if the currently selected endpoint is stalled, false otherwise.
@@ -599,7 +600,7 @@
static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_ResetDataToggle(void)
{
- ((avr32_usbb_uecon0_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].rstdt = true;
+ ((avr32_usbb_uecon0set_t*)AVR32_USBB_UECON0SET)[USB_SelectedEndpoint].rstdts = true;
}
/** Determines the currently selected endpoint's direction.
diff --git a/LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h b/LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h
index 14cc62474..d4f748f04 100644
--- a/LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h
+++ b/LUFA/Drivers/USB/Core/UC3B/Host_UC3B.h
@@ -245,7 +245,7 @@
*/
static inline uint16_t USB_Host_GetFrameNumber(void)
{
- return UHFNUM;
+ return AVR32_USBB_UHFNUM;
}
#if !defined(NO_SOF_EVENTS)
@@ -282,7 +282,7 @@
static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_ResetBus(void)
{
- UHCON |= (1 << RESET);
+ AVR32_USBB_UHCON.reset = true;
}
/** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has
@@ -293,7 +293,7 @@
static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsBusResetComplete(void)
{
- return ((UHCON & (1 << RESET)) ? false : true);
+ return AVR32_USBB_UHCON.reset;
}
/** Resumes USB communications with an attached and enumerated device, by resuming the transmission
@@ -303,7 +303,7 @@
static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_ResumeBus(void)
{
- UHCON |= (1 << SOFEN);
+ AVR32_USBB_UHCON.sofe = true;
}
/** Suspends the USB bus, preventing any communications from occurring between the host and attached
@@ -313,7 +313,7 @@
static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_SuspendBus(void)
{
- UHCON &= ~(1 << SOFEN);
+ AVR32_USBB_UHCON.sofe = false;
}
/** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,
@@ -325,7 +325,7 @@
static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsBusSuspended(void)
{
- return ((UHCON & (1 << SOFEN)) ? false : true);
+ return AVR32_USBB_UHCON.sofe;
}
/** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or
@@ -336,7 +336,7 @@
static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsDeviceFullSpeed(void)
{
- return ((USBSTA & (1 << SPEED)) ? true : false);
+ return (AVR32_USBB_USBSTA.speed == AVR32_USBB_SPEED_FULL);
}
/** Determines if the attached device is currently issuing a Remote Wakeup request, requesting
@@ -347,14 +347,14 @@
static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsRemoteWakeupSent(void)
{
- return ((UHINT & (1 << RXRSMI)) ? true : false);
+ return AVR32_USBB_UHINT.rxrsmi;
}
/** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */
static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_ClearRemoteWakeupSent(void)
{
- UHINT &= ~(1 << RXRSMI);
+ AVR32_USBB_UHINTCLR.rxrsmic = true;
}
/** Accepts a Remote Wakeup request from an attached device. This must be issued in response to
@@ -364,7 +364,7 @@
static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_ResumeFromWakeupRequest(void)
{
- UHCON |= (1 << RESUME);
+ AVR32_USBB_UHCON.resume = true;
}
/** Determines if a resume from Remote Wakeup request is currently being sent to an attached
@@ -375,7 +375,7 @@
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)
{
- return ((UHCON & (1 << RESUME)) ? false : true);
+ return AVR32_USBB_UHCON.resume;
}
/* Function Prototypes: */
@@ -438,59 +438,63 @@
static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_HostMode_On(void)
{
- USBCON |= (1 << HOST);
+ // Not required for UC3B
}
static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_HostMode_Off(void)
{
- USBCON &= ~(1 << HOST);
+ // Not required for UC3B
}
static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Auto_Enable(void)
{
- OTGCON &= ~(1 << VBUSHWC);
- UHWCON |= (1 << UVCONE);
+ AVR32_USBB_USBCON.vbushwc = false;
}
static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Manual_Enable(void)
{
- OTGCON |= (1 << VBUSHWC);
- UHWCON &= ~(1 << UVCONE);
-
- DDRE |= (1 << 7);
+ AVR32_USBB_USBCON.vbushwc = true;
+
+ // TODO: Manual VBUS pin output setup
}
static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Auto_On(void)
{
- OTGCON |= (1 << VBUSREQ);
+ AVR32_USBB_USBSTASET.vbusreqs = true;
}
static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Manual_On(void)
{
- PORTE |= (1 << 7);
+ // TODO: Manual VBUS pin output on
}
static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Auto_Off(void)
{
- OTGCON |= (1 << VBUSRQC);
+ AVR32_USBB_USBSTACLR.vbusreqc = true;
}
static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Manual_Off(void)
{
- PORTE &= ~(1 << 7);
+ // TODO: Manual VBUS pin output off
}
static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
static inline void USB_Host_SetDeviceAddress(const uint8_t Address)
{
- UHADDR = (Address & 0x7F);
+ AVR32_USBB_UHADDR1.uhaddrp0 = Address;
+ AVR32_USBB_UHADDR1.uhaddrp1 = Address;
+ AVR32_USBB_UHADDR1.uhaddrp2 = Address;
+ AVR32_USBB_UHADDR1.uhaddrp3 = Address;
+ AVR32_USBB_UHADDR2.uhaddrp4 = Address;
+ AVR32_USBB_UHADDR2.uhaddrp5 = Address;
+ AVR32_USBB_UHADDR2.uhaddrp6 = Address;
}
/* Enums: */
diff --git a/LUFA/Drivers/USB/Core/UC3B/OTG_UC3B.h b/LUFA/Drivers/USB/Core/UC3B/OTG_UC3B.h
deleted file mode 100644
index b4d79acca..000000000
--- a/LUFA/Drivers/USB/Core/UC3B/OTG_UC3B.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2011.
-
- dean [at] fourwalledcubicle [dot] com
- www.lufa-lib.org
-*/
-
-/*
- Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, distribute, and sell this
- software and its documentation for any purpose is hereby granted
- without fee, provided that the above copyright notice appear in
- all copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- * \brief USB OTG definitions for the AVR32 UC3B microcontrollers.
- * \copydetails Group_OTG_UC3B
- *
- * \note This file should not be included directly. It is automatically included as needed by the USB driver
- * dispatch header located in LUFA/Drivers/USB/USB.h.
- */
-
-/** \ingroup Group_OTG
- * \defgroup Group_OTG_UC3B USB On The Go (OTG) Management (UC3B)
- * \brief USB OTG definitions for the AVR32 UC3B microcontrollers.
- *
- * Architecture specific USB OTG definitions for the Atmel 32-bit AVR UC3B microcontrollers.
- *
- * @{
- */
-
-#ifndef __USBOTG_UC3B_H__
-#define __USBOTG_UC3B_H__
-
- /* Includes: */
- #include "../../../../Common/Common.h"
-
- /* Preprocessor Checks: */
- #if !defined(__INCLUDE_FROM_USB_DRIVER)
- #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.
- #endif
-
- /* Public Interface - May be used in end-application: */
- /* Macros: */
- /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.
- *
- * \see \ref USB_OTG_Device_InitiateSRP().
- */
- #define USB_OTG_SRP_VBUS (1 << SRPSEL)
-
- /** Mask for the Data + pulsing method of SRP, supported by some OTG devices.
- *
- * \see \ref USB_OTG_Device_InitiateSRP().
- */
- #define USB_OTG_STP_DATA 0
-
- /* Inline Functions: */
- /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device
- * that the device wishes to change device/host roles.
- */
- static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Device_RequestHNP(void)
- {
- OTGCON |= (1 << HNPREQ);
- }
-
- /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other
- * connected device.
- */
- static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Device_CancelHNPRequest(void)
- {
- OTGCON &= ~(1 << HNPREQ);
- }
-
- /** Determines if the device is currently sending a HNP to an attached host.
- *
- * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise
- */
- static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_ALWAYS_INLINE;
- static inline bool USB_OTG_Device_IsSendingHNP(void)
- {
- return ((OTGCON & (1 << HNPREQ)) ? true : false);
- }
-
- /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB
- * interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in
- * host mode indicates that VBUS should be applied and a session started.
- *
- * There are two different methods of sending a SRP - either pulses on the VBUS line, or by
- * pulsing the Data + line via the internal pull-up resistor.
- *
- * \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or
- * \ref USB_OTG_STP_DATA.
- */
- static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask)
- {
- OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ)));
- }
-
- /** Accepts a HNP from a connected device, indicating that both devices should exchange
- * device/host roles.
- */
- static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Host_AcceptHNP(void)
- {
- OTGCON |= (1 << HNPREQ);
- }
-
- /** Rejects a HNP from a connected device, indicating that both devices should remain in their
- * current device/host roles.
- */
- static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE;
- static inline void USB_OTG_Host_RejectHNP(void)
- {
- OTGCON &= ~(1 << HNPREQ);
- }
-
- /** Indicates if the connected device is not currently sending a HNP request.
- *
- * \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise.
- */
- static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
- static inline bool USB_OTG_Host_IsHNPReceived(void)
- {
- return ((OTGCON & (1 << HNPREQ)) ? true : false);
- }
-
-#endif
-
-/** @} */
-
diff --git a/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.c b/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.c
index e2fa2b960..8a054da61 100644
--- a/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.c
+++ b/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.c
@@ -36,6 +36,7 @@
#include "../Pipe.h"
uint8_t USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
+uint8_t USB_SelectedPipe = PIPE_CONTROLPIPE;
bool Pipe_ConfigurePipe(const uint8_t Number,
const uint8_t Type,
@@ -44,70 +45,19 @@ bool Pipe_ConfigurePipe(const uint8_t Number,
const uint16_t Size,
const uint8_t Banks)
{
-#if defined(ORDERED_EP_CONFIG)
Pipe_SelectPipe(Number);
Pipe_EnablePipe();
- UPCFG1X = 0;
-
- UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
- UPCFG1X = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
+ *((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = 0;
+ *((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = (AVR32_USBB_ALLOC_MASK |
+ ((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) |
+ ((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) |
+ ((uint32_t)Banks << AVR32_USBB_PBK_OFFSET) |
+ ((EndpointNumber & PIPE_EPNUM_MASK) << AVR32_USBB_PEPNUM_OFFSET));
Pipe_SetInfiniteINRequests();
return Pipe_IsConfigured();
-#else
- for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)
- {
- uint8_t UPCFG0XTemp;
- uint8_t UPCFG1XTemp;
- uint8_t UPCFG2XTemp;
- uint8_t UPCONXTemp;
- uint8_t UPINRQXTemp;
- uint8_t UPIENXTemp;
-
- Pipe_SelectPipe(PNum);
-
- if (PNum == Number)
- {
- UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointNumber & PIPE_EPNUM_MASK) << PEPNUM0));
- UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));
- UPCFG2XTemp = 0;
- UPCONXTemp = ((1 << PEN) | (1 << INMODE));
- UPINRQXTemp = 0;
- UPIENXTemp = 0;
- }
- else
- {
- UPCFG0XTemp = UPCFG0X;
- UPCFG1XTemp = UPCFG1X;
- UPCFG2XTemp = UPCFG2X;
- UPCONXTemp = UPCONX;
- UPINRQXTemp = UPINRQX;
- UPIENXTemp = UPIENX;
- }
-
- if (!(UPCFG1XTemp & (1 << ALLOC)))
- continue;
-
- Pipe_DisablePipe();
- UPCFG1X &= (1 << ALLOC);
-
- Pipe_EnablePipe();
- UPCFG0X = UPCFG0XTemp;
- UPCFG1X = UPCFG1XTemp;
- UPCFG2X = UPCFG2XTemp;
- UPCONX = UPCONXTemp;
- UPINRQX = UPINRQXTemp;
- UPIENX = UPIENXTemp;
-
- if (!(Pipe_IsConfigured()))
- return false;
- }
-
- Pipe_SelectPipe(Number);
- return true;
-#endif
}
void Pipe_ClearPipes(void)
@@ -117,9 +67,7 @@ void Pipe_ClearPipes(void)
for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
{
Pipe_SelectPipe(PNum);
- UPIENX = 0;
- UPINTX = 0;
- UPCFG1X = 0;
+ *((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = 0;
Pipe_DisablePipe();
}
}
diff --git a/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h b/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h
index e904518fb..5663a76f2 100644
--- a/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h
+++ b/LUFA/Drivers/USB/Core/UC3B/Pipe_UC3B.h
@@ -101,25 +101,25 @@
/** \name Pipe Error Flag Masks */
//@{
/** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */
- #define PIPE_ERRORFLAG_OVERFLOW (1 << 6)
+ #define PIPE_ERRORFLAG_OVERFLOW ((1 << AVR32_USBB_UPSTA0_OVERFI_OFFSET) << 8)
/** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */
- #define PIPE_ERRORFLAG_UNDERFLOW (1 << 5)
+ #define PIPE_ERRORFLAG_UNDERFLOW ((1 << AVR32_USBB_UPSTA0_UNDERFI_OFFSET) << 8)
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */
- #define PIPE_ERRORFLAG_CRC16 (1 << 4)
+ #define PIPE_ERRORFLAG_CRC16 (1 << AVR32_USBB_UPERR0_CRC16_OFFSET)
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */
- #define PIPE_ERRORFLAG_TIMEOUT (1 << 3)
+ #define PIPE_ERRORFLAG_TIMEOUT (1 << AVR32_USBB_UPERR0_TIMEOUT_OFFSET)
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */
- #define PIPE_ERRORFLAG_PID (1 << 2)
+ #define PIPE_ERRORFLAG_PID (1 << AVR32_USBB_UPERR0_PID_OFFSET)
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */
- #define PIPE_ERRORFLAG_DATAPID (1 << 1)
+ #define PIPE_ERRORFLAG_DATAPID (1 << AVR32_USBB_UPERR0_DATAPID_OFFSET)
/** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */
- #define PIPE_ERRORFLAG_DATATGL (1 << 0)
+ #define PIPE_ERRORFLAG_DATATGL (1 << AVR32_USBB_UPERR0_DATATGL_OFFSET)
//@}
/** \name Pipe Token Masks */
@@ -127,17 +127,17 @@
/** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a SETUP token (for CONTROL type pipes),
* which will trigger a control request on the attached device when data is written to the pipe.
*/
- #define PIPE_TOKEN_SETUP (0 << PTOKEN0)
+ #define PIPE_TOKEN_SETUP AVR32_USBB_UPCFG0_PTOKEN_SETUP
/** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a IN token (for non-CONTROL type pipes),
* indicating that the pipe data will flow from device to host.
*/
- #define PIPE_TOKEN_IN (1 << PTOKEN0)
+ #define PIPE_TOKEN_IN AVR32_USBB_UPCFG0_PTOKEN_IN
/** Token mask for \ref Pipe_ConfigurePipe(). This sets the pipe as a OUT token (for non-CONTROL type pipes),
* indicating that the pipe data will flow from host to device.
*/
- #define PIPE_TOKEN_OUT (2 << PTOKEN0)
+ #define PIPE_TOKEN_OUT AVR32_USBB_UPCFG0_PTOKEN_OUT
//@}
/** \name Pipe Bank Mode Masks */
@@ -146,14 +146,21 @@
* should have one single bank, which requires less USB FIFO memory but results in slower transfers as
* only one USB device (the AVR or the attached device) can access the pipe's bank at the one time.
*/
- #define PIPE_BANK_SINGLE (0 << EPBK0)
+ #define PIPE_BANK_SINGLE AVR32_USBB_UPCFG0_PBK_SINGLE
/** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe
* should have two banks, which requires more USB FIFO memory but results in faster transfers as one
* USB device (the AVR or the attached device) can access one bank while the other accesses the second
* bank.
*/
- #define PIPE_BANK_DOUBLE (1 << EPBK0)
+ #define PIPE_BANK_DOUBLE AVR32_USBB_UPCFG0_PBK_DOUBLE
+
+ /** Mask for the bank mode selection for the \ref Pipe_ConfigurePipe() macro. This indicates that the pipe
+ * should have three banks, which requires more USB FIFO memory but results in faster transfers as one
+ * USB device (the AVR or the attached device) can access one bank while the other accesses the remaining
+ * banks.
+ */
+ #define PIPE_BANK_TRIPLE AVR32_USBB_UPCFG0_PBK_TRIPLE
//@}
/** Pipe address for the default control pipe, which always resides in address 0. This is
@@ -223,7 +230,7 @@
static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint16_t Pipe_BytesInPipe(void)
{
- return UPBCX;
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].pbyct;
}
/** Returns the pipe address of the currently selected pipe. This is typically used to save the
@@ -234,7 +241,7 @@
static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t Pipe_GetCurrentPipe(void)
{
- return (UPNUM & PIPE_PIPENUM_MASK);
+ return USB_SelectedPipe;
}
/** Selects the given pipe number. Any pipe operations which do not require the pipe number to be
@@ -245,7 +252,7 @@
static inline void Pipe_SelectPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;
static inline void Pipe_SelectPipe(const uint8_t PipeNumber)
{
- UPNUM = PipeNumber;
+ USB_SelectedPipe = PipeNumber;
}
/** Resets the desired pipe, including the pipe banks and flags.
@@ -255,8 +262,8 @@
static inline void Pipe_ResetPipe(const uint8_t PipeNumber) ATTR_ALWAYS_INLINE;
static inline void Pipe_ResetPipe(const uint8_t PipeNumber)
{
- UPRST = (1 << PipeNumber);
- UPRST = 0;
+ AVR32_USBB.uprst |= (AVR32_USBB_PRST0_MASK << PipeNumber);
+ AVR32_USBB.uprst &= ~(AVR32_USBB_PRST0_MASK << PipeNumber);
}
/** Enables the currently selected pipe so that data can be sent and received through it to and from
@@ -267,7 +274,7 @@
static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_EnablePipe(void)
{
- UPCONX |= (1 << PEN);
+ AVR32_USBB.uprst |= (AVR32_USBB_PEN0_MASK << PipeNumber);
}
/** Disables the currently selected pipe so that data cannot be sent and received through it to and
@@ -276,7 +283,7 @@
static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_DisablePipe(void)
{
- UPCONX &= ~(1 << PEN);
+ AVR32_USBB.uprst &= ~(AVR32_USBB_PEN0_MASK << PipeNumber);
}
/** Determines if the currently selected pipe is enabled, but not necessarily configured.
@@ -286,7 +293,7 @@
static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsEnabled(void)
{
- return ((UPCONX & (1 << PEN)) ? true : false);
+ return ((AVR32_USBB.uprst & (AVR32_USBB_PEN0_MASK << PipeNumber)) ? true : false);
}
/** Gets the current pipe token, indicating the pipe's data direction and type.
@@ -296,7 +303,7 @@
static inline uint8_t Pipe_GetPipeToken(void) ATTR_ALWAYS_INLINE;
static inline uint8_t Pipe_GetPipeToken(void)
{
- return (UPCFG0X & (0x03 << PTOKEN0));
+ return ((avr32_usbb_upcfg0_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe].ptoken;
}
/** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_*
@@ -309,14 +316,14 @@
static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE;
static inline void Pipe_SetPipeToken(const uint8_t Token)
{
- UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token);
+ ((avr32_usbb_upcfg0_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe].ptoken = Token;
}
/** Configures the currently selected pipe to allow for an unlimited number of IN requests. */
static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_SetInfiniteINRequests(void)
{
- UPCONX |= (1 << INMODE);
+ ((avr32_usbb_upinrq0_t*)AVR32_USBB_UPINRQ0)[USB_SelectedPipe].inmode = true;
}
/** Configures the currently selected pipe to only allow the specified number of IN requests to be
@@ -327,8 +334,8 @@
static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE;
static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests)
{
- UPCONX &= ~(1 << INMODE);
- UPINRQX = TotalINRequests;
+ ((avr32_usbb_upinrq0_t*)AVR32_USBB_UPINRQ0)[USB_SelectedPipe].inmode = false;
+ ((avr32_usbb_upinrq0_t*)AVR32_USBB_UPINRQ0)[USB_SelectedPipe].inrq = TotalINRequests;
}
/** Determines if the currently selected pipe is configured.
@@ -338,7 +345,7 @@
static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsConfigured(void)
{
- return ((UPSTAX & (1 << CFGOK)) ? true : false);
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].cfgok;
}
/** Retrieves the endpoint number of the endpoint within the attached device that the currently selected
@@ -349,7 +356,7 @@
static inline uint8_t Pipe_BoundEndpointNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t Pipe_BoundEndpointNumber(void)
{
- return ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK);
+ return ((avr32_usbb_upcfg0_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe].pepnum;
}
/** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.
@@ -359,7 +366,7 @@
static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE;
static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds)
{
- UPCFG2X = Milliseconds;
+ ((avr32_usbb_upcfg0_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe].intfrq = Milliseconds;
}
/** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should
@@ -370,7 +377,10 @@
static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t Pipe_GetPipeInterrupts(void)
{
- return UPINT;
+ return ((AVR32_USBB.uhint & (AVR32_USBB_P6INT_MASK | AVR32_USBB_P5INT_MASK |
+ AVR32_USBB_P4INT_MASK | AVR32_USBB_P3INT_MASK |
+ AVR32_USBB_P2INT_MASK | AVR32_USBB_P1INT_MASK |
+ AVR32_USBB_P0INT_MASK)) >> AVR32_USBB_P0INT_OFFSET);
}
/** Determines if the specified pipe number has interrupted (valid only for INTERRUPT type
@@ -383,21 +393,21 @@
static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_HasPipeInterrupted(const uint8_t PipeNumber)
{
- return ((UPINT & (1 << PipeNumber)) ? true : false);
+ return ((AVR32_USBB.uhint & (AVR32_USBB_P0INTES_MASK << USB_SelectedPipe)) ? true : false);
}
/** Unfreezes the selected pipe, allowing it to communicate with an attached device. */
static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_Unfreeze(void)
{
- UPCONX &= ~(1 << PFREEZE);
+ ((avr32_usbb_upcon0clr_t*)AVR32_USBB_UPCON0CLR)[USB_SelectedPipe].pfreezec = true;
}
/** Freezes the selected pipe, preventing it from communicating with an attached device. */
static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_Freeze(void)
{
- UPCONX |= (1 << PFREEZE);
+ ((avr32_usbb_upcon0set_t*)AVR32_USBB_UPCON0SET)[USB_SelectedPipe].pfreezes = true;
}
/** Determines if the currently selected pipe is frozen, and not able to accept data.
@@ -407,14 +417,14 @@
static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsFrozen(void)
{
- return ((UPCONX & (1 << PFREEZE)) ? true : false);
+ return ((((avr32_usbb_upcon0_t*)AVR32_USBB_UPCON0)[USB_SelectedPipe].pfreeze) ? true : false);
}
- /** Clears the master pipe error flag. */
+ /** Clears the error flags for the currently selected pipe. */
static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_ClearError(void)
{
- UPINTX &= ~(1 << PERRI);
+ ((uint32_t*)AVR32_USBB_UPERR0)[USB_SelectedPipe] = 0;
}
/** Determines if the master pipe error flag is set for the currently selected pipe, indicating that
@@ -427,16 +437,7 @@
static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsError(void)
{
- return ((UPINTX & (1 << PERRI)) ? true : false);
- }
-
- /** Clears all the currently selected pipe's hardware error flags, but does not clear the master error
- * flag for the pipe.
- */
- static inline void Pipe_ClearErrorFlags(void) ATTR_ALWAYS_INLINE;
- static inline void Pipe_ClearErrorFlags(void)
- {
- UPERRX = 0;
+ return ((((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].perri) ? true : false);
}
/** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This
@@ -463,7 +464,7 @@
*/
static inline uint8_t Pipe_GetBusyBanks(void)
{
- return (UPSTAX & (0x03 << NBUSYBK0));
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].nbusybk;
}
/** Determines if the currently selected pipe may be read from (if data is waiting in the pipe
@@ -482,7 +483,7 @@
static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsReadWriteAllowed(void)
{
- return ((UPINTX & (1 << RWAL)) ? true : false);
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rwall;
}
/** Determines if a packet has been received on the currently selected IN pipe from the attached device.
@@ -494,7 +495,7 @@
static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsINReceived(void)
{
- return ((UPINTX & (1 << RXINI)) ? true : false);
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxini;
}
/** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device.
@@ -506,7 +507,7 @@
static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsOUTReady(void)
{
- return ((UPINTX & (1 << TXOUTI)) ? true : false);
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxouti;
}
/** Determines if no SETUP request is currently being sent to the attached device on the selected
@@ -519,7 +520,7 @@
static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsSETUPSent(void)
{
- return ((UPINTX & (1 << TXSTPI)) ? true : false);
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].txstpi;
}
/** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.
@@ -529,7 +530,7 @@
static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_ClearSETUP(void)
{
- UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON));
+ ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].txstpic = true;
}
/** Acknowledges the reception of a setup IN request from the attached device on the currently selected
@@ -540,7 +541,8 @@
static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_ClearIN(void)
{
- UPINTX &= ~((1 << RXINI) | (1 << FIFOCON));
+ ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxinic = true;
+ ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].fifoconc = true;
}
/** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing
@@ -551,7 +553,8 @@
static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_ClearOUT(void)
{
- UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON));
+ ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].txoutic = true;
+ ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].fifoconc = true;
}
/** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on
@@ -567,7 +570,7 @@
static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsNAKReceived(void)
{
- return ((UPINTX & (1 << NAKEDI)) ? true : false);
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].nakedi;
}
/** Clears the NAK condition on the currently selected pipe.
@@ -579,7 +582,7 @@
static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_ClearNAKReceived(void)
{
- UPINTX &= ~(1 << NAKEDI);
+ ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].nakedic = true;
}
/** Determines if the currently selected pipe has had the STALL condition set by the attached device.
@@ -591,7 +594,7 @@
static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Pipe_IsStalled(void)
{
- return ((UPINTX & (1 << RXSTALLI)) ? true : false);
+ return ((avr32_usbb_upsta0_t*)AVR32_USBB_UPSTA0)[USB_SelectedPipe].rxstalledi;
}
/** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the
@@ -602,7 +605,7 @@
static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE;
static inline void Pipe_ClearStall(void)
{
- UPINTX &= ~(1 << RXSTALLI);
+ ((avr32_usbb_upsta0clr_t*)AVR32_USBB_UPSTA0CLR)[USB_SelectedPipe].rxstalledic = true;
}
/** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.
@@ -614,7 +617,7 @@
static inline uint8_t Pipe_Read_Byte(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline uint8_t Pipe_Read_Byte(void)
{
- return UPDATX;
+ return *((uint8_t*)AVR32_USBB_EP_DATA);
}
/** Writes one byte from the currently selected pipe's bank, for IN direction pipes.
@@ -626,7 +629,7 @@
static inline void Pipe_Write_Byte(const uint8_t Byte) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_Byte(const uint8_t Byte)
{
- UPDATX = Byte;
+ *((uint8_t*)AVR32_USBB_EP_DATA) = Byte;
}
/** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.
@@ -638,7 +641,7 @@
{
uint8_t Dummy;
- Dummy = UPDATX;
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
}
/** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT
@@ -657,8 +660,8 @@
uint8_t Bytes[2];
} Data;
- Data.Bytes[0] = UPDATX;
- Data.Bytes[1] = UPDATX;
+ Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);
return Data.Word;
}
@@ -679,8 +682,8 @@
uint8_t Bytes[2];
} Data;
- Data.Bytes[1] = UPDATX;
- Data.Bytes[0] = UPDATX;
+ Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);
return Data.Word;
}
@@ -695,8 +698,8 @@
static inline void Pipe_Write_Word_LE(const uint16_t Word) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_Word_LE(const uint16_t Word)
{
- UPDATX = (Word & 0xFF);
- UPDATX = (Word >> 8);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (Word >> 8);
}
/** Writes two bytes to the currently selected pipe's bank in big endian format, for IN
@@ -709,8 +712,8 @@
static inline void Pipe_Write_Word_BE(const uint16_t Word) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_Word_BE(const uint16_t Word)
{
- UPDATX = (Word >> 8);
- UPDATX = (Word & 0xFF);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (Word >> 8);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (Word & 0xFF);
}
/** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.
@@ -722,8 +725,8 @@
{
uint8_t Dummy;
- Dummy = UPDATX;
- Dummy = UPDATX;
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
}
/** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT
@@ -742,10 +745,10 @@
uint8_t Bytes[4];
} Data;
- Data.Bytes[0] = UPDATX;
- Data.Bytes[1] = UPDATX;
- Data.Bytes[2] = UPDATX;
- Data.Bytes[3] = UPDATX;
+ Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Data.Bytes[3] = *((uint8_t*)AVR32_USBB_EP_DATA);
return Data.DWord;
}
@@ -766,10 +769,10 @@
uint8_t Bytes[4];
} Data;
- Data.Bytes[3] = UPDATX;
- Data.Bytes[2] = UPDATX;
- Data.Bytes[1] = UPDATX;
- Data.Bytes[0] = UPDATX;
+ Data.Bytes[3] = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Data.Bytes[2] = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Data.Bytes[1] = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Data.Bytes[0] = *((uint8_t*)AVR32_USBB_EP_DATA);
return Data.DWord;
}
@@ -784,10 +787,10 @@
static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_DWord_LE(const uint32_t DWord)
{
- UPDATX = (DWord & 0xFF);
- UPDATX = (DWord >> 8);
- UPDATX = (DWord >> 16);
- UPDATX = (DWord >> 24);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord & 0xFF);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);
}
/** Writes four bytes to the currently selected pipe's bank in big endian format, for IN
@@ -800,10 +803,10 @@
static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_DWord_BE(const uint32_t DWord)
{
- UPDATX = (DWord >> 24);
- UPDATX = (DWord >> 16);
- UPDATX = (DWord >> 8);
- UPDATX = (DWord & 0xFF);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 24);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 16);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord >> 8);
+ *((uint8_t*)AVR32_USBB_EP_DATA) = (DWord & 0xFF);
}
/** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.
@@ -815,10 +818,10 @@
{
uint8_t Dummy;
- Dummy = UPDATX;
- Dummy = UPDATX;
- Dummy = UPDATX;
- Dummy = UPDATX;
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
+ Dummy = *((uint8_t*)AVR32_USBB_EP_DATA);
}
/* External Variables: */
@@ -911,7 +914,7 @@
#if !defined(ENDPOINT_CONTROLEP)
#define ENDPOINT_CONTROLEP 0
#endif
-
+
/* Inline Functions: */
static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;
static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes)
@@ -925,11 +928,14 @@
CheckBytes <<= 1;
}
- return (MaskVal << EPSIZE0);
+ return (MaskVal << AVR32_USBB_PSIZE_OFFSET);
}
/* Function Prototypes: */
void Pipe_ClearPipes(void);
+
+ /* External Variables: */
+ extern uint8_t USB_SelectedPipe;
#endif
/* Disable C linkage for C++ Compilers: */