2 #include <asm/arch/adc_drvapi.h>
4 unsigned int get_bat_low_level(void);
5 unsigned int get_bat_low_level_chg(void);
6 int charger_connected(void);
9 uint32_t vbat_buf[_BUF_SIZE];
10 void put_vbat_value(uint32_t vbat)
13 for(i=0;i<_BUF_SIZE -1;i++){
14 vbat_buf[i] = vbat_buf[i+1];
17 vbat_buf[_BUF_SIZE-1] = vbat;
20 uint32_t get_vbat_value(void)
24 for(i=0; i < _BUF_SIZE; i++)
34 unsigned int comp_vbat = 0;
41 if(charger_connected()){
42 comp_vbat = get_bat_low_level_chg();
44 comp_vbat = get_bat_low_level();
49 for(i=0;i<_BUF_SIZE;i++){
51 adc_value = ADC_GetValue(ADC_CHANNEL_VBAT, false);
53 printf("ADC read error\n");
57 put_vbat_value(adc_value);
61 adc_value = get_vbat_value();
63 printf("is_bat_low adc_value:%d,comp_vbat:%d\n",adc_value,comp_vbat);
65 if(sprdbat_auxadc2vbatvol (adc_value) < comp_vbat)