尝试bat监控
This commit is contained in:
parent
c745aca701
commit
54cd61e37f
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include "bsp_valve.h"
|
||||
|
||||
#include "bsp_bat.h"
|
||||
|
||||
#undef LOG_ENABLE
|
||||
#define LOG_ENABLE 1
|
||||
|
||||
|
@ -375,6 +377,8 @@ int main(void)
|
|||
|
||||
DelayMs(500 * 1);
|
||||
|
||||
// BSP_BAT_Init();
|
||||
|
||||
// tmos_set_event(Peripheral_TaskID, SBP_REPLY_CMD_EVT);
|
||||
#if 0
|
||||
// GPIOA_ModeCfg(GPIO_Pin_2, GPIO_ModeIN_Floating);
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef __BSP_BAT_H__
|
||||
#define __BSP_BAT_H__
|
||||
|
||||
|
||||
#include "CONFIG.h"
|
||||
|
||||
void BSP_BAT_Init(void);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //!@__BSP_BAT_H__
|
|
@ -0,0 +1,44 @@
|
|||
#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..");
|
||||
}
|
|
@ -124,6 +124,8 @@ void BSP_KEY_EnterLowpower(void)
|
|||
// PWR_PeriphWakeUpCfg(ENABLE, RB_SLP_GPIO_WAKE, Long_Delay);
|
||||
PWR_PeriphWakeUpCfg(ENABLE, RB_GPIO_WAKE_MODE | RB_SLP_GPIO_WAKE, Long_Delay);
|
||||
|
||||
PWR_PeriphWakeUpCfg(ENABLE, RB_SLP_GPIO_WAKE | RB_SLP_BAT_WAKE, Long_Delay);
|
||||
|
||||
BSP_RequestSleep();
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Description : source file(ch585/ch584)
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
|
@ -28,7 +28,7 @@ void PWR_DCDCCfg(FunctionalState s)
|
|||
|
||||
if(s == DISABLE)
|
||||
{
|
||||
|
||||
|
||||
adj &= ~RB_DCDC_CHARGE;
|
||||
plan &= ~(RB_PWR_DCDC_EN | RB_PWR_DCDC_PRE); // ÅÔ· DC/DC
|
||||
sys_safe_access_enable();
|
||||
|
@ -227,7 +227,7 @@ void PowerMonitor(FunctionalState s, VolM_LevelypeDef vl)
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
cfg = vl & 0x03;
|
||||
ctrl = RB_BAT_DET_EN;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ void LowPower_Sleep(uint16_t rm)
|
|||
flash_sck = R8_FLASH_SCK;
|
||||
|
||||
sys_safe_access_enable();
|
||||
R8_BAT_DET_CTRL = 0; // 关闭电压监控
|
||||
// R8_BAT_DET_CTRL = 0; // 关闭电压监控
|
||||
sys_safe_access_disable();
|
||||
sys_safe_access_enable();
|
||||
R8_XT32M_TUNE = x32Mpw;
|
||||
|
|
Loading…
Reference in New Issue