stm32: rcc_wait_for_sysclk_status should actually wait
Original implementation only checked whether the user had _selected_ the clock, not whether it had actually switched to the clock or not. For almost all cases, this made this function either a no-op, if you _had_ selected the clock, or a blocking loop if you hadn't selected it ahead of time. Fixes github issue #687
This commit is contained in:
@@ -414,13 +414,16 @@ void rcc_wait_for_sysclk_status(enum rcc_osc osc)
|
||||
{
|
||||
switch (osc) {
|
||||
case RCC_PLL:
|
||||
while ((RCC_CFGR & ((1 << 1) | (1 << 0))) != RCC_CFGR_SWS_PLL);
|
||||
while (((RCC_CFGR >> RCC_CFGR_SWS_SHIFT) & RCC_CFGR_SWS_MASK) !=
|
||||
RCC_CFGR_SWS_PLL);
|
||||
break;
|
||||
case RCC_HSE:
|
||||
while ((RCC_CFGR & ((1 << 1) | (1 << 0))) != RCC_CFGR_SWS_HSE);
|
||||
while (((RCC_CFGR >> RCC_CFGR_SWS_SHIFT) & RCC_CFGR_SWS_MASK) !=
|
||||
RCC_CFGR_SWS_HSE);
|
||||
break;
|
||||
case RCC_HSI:
|
||||
while ((RCC_CFGR & ((1 << 1) | (1 << 0))) != RCC_CFGR_SWS_HSI);
|
||||
while (((RCC_CFGR >> RCC_CFGR_SWS_SHIFT) & RCC_CFGR_SWS_MASK) !=
|
||||
RCC_CFGR_SWS_HSI);
|
||||
break;
|
||||
default:
|
||||
/* Shouldn't be reached. */
|
||||
|
||||
Reference in New Issue
Block a user