From 7563530936eff4033f7890064dcf5e2393908e6e Mon Sep 17 00:00:00 2001 From: bkleiner Date: Sat, 4 May 2024 18:53:25 +0200 Subject: [PATCH] squash stm32g4 --- src/driver/adc.c | 2 +- src/driver/at32/adc.c | 2 +- src/driver/stm32/adc.c | 3 ++- src/system/stm32g473/system.c | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/driver/adc.c b/src/driver/adc.c index e2a2495c2..86d73f48d 100644 --- a/src/driver/adc.c +++ b/src/driver/adc.c @@ -11,7 +11,7 @@ uint16_t adc_array[ADC_CHAN_MAX]; adc_channel_t adc_pins[ADC_CHAN_MAX]; extern uint16_t adc_read_raw(adc_chan_t index); -extern float adc_convert_to_temp(float val); +extern float adc_convert_to_temp(uint16_t val); static float adc_convert_to_mv(float value) { const float vref = (float)(VREFINT_CAL * VREFINT_CAL_VREF) / (float)adc_read_raw(ADC_CHAN_VREF); diff --git a/src/driver/at32/adc.c b/src/driver/at32/adc.c index 689af521b..3d6c06e6a 100644 --- a/src/driver/at32/adc.c +++ b/src/driver/at32/adc.c @@ -149,6 +149,6 @@ uint16_t adc_read_raw(adc_chan_t index) { return adc_array[index]; } -float adc_convert_to_temp(float val) { +float adc_convert_to_temp(uint16_t val) { return (ADC_TEMP_BASE - val * ADC_VREF / 4096) / ADC_TEMP_SLOPE + 25; } \ No newline at end of file diff --git a/src/driver/stm32/adc.c b/src/driver/stm32/adc.c index 5235e3848..097abb650 100644 --- a/src/driver/stm32/adc.c +++ b/src/driver/stm32/adc.c @@ -155,6 +155,7 @@ static void adc_init_dev(adc_devices_t index) { LL_ADC_EnableInternalRegulator(dev->adc); time_delay_us(LL_ADC_DELAY_INTERNAL_REGUL_STAB_US); + LL_ADC_StartCalibration(dev->adc, LL_ADC_SINGLE_ENDED); while (LL_ADC_IsCalibrationOnGoing(dev->adc) != 0) ; @@ -238,7 +239,7 @@ uint16_t adc_read_raw(adc_chan_t index) { return adc_array[index]; } -float adc_convert_to_temp(float val) { +float adc_convert_to_temp(uint16_t val) { #ifdef STM32H7 // adc cal is 16bit on h7, shift by 4bit left val *= 16; diff --git a/src/system/stm32g473/system.c b/src/system/stm32g473/system.c index 4b40b36d4..247fd3efe 100644 --- a/src/system/stm32g473/system.c +++ b/src/system/stm32g473/system.c @@ -67,9 +67,9 @@ static void SystemClock_Config(void) { RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; - RCC_OscInitStruct.PLL.PLLN = 21; + RCC_OscInitStruct.PLL.PLLN = 42; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;