Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/samd5x: disable ONDEMAND on clock with periph_can #21158

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cpu/samd5x/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
# endif

# if (CLOCK_CORECLOCK > SAM0_XOSC_FREQ_HZ)
# error When using an external oscillator for the main clock, the CPU frequency can't exceed it's frequency.

Check warning on line 62 in cpu/samd5x/cpu.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'for' not followed by a single space

Check warning on line 62 in cpu/samd5x/cpu.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
# endif

# define USE_DPLL 0
Expand All @@ -73,7 +73,7 @@
#else /* !USE_XOSC_ONLY */

/* Main clock > 48 MHz -> use DPLL, otherwise use DFLL */
# define USE_DPLL (CLOCK_CORECLOCK > SAM0_DFLL_FREQ_HZ)

Check warning on line 76 in cpu/samd5x/cpu.c

View workflow job for this annotation

GitHub Actions / static-tests

full block {} expected in the control structure
# define USE_DFLL 1
# define USE_XOSC 0

Expand Down Expand Up @@ -174,7 +174,7 @@
#ifdef OSCCTRL_DFLLCTRLB_WAITLOCK
| OSCCTRL_DFLLCTRLB_WAITLOCK
#endif
;

Check warning on line 177 in cpu/samd5x/cpu.c

View workflow job for this annotation

GitHub Actions / static-tests

semicolon is isolated from other tokens

/* workaround for Errata 2.8.3 DFLLVAL.FINE Value When DFLL48M Re-enabled */
OSCCTRL->DFLLMUL.reg = 0; /* Write new DFLLMULL configuration */
Expand Down Expand Up @@ -345,7 +345,7 @@
#ifdef MODULE_PERIPH_GPIO_IRQ
| MCLK_APBAMASK_EIC
#endif
;

Check warning on line 348 in cpu/samd5x/cpu.c

View workflow job for this annotation

GitHub Actions / static-tests

semicolon is isolated from other tokens

MCLK->APBBMASK.reg = 0
#ifdef MODULE_PERIPH_FLASHPAGE
Expand All @@ -354,7 +354,7 @@
#ifdef MODULE_PERIPH_GPIO
| MCLK_APBBMASK_PORT
#endif
;

Check warning on line 357 in cpu/samd5x/cpu.c

View workflow job for this annotation

GitHub Actions / static-tests

semicolon is isolated from other tokens

MCLK->APBCMASK.reg = 0;
MCLK->APBDMASK.reg = 0;
Expand All @@ -379,7 +379,9 @@

/* select the source of the main clock */
if (USE_DPLL) {
fdpll_init_nolock(0, CLOCK_CORECLOCK * DPLL_DIV, OSCCTRL_DPLLCTRLA_ONDEMAND);
/* CAN does not work with ondemand */
const uint8_t flags = IS_USED(MODULE_PERIPH_CAN) ? 0 : OSCCTRL_DPLLCTRLA_ONDEMAND;
fdpll_init_nolock(0, CLOCK_CORECLOCK * DPLL_DIV, flags);
gclk_connect(SAM0_GCLK_MAIN, GCLK_SOURCE_DPLL0,
GCLK_GENCTRL_DIV(DPLL_DIV));
fdpll_lock(0);
Expand Down Expand Up @@ -416,5 +418,7 @@

/* set ONDEMAND bit after all clocks have been configured */
/* This is to avoid setting the source for the main clock to ONDEMAND before using it. */
OSCCTRL->Dpll[0].DPLLCTRLA.reg |= OSCCTRL_DPLLCTRLA_ONDEMAND;
if (!IS_USED(MODULE_PERIPH_CAN)) {
OSCCTRL->Dpll[0].DPLLCTRLA.reg |= OSCCTRL_DPLLCTRLA_ONDEMAND;
}
}
Loading