
#ifndef __UWater_POWER_APP_H
#define __UWater_POWER_APP_H


#ifdef __cplusplus
extern "C" {
#endif
	
#include "sys_config.h"



/*--------------------------------- Variable Define ------------------------------------*/
//状态机状态定义
#define  POWER_SYS_S0                           0
#define  POWER_SYS_S1                           1
	
	
//#define POWER_CHECK_ADC         ADC_ONE
#define POWER_CHECK_CHANNEL     10
#define POWER_CHECK_NUM         3
#define POWER_CHECK_INTERVAL    30000

//电池电压信息
#define    LOW_POWER                            10         //电池电压低
#define    NORMAL_POWER                         01         //电压正常

//电压低于
#define    LOW_POWER_ADC_VALUE                  2540// //((3.1/2)/2.5)*4096 阈值3.1-V（无磁是3V）   //0x9A0      

//采样信息
#define    VOLTAGE_TEST_INTERVAL                43200  //电池电压检测间隔，12h（60*60*12）

#define    VOLTAGE_ADC_INTERVAL                 20  //电池电压采样间隔，20ms采集一次
#define    VOLTAGE_ADC_INTERVAL_SUM             10   //电池电压采样间隔，采样10次

#if (HARDWARE_VERSION==0x14)//方壳表
#define BAT_CHECK_ENPORT GpioPortE
#define BAT_CHECK_ENPIN  GpioPin5

#elif (HARDWARE_VERSION==0x18)//圆壳表
#define BAT_CHECK_ENPORT GpioPortF
#define BAT_CHECK_ENPIN  GpioPin0
#endif
/*---------------------------------- Function Declare -----------------------------------*/

void PowerMachineSys(void);
u8 PowerCheckStatusSys(void);
void PowerManageInitSys(void);

void PowerUnSleepClearSumSys(void);
void PowerUnSleepSumAddSys(void);
u8 PowerUnSleepSaveDataMsgSys(void);
void PowerUnSleepSaveDataClearMsgSys(void);


u8 PowerIfSleepSys(void);
void PowerPreSleepSys(void);
u16 PowerCheckValueSys(void);

#endif	/* __UWater_POWER_MANAGE_SYS_H */



