@ -59,9 +59,9 @@ const struct rcc_clock_scale rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. power_save = 1 ,
. voltage_scale = PWR_SCALE 1,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_3 WS ,
FLASH_ACR_LATENCY_1 WS ,
. ahb_frequency = 48000000 ,
. apb1_frequency = 12000000 ,
. apb2_frequency = 24000000 ,
@ -75,6 +75,7 @@ const struct rcc_clock_scale rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_2 ,
. ppre2 = RCC_CFGR_PPRE_DIV_NONE ,
. voltage_scale = PWR_SCALE1 ,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_2WS ,
. ahb_frequency = 84000000 ,
@ -90,7 +91,7 @@ const struct rcc_clock_scale rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. power_save = 1 ,
. voltage_scale = PWR_SCALE 1,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_3WS ,
. ahb_frequency = 120000000 ,
@ -106,6 +107,7 @@ const struct rcc_clock_scale rcc_hse_8mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. voltage_scale = PWR_SCALE1 ,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_5WS ,
. ahb_frequency = 168000000 ,
@ -124,9 +126,9 @@ const struct rcc_clock_scale rcc_hse_12mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. power_save = 1 ,
. voltage_scale = PWR_SCALE 1,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_3 WS ,
FLASH_ACR_LATENCY_1 WS ,
. ahb_frequency = 48000000 ,
. apb1_frequency = 12000000 ,
. apb2_frequency = 24000000 ,
@ -140,6 +142,7 @@ const struct rcc_clock_scale rcc_hse_12mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_2 ,
. ppre2 = RCC_CFGR_PPRE_DIV_NONE ,
. voltage_scale = PWR_SCALE1 ,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_2WS ,
. ahb_frequency = 84000000 ,
@ -155,7 +158,7 @@ const struct rcc_clock_scale rcc_hse_12mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. power_save = 1 ,
. voltage_scale = PWR_SCALE 1,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_3WS ,
. ahb_frequency = 120000000 ,
@ -171,6 +174,7 @@ const struct rcc_clock_scale rcc_hse_12mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. voltage_scale = PWR_SCALE1 ,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_5WS ,
. ahb_frequency = 168000000 ,
@ -189,9 +193,9 @@ const struct rcc_clock_scale rcc_hse_16mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. power_save = 1 ,
. voltage_scale = PWR_SCALE 1,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_3 WS ,
FLASH_ACR_LATENCY_1 WS ,
. ahb_frequency = 48000000 ,
. apb1_frequency = 12000000 ,
. apb2_frequency = 24000000 ,
@ -205,6 +209,7 @@ const struct rcc_clock_scale rcc_hse_16mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_2 ,
. ppre2 = RCC_CFGR_PPRE_DIV_NONE ,
. voltage_scale = PWR_SCALE1 ,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_2WS ,
. ahb_frequency = 84000000 ,
@ -220,7 +225,7 @@ const struct rcc_clock_scale rcc_hse_16mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. power_save = 1 ,
. voltage_scale = PWR_SCALE 1,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_3WS ,
. ahb_frequency = 120000000 ,
@ -236,6 +241,7 @@ const struct rcc_clock_scale rcc_hse_16mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. voltage_scale = PWR_SCALE1 ,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_5WS ,
. ahb_frequency = 168000000 ,
@ -254,9 +260,9 @@ const struct rcc_clock_scale rcc_hse_25mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. power_save = 1 ,
. voltage_scale = PWR_SCALE 1,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_3 WS ,
FLASH_ACR_LATENCY_1 WS ,
. ahb_frequency = 48000000 ,
. apb1_frequency = 12000000 ,
. apb2_frequency = 24000000 ,
@ -270,6 +276,7 @@ const struct rcc_clock_scale rcc_hse_25mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_2 ,
. ppre2 = RCC_CFGR_PPRE_DIV_NONE ,
. voltage_scale = PWR_SCALE1 ,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_2WS ,
. ahb_frequency = 84000000 ,
@ -285,7 +292,7 @@ const struct rcc_clock_scale rcc_hse_25mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. power_save = 1 ,
. voltage_scale = PWR_SCALE 1,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_3WS ,
. ahb_frequency = 120000000 ,
@ -301,6 +308,7 @@ const struct rcc_clock_scale rcc_hse_25mhz_3v3[RCC_CLOCK_3V3_END] = {
. hpre = RCC_CFGR_HPRE_DIV_NONE ,
. ppre1 = RCC_CFGR_PPRE_DIV_4 ,
. ppre2 = RCC_CFGR_PPRE_DIV_2 ,
. voltage_scale = PWR_SCALE1 ,
. flash_config = FLASH_ACR_DCEN | FLASH_ACR_ICEN |
FLASH_ACR_LATENCY_5WS ,
. ahb_frequency = 168000000 ,
@ -678,23 +686,20 @@ uint32_t rcc_system_clock_source(void)
void rcc_clock_setup_hse_3v3 ( const struct rcc_clock_scale * clock )
{
/* Enable internal high-speed oscillator. */
/* Enable internal high-speed oscillator (HSI) . */
rcc_osc_on ( RCC_HSI ) ;
rcc_wait_for_osc_ready ( RCC_HSI ) ;
/* Select HSI as SYSCLK source. */
rcc_set_sysclk_source ( RCC_CFGR_SW_HSI ) ;
/* Enable external high-speed oscillator 8MHz . */
/* Enable external high-speed oscillator (HSE) . */
rcc_osc_on ( RCC_HSE ) ;
rcc_wait_for_osc_ready ( RCC_HSE ) ;
/* Enable/disable high performance mode */
if ( ! clock - > power_save ) {
pwr_set_vos_scale ( PWR_SCALE1 ) ;
} else {
pwr_set_vos_scale ( PWR_SCALE2 ) ;
}
/* Set the VOS scale mode */
rcc_peripheral_enable_clock ( & RCC_APB1ENR , RCC_PWR ) ;
pwr_set_vos_scale ( clock - > voltage_scale ) ;
/*
* Set prescalers for AHB , ADC , ABP1 , ABP2 .
@ -712,6 +717,16 @@ void rcc_clock_setup_hse_3v3(const struct rcc_clock_scale *clock)
rcc_wait_for_osc_ready ( RCC_PLL ) ;
/* Configure flash settings. */
if ( clock - > flash_config & FLASH_ACR_DCEN ) {
flash_dcache_enable ( ) ;
} else {
flash_dcache_disable ( ) ;
}
if ( clock - > flash_config & FLASH_ACR_ICEN ) {
flash_icache_enable ( ) ;
} else {
flash_icache_disable ( ) ;
}
flash_set_ws ( clock - > flash_config ) ;
/* Select PLL as SYSCLK source. */