Skip to content

Commit df44924

Browse files
author
Marti Bolivar
committed
wirish: allow boards to override PLL input clock
Signed-off-by: Marti Bolivar <[email protected]>
1 parent 630e2ce commit df44924

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

wirish/boards.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ static void setup_nvic(void) {
120120
namespace wirish {
121121
namespace priv {
122122

123+
__weak rcc_clk w_board_pll_in_clk = RCC_CLK_HSE;
124+
123125
__weak void board_setup_flash(void) {
124126
// Turn on as many Flash "go faster" features as
125127
// possible. flash_enable_features() just ignores any flags it
@@ -140,15 +142,17 @@ __weak void board_setup_clocks(void) {
140142
RCC_BASE->CFGR = 0x00000000;
141143
rcc_disable_css();
142144
rcc_turn_off_clk(RCC_CLK_PLL);
143-
rcc_turn_off_clk(RCC_CLK_HSE);
145+
if (w_board_pll_in_clk != RCC_CLK_HSI) {
146+
rcc_turn_off_clk(w_board_pll_in_clk);
147+
}
144148
wirish::priv::board_reset_pll();
145149
// Clear clock readiness interrupt flags and turn off clock
146150
// readiness interrupts.
147151
RCC_BASE->CIR = 0x00000000;
148152

149-
// Enable HSE, and wait until it's ready.
150-
rcc_turn_on_clk(RCC_CLK_HSE);
151-
while (!rcc_is_clk_ready(RCC_CLK_HSE))
153+
// Enable the PLL input clock, and wait until it's ready.
154+
rcc_turn_on_clk(w_board_pll_in_clk);
155+
while (!rcc_is_clk_ready(w_board_pll_in_clk))
152156
;
153157

154158
// Configure AHBx, APBx, etc. prescalers and the main PLL.

wirish/boards_private.h

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ namespace wirish {
5252
*/
5353

5454
extern rcc_pll_cfg w_board_pll_cfg;
55+
extern rcc_clk w_board_pll_in_clk;
5556
extern adc_prescaler w_adc_pre;
5657
extern adc_smp_rate w_adc_smp;
5758

0 commit comments

Comments
 (0)