mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-25 01:38:33 +03:00
move PLLB (for USB) initialization to board_lowlevel.c
This way it is present both inside the DFU loader and in the main app.
This commit is contained in:
@@ -81,9 +81,31 @@
|
|||||||
#error "No PLL settings for current BOARD_MCK."
|
#error "No PLL settings for current BOARD_MCK."
|
||||||
#endif
|
#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 */
|
||||||
#define CLOCK_TIMEOUT 0xFFFFFFFF
|
#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
|
* Exported functions
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
@@ -165,6 +187,8 @@ extern WEAK void LowLevelInit( void )
|
|||||||
|
|
||||||
/* Configure SysTick for 1ms */
|
/* Configure SysTick for 1ms */
|
||||||
SysTick_Config(BOARD_MCK/1000);
|
SysTick_Config(BOARD_MCK/1000);
|
||||||
|
|
||||||
|
_ConfigureUsbClock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* SysTick based delay function */
|
/* SysTick based delay function */
|
||||||
|
|||||||
@@ -780,35 +780,12 @@ static const USBDDriverDescriptors driverDescriptors = {
|
|||||||
STRING_DESC_CNT /* cnt string descriptors in list */
|
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
|
* 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)
|
void SIMtrace_USB_Initialize(void)
|
||||||
{
|
{
|
||||||
_ConfigureUsbClock();
|
|
||||||
// Get std USB driver
|
// Get std USB driver
|
||||||
USBDDriver *pUsbd = USBD_GetDriver();
|
USBDDriver *pUsbd = USBD_GetDriver();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user