/*
 * @Description: 电量采集模块-svc层
 * @Author: yangsw
 * @Date: 2021-06-02 09:30:22
 * @LastEditTime: 2021-08-03 14:15:09
 * @LastEditors: yangsw
 * @Reference:
 */
#ifndef H_SVC_BAT_H
#define H_SVC_BAT_H

#include "../bsp/bsp_bat.h"

#define BAT_FLASH_LOW 2800

#define BAT_FLASH_COMMON 3400

#define Svc_Bat_Get_Adc() Bsp_Bat_Get_Adc()

typedef enum{
  E_Power_Normal1 = 0,  //电量正常
  E_Power_Normal2,      //电量够用
  E_Power_Low_1,        //一级低压状态
  E_Power_Low_2,        //二级低压状态
  E_Power_Down,         //掉电状态
}E_Power_State;         //电量状态

typedef struct
{
    /*电池电压，单位：mV*/
    gw_u16 u16BatValtage;
    /*电量检测时间计数*/
    gw_u8 u8TimeCnt;
    /*电量状态*/
    E_Power_State  e_power_state;
    /*刷新计数*/
    gw_u8 u8Cnt;
} S_Bat;

void Svc_Bat_Init(void);
void Svc_Bat_Wakeup_Init(void);
S_Bat Svc_Bat_Get_Data(void);

void Svc_Bat_Timer_Callback(void);
void Svc_Bat_Check(void);
void Svc_Bat_Real_Time(void);
void Bat_Check(gw_u32 u32Adc);
void Batter_Init(void);
#endif
