From 99f3bb79c39a84a4d8b0cb76d17fa19207b18f5f Mon Sep 17 00:00:00 2001 From: Steins7 Date: Sun, 3 Nov 2024 22:28:00 +0100 Subject: [PATCH] Fix rcc_configure failing silently The function being so important, any failure should be fatal --- drv/rcc.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drv/rcc.c b/drv/rcc.c index e36fe45..aefe4e3 100644 --- a/drv/rcc.c +++ b/drv/rcc.c @@ -161,7 +161,7 @@ static void apply_speed_preset(void) //restore sane values apply_default_preset(); - //try enabling HSE, fallback to HSI if HSE fails + //enable HSE regs->CR.HSEON = 1; for (uint32_t i=0; i<10000; ++i) { __asm__("nop"); @@ -169,18 +169,19 @@ static void apply_speed_preset(void) if (regs->CR.HSERDY == 0x1) { regs->CFGR.PLLSCR = 1; } else { - regs->CR.HSEON = 0; + apply_default_preset(); + while (true); } - //configure PLL, fallback to HSI if PLL fails + //configure PLL regs->CFGR.PLLMUL = 0x7; //PLL x9 regs->CR.PLLON = 1; for (uint32_t i=0; i<10000; ++i) { __asm__("nop"); } if (regs->CR.PLLRDY != 0x1) { - regs->CR.PLLON = 0; - return; //clock low enough, no need for prescalers + apply_default_preset(); + while (true); } //configure prescalers