/* Wait until system clock switched to given oscillator.  */
void rcc_wait_for_sysclk_status(enum rcc_osc osc)
/* Wait until system clock switched to given oscillator.  */
void rcc_wait_for_sysclk_status(enum rcc_osc osc)
{
	uint32_t sws = 0;
	switch (osc) {
		case RCC_PLL:
			sws = RCC_CFGR_SWS_PLLRCLK;
			break;
		case RCC_HSE:
			sws = RCC_CFGR_SWS_HSE;
			break;
		case RCC_HSI:
			sws = RCC_CFGR_SWS_HSISYS;
			break;
		case RCC_LSI:
			sws = RCC_CFGR_SWS_LSI;
			break;
		case RCC_LSE:
			sws = RCC_CFGR_SWS_LSE;
			break;
		default:
			cm3_assert_not_reached();
			break;
	}
	while (((RCC_CFGR >> RCC_CFGR_SWS_SHIFT) & RCC_CFGR_SWS_MASK) != sws);
}