diff --git a/src/cmsis/src/st/system_stm32fxxx.c b/src/cmsis/src/st/system_stm32fxxx.c index f477e3c39..062a8a5d5 100644 --- a/src/cmsis/src/st/system_stm32fxxx.c +++ b/src/cmsis/src/st/system_stm32fxxx.c @@ -215,14 +215,20 @@ void SystemClock_Config(void) /* Enable HSE Oscillator and activate PLL with HSE as source */ #if defined(OMV_OSC_HSE_STATE) RCC_OscInitStruct.HSEState = OMV_OSC_HSE_STATE; + RCC_OscInitStruct.OscillatorType |= RCC_OSCILLATORTYPE_HSE; #endif #if defined(OMV_OSC_HSI_STATE) RCC_OscInitStruct.HSIState = OMV_OSC_HSI_STATE; + RCC_OscInitStruct.OscillatorType |= RCC_OSCILLATORTYPE_HSI; #endif #if defined(OMV_OSC_CSI_STATE) RCC_OscInitStruct.CSIState = OMV_OSC_CSI_STATE; + RCC_OscInitStruct.OscillatorType |= RCC_OSCILLATORTYPE_CSI; + #endif + #if defined(OMV_OSC_HSI48_STATE) + RCC_OscInitStruct.HSI48State = OMV_OSC_HSI48_STATE; + RCC_OscInitStruct.OscillatorType |= RCC_OSCILLATORTYPE_HSI48; #endif - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = OMV_OSC_PLL1M; @@ -274,17 +280,19 @@ void SystemClock_Config(void) |RCC_PERIPHCLK_SPI3|RCC_PERIPHCLK_SPI2 |RCC_PERIPHCLK_SDMMC|RCC_PERIPHCLK_I2C2 |RCC_PERIPHCLK_ADC|RCC_PERIPHCLK_USB - |RCC_PERIPHCLK_QSPI|RCC_PERIPHCLK_FMC; - PeriphClkInitStruct.UsbClockSelection = RCC_USBCLKSOURCE_PLL; + |RCC_PERIPHCLK_QSPI|RCC_PERIPHCLK_FMC + |RCC_PERIPHCLK_RNG; + PeriphClkInitStruct.UsbClockSelection = OMV_OSC_USB_CLKSOURCE; PeriphClkInitStruct.SdmmcClockSelection = RCC_SDMMCCLKSOURCE_PLL; PeriphClkInitStruct.FdcanClockSelection = RCC_FDCANCLKSOURCE_PLL; PeriphClkInitStruct.FmcClockSelection = RCC_FMCCLKSOURCE_PLL2; PeriphClkInitStruct.QspiClockSelection = RCC_QSPICLKSOURCE_PLL2; - PeriphClkInitStruct.AdcClockSelection = OMV_OSC_ADC_SOURCE; - PeriphClkInitStruct.Spi123ClockSelection = OMV_OSC_SPI123_SOURCE; + PeriphClkInitStruct.AdcClockSelection = OMV_OSC_ADC_CLKSOURCE; + PeriphClkInitStruct.Spi123ClockSelection = OMV_OSC_SPI123_CLKSOURCE; PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; PeriphClkInitStruct.I2c123ClockSelection = RCC_I2C123CLKSOURCE_D2PCLK1; PeriphClkInitStruct.Spi45ClockSelection = RCC_SPI45CLKSOURCE_PLL2; + PeriphClkInitStruct.RngClockSelection = RCC_RNGCLKSOURCE_HSI48; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { // Initialization Error diff --git a/src/omv/boards/OPENMV1/omv_boardconfig.h b/src/omv/boards/OPENMV1/omv_boardconfig.h index f7b4388c4..4d1991cdc 100644 --- a/src/omv/boards/OPENMV1/omv_boardconfig.h +++ b/src/omv/boards/OPENMV1/omv_boardconfig.h @@ -38,7 +38,6 @@ // HSE/HSI/CSI State #define OMV_OSC_HSE_STATE (RCC_HSE_ON) -#define OMV_OSC_HSI_STATE (RCC_HSI_OFF) // Flash Latency #define OMV_FLASH_LATENCY (FLASH_LATENCY_5) diff --git a/src/omv/boards/OPENMV2/omv_boardconfig.h b/src/omv/boards/OPENMV2/omv_boardconfig.h index 10dc48ca4..f272865eb 100644 --- a/src/omv/boards/OPENMV2/omv_boardconfig.h +++ b/src/omv/boards/OPENMV2/omv_boardconfig.h @@ -77,7 +77,6 @@ // HSE/HSI/CSI State #define OMV_OSC_HSE_STATE (RCC_HSE_ON) -#define OMV_OSC_HSI_STATE (RCC_HSI_OFF) // Flash Latency #define OMV_FLASH_LATENCY (FLASH_LATENCY_7) diff --git a/src/omv/boards/OPENMV3/omv_boardconfig.h b/src/omv/boards/OPENMV3/omv_boardconfig.h index 272d74f71..b886cd553 100644 --- a/src/omv/boards/OPENMV3/omv_boardconfig.h +++ b/src/omv/boards/OPENMV3/omv_boardconfig.h @@ -78,7 +78,6 @@ // HSE/HSI/CSI State #define OMV_OSC_HSE_STATE (RCC_HSE_ON) -#define OMV_OSC_HSI_STATE (RCC_HSI_OFF) // Flash Latency #define OMV_FLASH_LATENCY (FLASH_LATENCY_7) diff --git a/src/omv/boards/OPENMV4/omv_boardconfig.h b/src/omv/boards/OPENMV4/omv_boardconfig.h index ef7419799..60a561eed 100644 --- a/src/omv/boards/OPENMV4/omv_boardconfig.h +++ b/src/omv/boards/OPENMV4/omv_boardconfig.h @@ -106,13 +106,12 @@ #define OMV_OSC_PLL3FRAC (0) // Clock Sources -#define OMV_OSC_ADC_SOURCE RCC_ADCCLKSOURCE_PLL3 -#define OMV_OSC_SPI123_SOURCE RCC_SPI123CLKSOURCE_PLL3 +#define OMV_OSC_USB_CLKSOURCE RCC_USBCLKSOURCE_PLL +#define OMV_OSC_ADC_CLKSOURCE RCC_ADCCLKSOURCE_PLL3 +#define OMV_OSC_SPI123_CLKSOURCE RCC_SPI123CLKSOURCE_PLL3 // HSE/HSI/CSI State #define OMV_OSC_HSE_STATE (RCC_HSE_ON) -#define OMV_OSC_HSI_STATE (RCC_HSI_OFF) -#define OMV_OSC_CSI_STATE (RCC_CSI_OFF) // Flash Latency #define OMV_FLASH_LATENCY (FLASH_LATENCY_2) diff --git a/src/omv/boards/OPENMV4P/omv_boardconfig.h b/src/omv/boards/OPENMV4P/omv_boardconfig.h index 459a6ee2d..24922aa26 100644 --- a/src/omv/boards/OPENMV4P/omv_boardconfig.h +++ b/src/omv/boards/OPENMV4P/omv_boardconfig.h @@ -110,13 +110,12 @@ #define OMV_OSC_PLL3FRAC (0) // Clock Sources -#define OMV_OSC_ADC_SOURCE RCC_ADCCLKSOURCE_PLL3 -#define OMV_OSC_SPI123_SOURCE RCC_SPI123CLKSOURCE_PLL3 +#define OMV_OSC_USB_CLKSOURCE RCC_USBCLKSOURCE_PLL +#define OMV_OSC_ADC_CLKSOURCE RCC_ADCCLKSOURCE_PLL3 +#define OMV_OSC_SPI123_CLKSOURCE RCC_SPI123CLKSOURCE_PLL3 // HSE/HSI/CSI State #define OMV_OSC_HSE_STATE (RCC_HSE_ON) -#define OMV_OSC_HSI_STATE (RCC_HSI_OFF) -#define OMV_OSC_CSI_STATE (RCC_CSI_OFF) // Flash Latency #define OMV_FLASH_LATENCY (FLASH_LATENCY_2) diff --git a/src/omv/boards/OPENMVPURETHERMAL/omv_boardconfig.h b/src/omv/boards/OPENMVPURETHERMAL/omv_boardconfig.h index a02d8847f..047f1bda8 100644 --- a/src/omv/boards/OPENMVPURETHERMAL/omv_boardconfig.h +++ b/src/omv/boards/OPENMVPURETHERMAL/omv_boardconfig.h @@ -80,8 +80,9 @@ #define OMV_CORE_VBAT "3.3" // Clock Sources -#define OMV_OSC_ADC_SOURCE RCC_ADCCLKSOURCE_PLL2 -#define OMV_OSC_SPI123_SOURCE RCC_SPI123CLKSOURCE_PLL2 +#define OMV_OSC_USB_CLKSOURCE RCC_USBCLKSOURCE_PLL +#define OMV_OSC_ADC_CLKSOURCE RCC_ADCCLKSOURCE_PLL2 +#define OMV_OSC_SPI123_CLKSOURCE RCC_SPI123CLKSOURCE_PLL2 //PLL1 48MHz for USB, SDMMC and FDCAN #define OMV_OSC_PLL1M (3) @@ -115,8 +116,6 @@ // HSE/HSI/CSI State #define OMV_OSC_HSE_STATE (RCC_HSE_ON) -#define OMV_OSC_HSI_STATE (RCC_HSI_OFF) -#define OMV_OSC_CSI_STATE (RCC_CSI_OFF) // Flash Latency #define OMV_FLASH_LATENCY (FLASH_LATENCY_2) diff --git a/src/omv/boards/PORTENTA/omv_boardconfig.h b/src/omv/boards/PORTENTA/omv_boardconfig.h index 2f3fa9878..008552209 100644 --- a/src/omv/boards/PORTENTA/omv_boardconfig.h +++ b/src/omv/boards/PORTENTA/omv_boardconfig.h @@ -107,13 +107,13 @@ #define OMV_OSC_PLL3FRAC (0) // Clock Sources -#define OMV_OSC_ADC_SOURCE RCC_ADCCLKSOURCE_PLL3 -#define OMV_OSC_SPI123_SOURCE RCC_SPI123CLKSOURCE_PLL3 +#define OMV_OSC_USB_CLKSOURCE RCC_USBCLKSOURCE_HSI48 +#define OMV_OSC_ADC_CLKSOURCE RCC_ADCCLKSOURCE_PLL3 +#define OMV_OSC_SPI123_CLKSOURCE RCC_SPI123CLKSOURCE_PLL3 // HSE/HSI/CSI State #define OMV_OSC_HSE_STATE (RCC_HSE_BYPASS) -#define OMV_OSC_HSI_STATE (RCC_HSI_OFF) -#define OMV_OSC_CSI_STATE (RCC_CSI_OFF) +#define OMV_OSC_HSI48_STATE (RCC_HSI48_ON) // Flash Latency #define OMV_FLASH_LATENCY (FLASH_LATENCY_2)