Commit cb7f7a82 authored by Dean Camera's avatar Dean Camera
Browse files

Fix XMEGA core USB driver endpoint code to prevent incorrect STALL determination.

parent 139c1afe
This diff is collapsed.
...@@ -52,14 +52,14 @@ bool Endpoint_ConfigureEndpoint_PRV(const uint8_t Number, ...@@ -52,14 +52,14 @@ bool Endpoint_ConfigureEndpoint_PRV(const uint8_t Number,
{ {
Endpoint_SelectEndpoint(Number | Direction); Endpoint_SelectEndpoint(Number | Direction);
USB_Endpoint_SelectedHandle->CTRL = 0; USB_Endpoint_SelectedHandle->CTRL = 0;
USB_Endpoint_SelectedHandle->STATUS = (Direction == ENDPOINT_DIR_IN) ? USB_EP_BUSNACK0_bm : 0; USB_Endpoint_SelectedHandle->STATUS = (Direction == ENDPOINT_DIR_IN) ? USB_EP_BUSNACK0_bm : 0;
USB_Endpoint_SelectedHandle->CTRL = Config; USB_Endpoint_SelectedHandle->CTRL = Config;
USB_Endpoint_SelectedHandle->CNT = 0; USB_Endpoint_SelectedHandle->CNT = 0;
USB_Endpoint_SelectedHandle->DATAPTR = (intptr_t)&USB_Endpoint_SelectedFIFO->Data[0]; USB_Endpoint_SelectedHandle->DATAPTR = (intptr_t)&USB_Endpoint_SelectedFIFO->Data[0];
USB_Endpoint_SelectedFIFO->Length = (Direction == ENDPOINT_DIR_IN) ? Size : 0; USB_Endpoint_SelectedFIFO->Length = (Direction == ENDPOINT_DIR_IN) ? Size : 0;
USB_Endpoint_SelectedFIFO->Position = 0; USB_Endpoint_SelectedFIFO->Position = 0;
return true; return true;
} }
......
...@@ -289,7 +289,7 @@ ...@@ -289,7 +289,7 @@
const uint16_t Size, const uint16_t Size,
const uint8_t Banks) const uint8_t Banks)
{ {
uint8_t EPConfigMask = (Banks | Endpoint_BytesToEPSizeMask(Size)); uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | Banks | Endpoint_BytesToEPSizeMask(Size));
switch (Type) switch (Type)
{ {
...@@ -345,7 +345,10 @@ ...@@ -345,7 +345,10 @@
static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE; static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber) ATTR_ALWAYS_INLINE;
static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber) static inline void Endpoint_ResetEndpoint(const uint8_t EndpointNumber)
{ {
USB_Endpoint_SelectedFIFO->Position = 0; if (EndpointNumber & ENDPOINT_DIR_IN)
USB_Endpoint_FIFOs[EndpointNumber & ENDPOINT_EPNUM_MASK].IN.Position = 0;
else
USB_Endpoint_FIFOs[EndpointNumber & ENDPOINT_EPNUM_MASK].OUT.Position = 0;
} }
/** Determines if the currently selected endpoint is enabled, but not necessarily configured. /** Determines if the currently selected endpoint is enabled, but not necessarily configured.
...@@ -564,7 +567,7 @@ ...@@ -564,7 +567,7 @@
static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE; static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool Endpoint_IsStalled(void) static inline bool Endpoint_IsStalled(void)
{ {
return ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_STALLF_bm) ? true : false); return ((USB_Endpoint_SelectedHandle->STATUS & USB_EP_STALLF_bm) ? true : false);
} }
/** Resets the data toggle of the currently selected endpoint. */ /** Resets the data toggle of the currently selected endpoint. */
......
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