From 2bc159c6a126a414553f36a97e3f25d9923166b5 Mon Sep 17 00:00:00 2001 From: yincheng.zhong <634916154@qq.com> Date: 星期五, 22 十一月 2024 00:06:56 +0800 Subject: [PATCH] V2.24 现场升级版本,修改升级模式为SF8,小组0不启动UWB,1秒测距一次 --- Src/OnChipDevices/ADC.c | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Src/OnChipDevices/ADC.c b/Src/OnChipDevices/ADC.c index 26863f4..c029a89 100644 --- a/Src/OnChipDevices/ADC.c +++ b/Src/OnChipDevices/ADC.c @@ -1,5 +1,6 @@ #include "ADC.h" #include "main.h" + uint16_t Get_ADC_Value() { HAL_ADC_Start(&hadc); @@ -8,6 +9,18 @@ { return HAL_ADC_GetValue(&hadc); } +} +uint16_t GetRandomValue(void) +{ + uint16_t temp; + for(uint8_t i=0;i<16;i++) + { + if(Get_ADC_Value()%2) + { + temp=temp|(1<<i); + } + } + return temp; } float bat_volt; uint8_t Get_Battary(void) @@ -40,15 +53,16 @@ { static float last_value = 100; static uint8_t first=1; static uint16_t bat_count = 0; - if(bat_count++%600==0) - { +// if(bat_count++%600==0) +// { READC_Init(); - HAL_Delay(30); + Delay_Ms(10); + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_SET); adc_val = Get_ADC_Value(); MX_ADC_DeInit(); - //temp_voltage = (float)Get_ADC_Value()/621; //(value/4096*3.3*2-3.5)/0.7 + //temp_voltage = (float)Get_ADC_Value()/621; //(value/4096*3.3*2-3.5)/0.7 verfint_cal = *(__IO uint16_t *)(0X1FF80078); - bat_volt = 3*(float)verfint_cal/adc_val-0.329; + bat_volt = 3*(float)verfint_cal/adc_val-0.28; if(bat_volt>=3.0) { if(first) @@ -64,6 +78,8 @@ }else{ last_value=0; } -} + printf("VCC:%.2f\r\n",bat_volt); + HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET); +//} return last_value; } \ No newline at end of file -- Gitblit v1.9.3