NOUP: stm32f3: rcc: provide async osc checks

replace bulky hardcoded wait for set and wait for clear with a single asynch
routine.  Leave the blocking routines in for compatibility at this point.

NOUP: should be added to other rcc.c files too.
This commit is contained in:
Karl Palsson
2015-10-22 22:36:58 +00:00
parent 0b84540ecb
commit aa5e108553
2 changed files with 13 additions and 29 deletions

View File

@@ -176,47 +176,30 @@ int rcc_css_int_flag(void)
return ((RCC_CIR & RCC_CIR_CSSF) != 0);
}
void rcc_wait_for_osc_ready(enum rcc_osc osc)
{
bool rcc_is_osc_ready(enum rcc_osc osc) {
switch (osc) {
case RCC_PLL:
while ((RCC_CR & RCC_CR_PLLRDY) == 0);
break;
return (RCC_CR & RCC_CR_PLLRDY);
case RCC_HSE:
while ((RCC_CR & RCC_CR_HSERDY) == 0);
break;
return (RCC_CR & RCC_CR_HSERDY);
case RCC_HSI:
while ((RCC_CR & RCC_CR_HSIRDY) == 0);
break;
return (RCC_CR & RCC_CR_HSIRDY);
case RCC_LSE:
while ((RCC_BDCR & RCC_BDCR_LSERDY) == 0);
break;
return (RCC_BDCR & RCC_BDCR_LSERDY);
case RCC_LSI:
while ((RCC_CSR & RCC_CSR_LSIRDY) == 0);
break;
return (RCC_CSR & RCC_CSR_LSIRDY);
}
return false;
}
void rcc_wait_for_osc_ready(enum rcc_osc osc)
{
while (!rcc_is_osc_ready(osc));
}
void rcc_wait_for_osc_not_ready(enum rcc_osc 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;
}
while (rcc_is_osc_ready(osc));
}
void rcc_wait_for_sysclk_status(enum rcc_osc osc)