diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-02-28 01:28:56 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-02-28 01:28:56 +0100 |
commit | 0395bd15b34a516b3f27311b8b508bb81e40fe34 (patch) | |
tree | 869e8a9cfc68304c0518280b0141a2a269647893 | |
parent | c430ac1f2a9a3b00fcc130072edd596ccfedc25d (diff) |
move PLLB (for USB) initialization to board_lowlevel.c
This way it is present both inside the DFU loader and in the main app.
-rw-r--r-- | firmware/libboard/common/source/board_lowlevel.c | 24 | ||||
-rw-r--r-- | firmware/libcommon/source/usb.c | 23 |
2 files changed, 24 insertions, 23 deletions
diff --git a/firmware/libboard/common/source/board_lowlevel.c b/firmware/libboard/common/source/board_lowlevel.c index 625160e..42a679f 100644 --- a/firmware/libboard/common/source/board_lowlevel.c +++ b/firmware/libboard/common/source/board_lowlevel.c @@ -81,9 +81,31 @@ #error "No PLL settings for current BOARD_MCK."
#endif
+#if (BOARD_MAINOSC == 12000000)
+#define PLLB_CFG (CKGR_PLLBR_DIVB(2)|CKGR_PLLBR_MULB(8-1)|CKGR_PLLBR_PLLBCOUNT_Msk)
+#elif (BOARD_MAINOSC == 18432000)
+#define PLLB_CFG (CKGR_PLLBR_DIVB(5)|CKGR_PLLBR_MULB(13-1)|CKGR_PLLBR_PLLBCOUNT_Msk)
+#else
+#error "Please configure PLLB for your MAINOSC freq"
+#endif
+
/* Define clock timeout */
#define CLOCK_TIMEOUT 0xFFFFFFFF
+/**
+ * \brief Configure 48MHz Clock for USB
+ */
+static void _ConfigureUsbClock(void)
+{
+ /* Enable PLLB for USB */
+ PMC->CKGR_PLLBR = PLLB_CFG;
+ while ((PMC->PMC_SR & PMC_SR_LOCKB) == 0) ;
+
+ /* USB Clock uses PLLB */
+ PMC->PMC_USB = PMC_USB_USBDIV(0) /* /1 (no divider) */
+ | PMC_USB_USBS; /* PLLB */
+}
+
/*----------------------------------------------------------------------------
* Exported functions
*----------------------------------------------------------------------------*/
@@ -165,6 +187,8 @@ extern WEAK void LowLevelInit( void ) /* Configure SysTick for 1ms */
SysTick_Config(BOARD_MCK/1000);
+
+ _ConfigureUsbClock();
}
/* SysTick based delay function */
diff --git a/firmware/libcommon/source/usb.c b/firmware/libcommon/source/usb.c index 1d37914..c1fc111 100644 --- a/firmware/libcommon/source/usb.c +++ b/firmware/libcommon/source/usb.c @@ -780,35 +780,12 @@ static const USBDDriverDescriptors driverDescriptors = { STRING_DESC_CNT /* cnt string descriptors in list */ }; -#if (BOARD_MAINOSC == 12000000) -#define PLLB_CFG (CKGR_PLLBR_DIVB(2)|CKGR_PLLBR_MULB(8-1)|CKGR_PLLBR_PLLBCOUNT_Msk) -#elif (BOARD_MAINOSC == 18432000) -#define PLLB_CFG (CKGR_PLLBR_DIVB(5)|CKGR_PLLBR_MULB(13-1)|CKGR_PLLBR_PLLBCOUNT_Msk) -#else -#error "Please configure PLLB for your MAINOSC freq" -#endif - /*---------------------------------------------------------------------------- * Functions *----------------------------------------------------------------------------*/ -/** - * \brief Configure 48MHz Clock for USB - */ -static void _ConfigureUsbClock(void) -{ - /* Enable PLLB for USB */ - PMC->CKGR_PLLBR = PLLB_CFG; - while ((PMC->PMC_SR & PMC_SR_LOCKB) == 0) ; - - /* USB Clock uses PLLB */ - PMC->PMC_USB = PMC_USB_USBDIV(0) /* /1 (no divider) */ - | PMC_USB_USBS; /* PLLB */ -} - void SIMtrace_USB_Initialize(void) { - _ConfigureUsbClock(); // Get std USB driver USBDDriver *pUsbd = USBD_GetDriver(); |