Commit 2c404e5a authored by Dean Camera's avatar Dean Camera
Browse files

Add support for the ORDERED_EP_CONFIG compile time token on the UC3 architecture.

parent 69243c50
......@@ -45,6 +45,7 @@ volatile uint8_t* USB_EndpointFIFOPos[ENDPOINT_TOTAL_ENDPOINTS];
bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
const uint32_t UECFG0Data)
{
#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)
Endpoint_SelectEndpoint(Number);
Endpoint_EnableEndpoint();
......@@ -53,6 +54,38 @@ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
USB_EndpointFIFOPos[Number] = &AVR32_USBB_SLAVE[Number * 0x10000];
return Endpoint_IsConfigured();
#else
for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
{
uint8_t UECFG0Temp;
Endpoint_SelectEndpoint(EPNum);
if (EPNum == Number)
{
UECFG0Temp = UECFG0Data;
}
else
{
UECFG0Temp = (&AVR32_USBB.uecfg0)[EPNum];
}
if (!(UECFG0Temp & AVR32_USBB_ALLOC_MASK))
continue;
Endpoint_DisableEndpoint();
(&AVR32_USBB.uecfg0)[EPNum] &= ~AVR32_USBB_ALLOC_MASK;
Endpoint_EnableEndpoint();
(&AVR32_USBB.uecfg0)[EPNum] = UECFG0Temp;
if (!(Endpoint_IsConfigured()))
return false;
}
Endpoint_SelectEndpoint(Number);
return true;
#endif
}
void Endpoint_ClearEndpoints(void)
......
......@@ -47,6 +47,7 @@ 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();
......@@ -61,6 +62,44 @@ bool Pipe_ConfigurePipe(const uint8_t Number,
Pipe_SetInfiniteINRequests();
return Pipe_IsConfigured();
#else
for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)
{
uint8_t UPCFG0Temp;
Pipe_SelectPipe(PNum);
if (PNum == Number)
{
UPCFG0Temp = (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));
}
else
{
UPCFG0Temp = (&AVR32_USBB.upcfg0)[PNum]
}
if (!(UPCFG0Temp & AVR32_USBB_ALLOC_MASK))
continue;
Pipe_DisablePipe();
(&AVR32_USBB.upcfg0)[PNum] &= ~AVR32_USBB_ALLOC_MASK;
Pipe_EnablePipe();
(&AVR32_USBB.upcfg0)[PNum] = UPCFG0Temp;
Pipe_SetInfiniteINRequests();
if (!(Pipe_IsConfigured()))
return false;
}
Pipe_SelectPipe(Number);
return true;
#endif
}
void Pipe_ClearPipes(void)
......
......@@ -283,7 +283,24 @@
const uint8_t Banks)
{
Endpoint_SelectEndpoint(Number | Direction);
Endpoint_SelectedEndpointHandle->CTRL = (Type | Banks | Endpoint_BytesToEPSizeMask(Size));
uint8_t EPTypeMask = 0;
switch (Type)
{
case USB_EPTYPE_Control:
EPTypeMask = USB_EP_TYPE_CONTROL_gc;
break;
case USB_EPTYPE_Isochronous:
EPTypeMask = USB_EP_TYPE_ISOCHRONOUS_gc;
break;
default:
EPTypeMask = USB_EP_TYPE_BULK_gc;
break;
}
Endpoint_SelectedEndpointHandle->CTRL = 0;
Endpoint_SelectedEndpointHandle->STATUS = (USB_EP_BUSNACK0_bm | USB_EP_BUSNACK1_bm);
Endpoint_SelectedEndpointHandle->CTRL = (EPTypeMask | Banks | Endpoint_BytesToEPSizeMask(Size));
return true;
}
......@@ -324,27 +341,7 @@
{
// TODO
}
#if 0
/** Enables the currently selected endpoint so that data can be sent and received through it to
* and from a host.
*
* \note Endpoints must first be configured properly via \ref Endpoint_ConfigureEndpoint().
*/
static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_EnableEndpoint(void)
{
// TODO
}
/** Disables the currently selected endpoint so that data cannot be sent and received through it
* to and from a host.
*/
static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE;
static inline void Endpoint_DisableEndpoint(void)
{
// TODO
}
#endif
/** Determines if the currently selected endpoint is enabled, but not necessarily configured.
*
* \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise.
......@@ -355,20 +352,6 @@
return true;
}
/** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for
* transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the
* \ref Endpoint_ClearOUT() command.
*
* \ingroup Group_EndpointPacketManagement_XMEGA
*
* \return Total number of busy banks in the selected endpoint.
*/
static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Endpoint_GetBusyBanks(void)
{
return 0; // TODO
}
/** Aborts all pending IN transactions on the currently selected endpoint, once the bank
* has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function
* will terminate all queued transactions, resetting the endpoint banks ready for a new
......
......@@ -81,7 +81,7 @@
* \section Sec_SummaryUSBTokens General USB Driver Related Tokens
* This section describes compile tokens which affect USB driver stack as a whole in the LUFA library.
*
* <b>ORDERED_EP_CONFIG</b> - (\ref Group_EndpointManagement , \ref Group_PipeManagement) - <i>AVR8 Only</i> \n
* <b>ORDERED_EP_CONFIG</b> - (\ref Group_EndpointManagement , \ref Group_PipeManagement) - <i>AVR8, UC3</i> \n
* The USB AVRs do not allow for Endpoints and Pipes to be configured out of order; they <i>must</i> be configured in an ascending order to
* prevent data corruption issues. However, by default LUFA employs a workaround to allow for unordered Endpoint/Pipe initialization. This compile
* time token may be used to restrict the initialization order to ascending indexes only in exchange for a smaller compiled binary size. Use
......@@ -117,7 +117,7 @@
* can be accurately set and the \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events manually raised by the RAISE_EVENT macro.
* When defined, this token disables the library's auto-detection of the connection state by the aforementioned suspension and wake up events.
*
* <b>NO_SOF_EVENTS</b> - (\ref Group_Events) - <i>All Architectures</i> \n
* <b>NO_SOF_EVENTS</b> - (\ref Group_Events) - <i>AVR8, UC3</i> \n
* By default, there exists a LUFA application event for the start of each USB frame while the USB bus is not suspended in either host or device mode.
* This event can be selectively enabled or disabled by calling the appropriate device or host mode function. When this compile time token is defined,
* the ability to receive USB Start of Frame events via the \ref EVENT_USB_Device_StartOfFrame() or \ref EVENT_USB_Host_StartOfFrame() events is removed,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment