mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-06-13 04:14:19 +00:00
Minor corrections for the XMEGA USB controller. Add compile time warning if the USB clock frequency is provably incorrect.
This commit is contained in:
parent
e30be658c9
commit
dc09ccab8b
@ -290,6 +290,10 @@
|
|||||||
const uint8_t Banks)
|
const uint8_t Banks)
|
||||||
{
|
{
|
||||||
uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | Banks | Endpoint_BytesToEPSizeMask(Size));
|
uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | Banks | Endpoint_BytesToEPSizeMask(Size));
|
||||||
|
|
||||||
|
// TODO - Fix once limitations are lifted
|
||||||
|
if ((Banks != ENDPOINT_BANK_SINGLE) || (Size > 64))
|
||||||
|
return false;
|
||||||
|
|
||||||
switch (Type)
|
switch (Type)
|
||||||
{
|
{
|
||||||
@ -473,7 +477,7 @@
|
|||||||
if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_SETUP_bm)
|
if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_SETUP_bm)
|
||||||
{
|
{
|
||||||
USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT;
|
USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -489,8 +493,8 @@
|
|||||||
static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;
|
static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;
|
||||||
static inline void Endpoint_ClearSETUP(void)
|
static inline void Endpoint_ClearSETUP(void)
|
||||||
{
|
{
|
||||||
|
Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);
|
||||||
USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_SETUP_bm | USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);
|
USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_SETUP_bm | USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);
|
||||||
|
|
||||||
USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm;
|
USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm;
|
||||||
USB_Endpoint_SelectedFIFO->Position = 0;
|
USB_Endpoint_SelectedFIFO->Position = 0;
|
||||||
|
|
||||||
@ -543,7 +547,7 @@
|
|||||||
if ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) == USB_EP_TYPE_CONTROL_gc)
|
if ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) == USB_EP_TYPE_CONTROL_gc)
|
||||||
{
|
{
|
||||||
Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);
|
Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);
|
||||||
USB_Endpoint_SelectedHandle->STATUS |= USB_EP_STALL_bm;
|
USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm;
|
||||||
Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);
|
Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -567,7 +571,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->STATUS & USB_EP_STALLF_bm) ? true : false);
|
return ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_STALL_bm) ? true : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Resets the data toggle of the currently selected endpoint. */
|
/** Resets the data toggle of the currently selected endpoint. */
|
||||||
|
@ -94,6 +94,10 @@
|
|||||||
#if !defined(F_USB)
|
#if !defined(F_USB)
|
||||||
#error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.
|
#error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (F_USB % 6000000)
|
||||||
|
#error Invalid F_USB specified. F_USB must be a multiple of 6MHz for USB Low Speed operation, and a multiple of 48MHz for Full Speed operation.
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Public Interface - May be used in end-application: */
|
/* Public Interface - May be used in end-application: */
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
|
Loading…
Reference in New Issue
Block a user