From 2c1757d269b46c214b501e1b68776d632793b852 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Wed, 30 Mar 2016 17:38:13 +0000 Subject: [PATCH] Revert "NOUP: stm32f3: rcc: provide async osc checks" This reverts commit aa5e108553ace3079c6087dec796b9e58fe45fa4. This commit was not meant to land yet, it should have gone for review, and doesn't yet include all the parts it should touch. --- include/libopencm3/stm32/f3/rcc.h | 1 - lib/stm32/f3/rcc.c | 53 ++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/include/libopencm3/stm32/f3/rcc.h b/include/libopencm3/stm32/f3/rcc.h index 457aecc2..7c8ebf85 100644 --- a/include/libopencm3/stm32/f3/rcc.h +++ b/include/libopencm3/stm32/f3/rcc.h @@ -587,7 +587,6 @@ void rcc_osc_ready_int_disable(enum rcc_osc osc); int rcc_osc_ready_int_flag(enum rcc_osc osc); void rcc_css_int_clear(void); int rcc_css_int_flag(void); -bool rcc_is_osc_ready(enum rcc_osc osc); void rcc_wait_for_osc_ready(enum rcc_osc osc); void rcc_wait_for_osc_not_ready(enum rcc_osc osc); void rcc_wait_for_sysclk_status(enum rcc_osc osc); diff --git a/lib/stm32/f3/rcc.c b/lib/stm32/f3/rcc.c index 42dc6929..f915772d 100644 --- a/lib/stm32/f3/rcc.c +++ b/lib/stm32/f3/rcc.c @@ -176,30 +176,47 @@ int rcc_css_int_flag(void) return ((RCC_CIR & RCC_CIR_CSSF) != 0); } -bool rcc_is_osc_ready(enum rcc_osc osc) { - switch (osc) { - case RCC_PLL: - return (RCC_CR & RCC_CR_PLLRDY); - case RCC_HSE: - return (RCC_CR & RCC_CR_HSERDY); - case RCC_HSI: - return (RCC_CR & RCC_CR_HSIRDY); - case RCC_LSE: - return (RCC_BDCR & RCC_BDCR_LSERDY); - case RCC_LSI: - return (RCC_CSR & RCC_CSR_LSIRDY); - } - return false; -} - void rcc_wait_for_osc_ready(enum rcc_osc osc) { - while (!rcc_is_osc_ready(osc)); + switch (osc) { + case RCC_PLL: + while ((RCC_CR & RCC_CR_PLLRDY) == 0); + break; + case RCC_HSE: + while ((RCC_CR & RCC_CR_HSERDY) == 0); + break; + case RCC_HSI: + while ((RCC_CR & RCC_CR_HSIRDY) == 0); + break; + case RCC_LSE: + while ((RCC_BDCR & RCC_BDCR_LSERDY) == 0); + break; + case RCC_LSI: + while ((RCC_CSR & RCC_CSR_LSIRDY) == 0); + break; + } } + void rcc_wait_for_osc_not_ready(enum rcc_osc osc) { - while (rcc_is_osc_ready(osc)); + switch (osc) { + case RCC_PLL: + while ((RCC_CR & RCC_CR_PLLRDY) != 0); + break; + case RCC_HSE: + while ((RCC_CR & RCC_CR_HSERDY) != 0); + break; + case RCC_HSI: + while ((RCC_CR & RCC_CR_HSIRDY) != 0); + break; + case RCC_LSE: + while ((RCC_BDCR & RCC_BDCR_LSERDY) != 0); + break; + case RCC_LSI: + while ((RCC_CSR & RCC_CSR_LSIRDY) != 0); + break; + } } void rcc_wait_for_sysclk_status(enum rcc_osc osc)