firmware: add definition for main osc bypass when using external osc

Add new board.h definition BOARD_MAINOSC_BYPASS to configure the clock module to use an external oscillator rather than a crystal. The qmod board is one such board.
Change-Id: If62f55cd4c8b0cf758534f09d25a9bcb028814a7
This commit is contained in:
James Tavares 2022-01-10 17:48:14 -05:00 committed by laforge
parent aeaf12853e
commit 91a93bc5de
2 changed files with 6 additions and 4 deletions

View File

@ -147,7 +147,7 @@ extern WEAK void LowLevelInit( void )
}
*/
#ifndef qmod
#ifndef BOARD_MAINOSC_BYPASS
/* Initialize main oscillator */
if ( !(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL) )
{
@ -165,11 +165,11 @@ extern WEAK void LowLevelInit( void )
timeout = 0;
while (!(PMC->PMC_SR & PMC_SR_MOSCSELS) && (timeout++ < CLOCK_TIMEOUT));
#else
/* QMOD has external 12MHz clock source */
/* Board has external clock, not a crystal oscillator */
PIOB->PIO_PDR = (1 << 9);
PIOB->PIO_PUDR = (1 << 9);
PIOB->PIO_PPDDR = (1 << 9);
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTBY| CKGR_MOR_MOSCSEL;
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTBY | CKGR_MOR_MOSCSEL;
#endif
/* disable the red LED after main clock initialization */

View File

@ -25,6 +25,8 @@
#define BOARD_MAINOSC 12000000
/** desired main clock frequency (in Hz, based on BOARD_MAINOSC) */
#define BOARD_MCK 58000000 // 18.432 * 29 / 6
/** board has external clock, not crystal */
#define BOARD_MAINOSC_BYPASS
/** MCU pin connected to red LED */
#define PIO_LED_RED PIO_PA17