45 lines
820 B
C
45 lines
820 B
C
#include "bsp_bat.h"
|
|
|
|
#include "bsp_uart.h"
|
|
#include "log.h"
|
|
|
|
#undef LOG_ENABLE
|
|
#define LOG_ENABLE 1
|
|
|
|
#undef LOG_TAG
|
|
#define LOG_TAG "bat"
|
|
|
|
void BSP_BAT_Init(void)
|
|
{
|
|
// 低精度
|
|
PowerMonitor(ENABLE, LPLevel_2V1);
|
|
PFIC_EnableIRQ(WDOG_BAT_IRQn);
|
|
|
|
// 高精度
|
|
// PowerMonitor(ENABLE, HALevel_2V5);
|
|
}
|
|
|
|
__INTERRUPT
|
|
__HIGH_CODE
|
|
void WDOG_BAT_IRQHandler(void)
|
|
{
|
|
logDebug("R8_BAT_STATUS=%x.", R8_BAT_STATUS);
|
|
while (R8_BAT_STATUS & RB_BAT_STAT_LOWER) // 等电压恢复
|
|
{
|
|
logDebug("BAT low..");
|
|
}
|
|
logDebug("BAT normal..");
|
|
}
|
|
|
|
__INTERRUPT
|
|
__HIGH_CODE
|
|
void NMI_IRQHandler(void)
|
|
{
|
|
// logDebug("R8_BAT_STATUS=%x.",R8_BAT_STATUS);
|
|
// while(R8_BAT_STATUS&RB_BAT_STAT_LOWER) //等电压恢复
|
|
// {
|
|
// logDebug("BAT low.. ");
|
|
// }
|
|
// logDebug("BAT normal..");
|
|
}
|