forked from mfulz_github/qmk_firmware
Add additional preprocessor sanity checks for the XMEGA platform based on the USB controller input clock speed.
This commit is contained in:
parent
2d98e5499b
commit
0e434c8f8f
|
@ -92,10 +92,12 @@
|
||||||
*/
|
*/
|
||||||
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
|
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
|
||||||
|
|
||||||
|
#if (F_USB > 6000000)
|
||||||
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
|
||||||
* USB interface should be initialized in full speed (12Mb/s) mode.
|
* USB interface should be initialized in full speed (12Mb/s) mode.
|
||||||
*/
|
*/
|
||||||
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
|
#define USB_DEVICE_OPT_FULLSPEED (0 << 0)
|
||||||
|
#endif
|
||||||
//@}
|
//@}
|
||||||
|
|
||||||
#if (!defined(NO_INTERNAL_SERIAL) || defined(__DOXYGEN__))
|
#if (!defined(NO_INTERNAL_SERIAL) || defined(__DOXYGEN__))
|
||||||
|
|
|
@ -105,10 +105,14 @@ void USB_Disable(void)
|
||||||
|
|
||||||
void USB_ResetInterface(void)
|
void USB_ResetInterface(void)
|
||||||
{
|
{
|
||||||
|
#if defined(USB_DEVICE_OPT_FULLSPEED)
|
||||||
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
|
||||||
CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp);
|
CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp);
|
||||||
else
|
else
|
||||||
CLK.USBCTRL = (((F_USB / 48000000) - 1) << CLK_USBPSDIV_gp);
|
CLK.USBCTRL = (((F_USB / 48000000) - 1) << CLK_USBPSDIV_gp);
|
||||||
|
#else
|
||||||
|
CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (USB_Options & USB_OPT_PLLCLKSRC)
|
if (USB_Options & USB_OPT_PLLCLKSRC)
|
||||||
CLK.USBCTRL |= (CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);
|
CLK.USBCTRL |= (CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);
|
||||||
|
|
|
@ -95,7 +95,7 @@
|
||||||
#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)
|
#if ((F_USB % 6000000) || (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.
|
#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
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue