From: penglei <1624952103@qq.com> Date: Wed, 11 Dec 2024 09:16:20 +0000 (+0800) Subject: 修改电池温度检测频率为五分钟一次 X-Git-Tag: v1.3.113-repair_tp~155^2~2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F1511%2Fhead;p=mirrors%2FFD230.git 修改电池温度检测频率为五分钟一次 --- diff --git a/code/sdk/application/battery/service/battery_driver.cpp b/code/sdk/application/battery/service/battery_driver.cpp index a6a4869b2..8b6424710 100644 --- a/code/sdk/application/battery/service/battery_driver.cpp +++ b/code/sdk/application/battery/service/battery_driver.cpp @@ -568,7 +568,8 @@ static bool adc_get_sample_result(float *voltage, uint8_t channel) uint32_t stick = 0; uint32_t sample_zero_count = 0; //开启 battery NTC 开关 - uapi_gpio_set_val(BATTERY_NTC_GPIO,GPIO_LEVEL_LOW); + if(channel != ADC_CHANNEL_BAT_VOLTAGE) + uapi_gpio_set_val(BATTERY_NTC_GPIO,GPIO_LEVEL_LOW); if (channel >= ADC_CHANNEL_4) { sample_number = HAL_ADC_SAMPLE_NUMBER_CONFIG_1; @@ -639,8 +640,9 @@ static bool adc_get_sample_result(float *voltage, uint8_t channel) } // osal_printk("channel = %d , stick = %d , voltage = %.04f.\r\n", channel,stick,*voltage); - //关闭 battery NTC 电源 - uapi_gpio_set_val(BATTERY_NTC_GPIO,GPIO_LEVEL_HIGH); + //关闭 battery NTC 电源 + if(channel != ADC_CHANNEL_BAT_VOLTAGE) + uapi_gpio_set_val(BATTERY_NTC_GPIO,GPIO_LEVEL_HIGH); UNUSED(discard_number); return true; @@ -798,7 +800,13 @@ uint8_t batteryservice_get_battery_temp(float *temp) { battery_info_t *current_battery_info = get_current_battery_info(); *temp = current_battery_info->battery_ntc_temp; - + // PRINT("*temp : %.3f\n",*temp); + if(!*temp) + { + batteryservice_get_voltage_by_channel(¤t_battery_info->battery_ntc_temp,ADC_CHANNEL_BAT_TEMP); + uapi_tcxo_delay_ms(20); + *temp = current_battery_info->battery_ntc_temp; + } return 0; } uint8_t batteryservice_get_pcb_temp(float *temp) diff --git a/code/sdk/application/battery/service/battery_service.cpp b/code/sdk/application/battery/service/battery_service.cpp index 9096afe1d..91c8cfc60 100644 --- a/code/sdk/application/battery/service/battery_service.cpp +++ b/code/sdk/application/battery/service/battery_service.cpp @@ -278,14 +278,25 @@ uint8_t get_charge_stat(void) return 0; } +static uint8_t bat_temp_cnt = 0; static void battery_check_voltage(void) { battery_info_t *current_battery_info = get_current_battery_info(); batteryservice_get_voltage_by_channel(¤t_battery_info->battery_voltage,ADC_CHANNEL_BAT_VOLTAGE); uapi_tcxo_delay_ms(20); - batteryservice_get_voltage_by_channel(¤t_battery_info->battery_ntc_temp,ADC_CHANNEL_BAT_TEMP); - uapi_tcxo_delay_ms(20); + + if(bat_temp_cnt >= 8) //5分钟左右检测一次电池温度 + { + bat_temp_cnt = 0; + batteryservice_get_voltage_by_channel(¤t_battery_info->battery_ntc_temp,ADC_CHANNEL_BAT_TEMP); + // printf("current_battery_info->battery_ntc_temp : %.3f \n",current_battery_info->battery_ntc_temp); + uapi_tcxo_delay_ms(20); + } + else + { + bat_temp_cnt ++; + } // batteryservice_get_voltage_by_channel(¤t_battery_info->pcb_ntc_temp,ADC_CHANNEL_PCB_TEMP); // uapi_tcxo_delay_ms(20); }