From 6108f509dd96449786e206267a8959dd621b3910 Mon Sep 17 00:00:00 2001 From: wentx333 <2960191439@qq.com> Date: Tue, 13 Oct 2026 16:36:43 +0800 Subject: [PATCH] stm32: fix ADC build for STM32G0 --- .github/workflows/stm32.yml | 5 +++++ .../hardware_specific/stm32/stm32_adc_utils.cpp | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/stm32.yml b/.github/workflows/stm32.yml index 67b07cc31..c3ffca1cd 100644 --- a/.github/workflows/stm32.yml +++ b/.github/workflows/stm32.yml @@ -24,6 +24,7 @@ jobs: - STMicroelectronics:stm32:Disco:pnum=B_G431B_ESC1 # B-G431-ESC1 - STMicroelectronics:stm32:Nucleo_144:pnum=NUCLEO_H723ZG # stm32h7 - STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_G431RB # stm32g4 + - STMicroelectronics:stm32:GenG0:pnum=GENERIC_G030C8TX # stm32g0 include: - arduino-boards-fqbn: STMicroelectronics:stm32:GenF1:pnum=BLUEPILL_F103C8 # bluepill - hs examples @@ -61,6 +62,10 @@ jobs: platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json sketch-names: single_full_control_example.ino, stm32_spi_alt_example.ino, double_full_control_example.ino, stm32_current_control_low_side.ino, custom_motion_control.ino + - arduino-boards-fqbn: STMicroelectronics:stm32:GenG0:pnum=GENERIC_G030C8TX # stm32g0 compile regression + platform-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json + sketch-names: step_dir_listener_simple.ino + # Do not cancel all jobs / architectures if one job fails fail-fast: false steps: diff --git a/src/current_sense/hardware_specific/stm32/stm32_adc_utils.cpp b/src/current_sense/hardware_specific/stm32/stm32_adc_utils.cpp index 8bd41966f..e35a17321 100644 --- a/src/current_sense/hardware_specific/stm32/stm32_adc_utils.cpp +++ b/src/current_sense/hardware_specific/stm32/stm32_adc_utils.cpp @@ -186,6 +186,7 @@ ADC_TypeDef* _findBestADCForInjectedPins(int numPins, int pins[], ADC_HandleType SimpleFOCDebug::print(i+1); SimpleFOCDebug::print(" pins: "); SimpleFOCDebug::println(pins_at_adc[i]); +#if defined(LL_ADC_INJ_TRIG_SOFTWARE) if (adc_handles[i].Instance != NP) { // check if ADC injeted is already in use if(!LL_ADC_INJ_IsTriggerSourceSWStart(adc_handles[i].Instance)) { @@ -194,15 +195,18 @@ ADC_TypeDef* _findBestADCForInjectedPins(int numPins, int pins[], ADC_HandleType SimpleFOCDebug::println(" already in use for injected channels!"); } } +#endif } #endif // now take the first ADC that has all pins connected for (int i = 0; i < ADC_COUNT; i++) { +#if defined(LL_ADC_INJ_TRIG_SOFTWARE) if (adc_handles[i].Instance != NP) { if (!LL_ADC_INJ_IsTriggerSourceSWStart(adc_handles[i].Instance)) continue; // ADC already in use for injected } +#endif if (pins_at_adc[i] == no_pins) { return _indexToADC(i); } @@ -670,9 +674,6 @@ float _readRegularADCVoltage(const int pin){ #ifdef ADC_OFFSET_NONE sConfig.OffsetNumber = ADC_OFFSET_NONE; #endif -#ifndef STM32F1xx - sConfig.Offset = 0; -#endif if (HAL_ADC_ConfigChannel(&hadc[adc_index], &sConfig) != HAL_OK) { #ifdef SIMPLEFOC_STM32_DEBUG @@ -715,4 +716,4 @@ float _readRegularADCVoltage(const int pin){ return -1.0f; } -#endif \ No newline at end of file +#endif