From 3b4de9d09fa92fd1f6dd0fe7ef4c31ebc26e8c54 Mon Sep 17 00:00:00 2001 From: blckmn Date: Tue, 8 Jul 2025 09:01:30 +1000 Subject: [PATCH] ADC DEVICE correction and comment. --- src/main/drivers/adc.h | 12 ++++-------- src/main/pg/adc.h | 2 +- src/platform/AT32/include/platform/platform.h | 4 ++-- src/platform/STM32/include/platform/platform.h | 9 ++------- src/platform/common/stm32/platform/adc_impl.h | 3 +-- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/main/drivers/adc.h b/src/main/drivers/adc.h index f21317f170..00b2a94773 100644 --- a/src/main/drivers/adc.h +++ b/src/main/drivers/adc.h @@ -59,10 +59,10 @@ typedef enum { #if PLATFORM_TRAIT_ADC_INTERNAL // On H7 and G4, internal sensors are treated in the similar fashion as regular ADC inputs ADC_CHANNEL_INTERNAL_FIRST_ID = 4, - ADC_TEMPSENSOR = 4, - ADC_VREFINT = 5, -#if PLATFORM_TRAIT_ADC_INTERNAL_VBAT4 - ADC_VBAT4 = 6, + ADC_TEMPSENSOR = ADC_CHANNEL_INTERNAL_FIRST_ID, + ADC_VREFINT, +#if ADC_INTERNAL_VBAT4_ENABLED + ADC_VBAT4, #endif #endif ADC_CHANNEL_COUNT @@ -73,11 +73,7 @@ typedef struct adcOperatingConfig_s { #if PLATFORM_TRAIT_ADC_DEVICE ADCDevice adcDevice; // ADCDEV_x for this input #endif -#if PLATFORM_TRAIT_ADC_CHANNEL_32BIT uint32_t adcChannel; // Channel number for this input. Note that H7 and G4 HAL requires this to be 32-bit encoded number. -#else - uint8_t adcChannel; // ADCy_INxx channel number for this input (XXX May be consolidated with uint32_t case) -#endif uint8_t dmaIndex; // index into DMA buffer in case of sparse channels bool enabled; uint8_t sampleTime; diff --git a/src/main/pg/adc.h b/src/main/pg/adc.h index 8953a94c06..15646ea3bb 100644 --- a/src/main/pg/adc.h +++ b/src/main/pg/adc.h @@ -31,7 +31,7 @@ typedef struct adcChannelConfig_t { bool enabled; ioTag_t ioTag; -#if defined(STM32H7) +#if PLATFORM_TRAIT_ADC_DEVICE int8_t device; // ADCDevice #endif } adcChannelConfig_t; diff --git a/src/platform/AT32/include/platform/platform.h b/src/platform/AT32/include/platform/platform.h index 49dae4a95f..7c42e2628b 100644 --- a/src/platform/AT32/include/platform/platform.h +++ b/src/platform/AT32/include/platform/platform.h @@ -70,10 +70,10 @@ typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState; #define MODIFY_REG(REG, CLEARMASK, SETMASK) WRITE_REG((REG), (((READ_REG(REG)) & (~(CLEARMASK))) | (SETMASK))) #define PLATFORM_TRAIT_ADC_INTERNAL 1 -#define PLATFORM_TRAIT_ADC_INTERNAL_VBAT4 0 +#define ADC_INTERNAL_VBAT4_ENABLED 0 +/* AT32F4 we need to specify the ADC device for each channel */ #define PLATFORM_TRAIT_ADC_DEVICE 1 -#define PLATFORM_TRAIT_ADC_CHANNEL_32BIT 1 #endif #define USE_USB_MSC diff --git a/src/platform/STM32/include/platform/platform.h b/src/platform/STM32/include/platform/platform.h index b007bcbd03..c1ed4f2dce 100644 --- a/src/platform/STM32/include/platform/platform.h +++ b/src/platform/STM32/include/platform/platform.h @@ -468,14 +468,9 @@ extern uint8_t _dmaram_end__; #define DMA_CHANREQ_STRING "Request" #define PLATFORM_TRAIT_ADC_INTERNAL 1 -#define PLATFORM_TRAIT_ADC_INTERNAL_VBAT4 1 - +#define ADC_INTERNAL_VBAT4_ENABLED 1 +/* H7 and G4 we need to specify the ADC device for each channel */ #define PLATFORM_TRAIT_ADC_DEVICE 1 -#define PLATFORM_TRAIT_ADC_CHANNEL_32BIT 1 - -#if defined(STM32H7) -#define PLATFORM_TRAIT_ADC_DEVICE 1 -#endif #endif #if defined(STM32F4) || defined(STM32F7) || defined(STM32H7) diff --git a/src/platform/common/stm32/platform/adc_impl.h b/src/platform/common/stm32/platform/adc_impl.h index 90a64580ce..0e6742f298 100644 --- a/src/platform/common/stm32/platform/adc_impl.h +++ b/src/platform/common/stm32/platform/adc_impl.h @@ -162,6 +162,5 @@ void adcGetChannelValues(void); #define TEMPSENSOR_CAL_VREFANALOG (3300U) #define TEMPSENSOR_CAL1_TEMP (25U) #define TEMPSENSOR_CAL1_V (1.27f) -// mV/C -#define TEMPSENSOR_SLOPE (-4.13f) +#define TEMPSENSOR_SLOPE (-4.13f /* mV/C */) #endif