diff --git a/src/atsam/sam4e_afec.c b/src/atsam/sam4e_afec.c index 0e1c60ac..002e092f 100644 --- a/src/atsam/sam4e_afec.c +++ b/src/atsam/sam4e_afec.c @@ -179,7 +179,8 @@ gpio_adc_sample(struct gpio_adc g) afec->AFE_CR = AFE_CR_START; need_delay: - return ADC_FREQ_MAX * 10000ULL / CONFIG_CLOCK_FREQ; // about 400 mcu clock cycles or 40 afec cycles + // about 400 mcu clock cycles or 40 afec cycles + return ADC_FREQ_MAX * 10000ULL / CONFIG_CLOCK_FREQ; } // Read a value; use only after gpio_adc_sample() returns zero diff --git a/src/atsam/sam4s_sysinit.c b/src/atsam/sam4s_sysinit.c index 41a2dcfe..f31cf7ac 100644 --- a/src/atsam/sam4s_sysinit.c +++ b/src/atsam/sam4s_sysinit.c @@ -11,7 +11,8 @@ | CKGR_PLLAR_DIVA(0x1U)) #define SYS_BOARD_MCKR (PMC_MCKR_PRES_CLK_2 | PMC_MCKR_CSS_PLLA_CLK) -#define SYS_CKGR_MOR_KEY_VALUE CKGR_MOR_KEY(0x37) /* Key to unlock MOR register */ +/* Key to unlock MOR register */ +#define SYS_CKGR_MOR_KEY_VALUE CKGR_MOR_KEY(0x37) uint32_t SystemCoreClock = CHIP_FREQ_MAINCK_RC_4MHZ; @@ -23,7 +24,8 @@ void SystemInit( void ) /* Initialize main oscillator */ if ( !(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL) ) { - PMC->CKGR_MOR = SYS_CKGR_MOR_KEY_VALUE | SYS_BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN; + PMC->CKGR_MOR = (SYS_CKGR_MOR_KEY_VALUE | SYS_BOARD_OSCOUNT + | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN); while ( !(PMC->PMC_SR & PMC_SR_MOSCXTS) ) { @@ -31,13 +33,16 @@ void SystemInit( void ) } /* Switch to 3-20MHz Xtal oscillator */ - PMC->CKGR_MOR = SYS_CKGR_MOR_KEY_VALUE | SYS_BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL; + PMC->CKGR_MOR = (SYS_CKGR_MOR_KEY_VALUE | SYS_BOARD_OSCOUNT + | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN + | CKGR_MOR_MOSCSEL); while ( !(PMC->PMC_SR & PMC_SR_MOSCSELS) ) { } - PMC->PMC_MCKR = (PMC->PMC_MCKR & ~(uint32_t)PMC_MCKR_CSS_Msk) | PMC_MCKR_CSS_MAIN_CLK; + PMC->PMC_MCKR = ((PMC->PMC_MCKR & ~(uint32_t)PMC_MCKR_CSS_Msk) + | PMC_MCKR_CSS_MAIN_CLK); while ( !(PMC->PMC_SR & PMC_SR_MCKRDY) ) { @@ -50,7 +55,8 @@ void SystemInit( void ) } /* Switch to main clock */ - PMC->PMC_MCKR = (SYS_BOARD_MCKR & ~PMC_MCKR_CSS_Msk) | PMC_MCKR_CSS_MAIN_CLK; + PMC->PMC_MCKR = ((SYS_BOARD_MCKR & ~PMC_MCKR_CSS_Msk) + | PMC_MCKR_CSS_MAIN_CLK); while ( !(PMC->PMC_SR & PMC_SR_MCKRDY) ) { }