diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2011-07-19 02:42:27 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2011-07-19 02:42:27 +0000 |
commit | 2c404e5af53409af5ce279321377a1303c776617 (patch) | |
tree | 090bca3a20578720326ef0102cf1b22f582adf52 /LUFA/Drivers | |
parent | 69243c5071c4b059c1405f9dd4753f306f8dc04e (diff) | |
download | lufa-2c404e5af53409af5ce279321377a1303c776617.tar.gz lufa-2c404e5af53409af5ce279321377a1303c776617.tar.bz2 lufa-2c404e5af53409af5ce279321377a1303c776617.zip |
Add support for the ORDERED_EP_CONFIG compile time token on the UC3 architecture.
Diffstat (limited to 'LUFA/Drivers')
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c | 33 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c | 39 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h | 53 |
3 files changed, 90 insertions, 35 deletions
diff --git a/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c b/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c index 8e784e96c..19a57a1f3 100644 --- a/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c +++ b/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.c @@ -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) diff --git a/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c b/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c index b1db1fc50..b425d3dae 100644 --- a/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c +++ b/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.c @@ -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) diff --git a/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h b/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h index 14ebf01f2..8a679f532 100644 --- a/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h +++ b/LUFA/Drivers/USB/Core/XMEGA/Endpoint_XMEGA.h @@ -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 |