From bb2c0d034e5b4ab7d60b8ec06cc7706d22f1bdde Mon Sep 17 00:00:00 2001 From: 95384 <664090429@qq.com> Date: Sat, 1 Mar 2025 09:52:22 +0800 Subject: [PATCH] =?UTF-8?q?ADC=E5=A2=9E=E7=9B=8A=E5=BC=80=E5=90=AF?= =?UTF-8?q?=E4=B8=8E=E5=85=B3=E9=97=AD=E7=82=B9=E6=94=B9=E4=B8=BA=E5=AE=8F?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=EF=BC=8C=E5=BC=80=E5=90=AF=E6=94=B9=E4=B8=BA?= =?UTF-8?q?190=EF=BC=8C=E5=85=B3=E9=97=AD=E6=94=B9=E4=B8=BA1900?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Inc/anemometer_dev.h | 2 ++ App/Src/anemometer_dev.c | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/App/Inc/anemometer_dev.h b/App/Inc/anemometer_dev.h index dd40f8f..13107e5 100644 --- a/App/Inc/anemometer_dev.h +++ b/App/Inc/anemometer_dev.h @@ -20,6 +20,8 @@ +#define ADC_GAIN_ENABLE 190 +#define ADC_GAIN_DISABLE 1900 #define K_128 0xA12EE1FE // 延时REV_MUTE_DELAY us启动ADC采集数据 diff --git a/App/Src/anemometer_dev.c b/App/Src/anemometer_dev.c index bc0ea98..ea43e7d 100644 --- a/App/Src/anemometer_dev.c +++ b/App/Src/anemometer_dev.c @@ -93,30 +93,30 @@ void config_adc_gain(uint8_t channel, uint16_t max_val) switch(channel) { case 0x01: - if(max_val <= 180) + if(max_val <= ADC_GAIN_ENABLE) gain_status.gain_status_s = 1; - else if(max_val >= 1900) + else if(max_val >= ADC_GAIN_DISABLE) gain_status.gain_status_s = 0; break; case 0x02: - if(max_val <= 180) + if(max_val <= ADC_GAIN_ENABLE) gain_status.gain_status_n = 1; - else if(max_val >= 1900) + else if(max_val >= ADC_GAIN_DISABLE) gain_status.gain_status_n = 0; break; case 0x03: - if(max_val <= 180) + if(max_val <= ADC_GAIN_ENABLE) gain_status.gain_status_e = 1; - else if(max_val >= 1900) + else if(max_val >= ADC_GAIN_DISABLE) gain_status.gain_status_e = 0; break; case 0x04: - if(max_val <= 180) + if(max_val <= ADC_GAIN_ENABLE) gain_status.gain_status_w = 1; - else if(max_val >= 1900) + else if(max_val >= ADC_GAIN_DISABLE) gain_status.gain_status_w = 0; break;