stm32: rcc: provide async routines for osc checks

Start providing async routines for all blocking routines, to make it
easier to use libopencm3 in some RTOS environments.  This is not in
anyway intended to be complete, this just covers a single blocking
routine, rcc_wait_for_osc_ready.  Documentation added to the top level,
and provided for all stm32 families.
This commit is contained in:
Karl Palsson
2016-08-16 17:57:57 +00:00
committed by Karl Palsson
parent 4eb51ecaea
commit 08aac020ad
9 changed files with 101 additions and 130 deletions

View File

@@ -176,47 +176,32 @@ 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)