Skip to content

Commit

Permalink
wirish: allow boards to override PLL input clock
Browse files Browse the repository at this point in the history
Signed-off-by: Marti Bolivar <[email protected]>
  • Loading branch information
Marti Bolivar committed Nov 13, 2014
1 parent 630e2ce commit df44924
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions wirish/boards.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ static void setup_nvic(void) {
namespace wirish {
namespace priv {

__weak rcc_clk w_board_pll_in_clk = RCC_CLK_HSE;

__weak void board_setup_flash(void) {
// Turn on as many Flash "go faster" features as
// possible. flash_enable_features() just ignores any flags it
Expand All @@ -140,15 +142,17 @@ __weak void board_setup_clocks(void) {
RCC_BASE->CFGR = 0x00000000;
rcc_disable_css();
rcc_turn_off_clk(RCC_CLK_PLL);
rcc_turn_off_clk(RCC_CLK_HSE);
if (w_board_pll_in_clk != RCC_CLK_HSI) {
rcc_turn_off_clk(w_board_pll_in_clk);
}
wirish::priv::board_reset_pll();
// Clear clock readiness interrupt flags and turn off clock
// readiness interrupts.
RCC_BASE->CIR = 0x00000000;

// Enable HSE, and wait until it's ready.
rcc_turn_on_clk(RCC_CLK_HSE);
while (!rcc_is_clk_ready(RCC_CLK_HSE))
// Enable the PLL input clock, and wait until it's ready.
rcc_turn_on_clk(w_board_pll_in_clk);
while (!rcc_is_clk_ready(w_board_pll_in_clk))
;

// Configure AHBx, APBx, etc. prescalers and the main PLL.
Expand Down
1 change: 1 addition & 0 deletions wirish/boards_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace wirish {
*/

extern rcc_pll_cfg w_board_pll_cfg;
extern rcc_clk w_board_pll_in_clk;
extern adc_prescaler w_adc_pre;
extern adc_smp_rate w_adc_smp;

Expand Down

0 comments on commit df44924

Please sign in to comment.