掉电检测优化
This commit is contained in:
parent
6e2b230c5d
commit
867e3a21a7
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"selectedCompiler": "c:\\MounRiver\\MounRiver_Studio2\\resources\\app\\resources\\win32\\components\\WCH\\Toolchain\\RISC-V Embedded GCC12\\bin\\riscv-wch-elf-g++.exe",
|
||||
"selectedTarget": "riscv32",
|
||||
"compilerArguement": [],
|
||||
"includePaths": [],
|
||||
"defines": [],
|
||||
"c_standard": "gnu99",
|
||||
"cpp_standard": "c++14",
|
||||
"check_flag": true
|
||||
}
|
|
@ -228,13 +228,14 @@ int main(void)
|
|||
// 检测上电/掉电复位标志
|
||||
if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET) // TODO:这块超级电容会造成掉电重启,并且标志是上电复位,只能通过其超级电容造成复位时事件创建失败进行判断,不治本
|
||||
{
|
||||
RCC_ClearFlag();
|
||||
// RCC_ClearFlag();
|
||||
Send_Laser_Alarm_Event(kPowerOnEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Send_Laser_Alarm_Event(kPreheatingEvent); // 这一句的作用是设备不是掉电重启的情况,直接进入预热模式
|
||||
}
|
||||
RCC_ClearFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -410,6 +411,9 @@ int main(void)
|
|||
else if (received_event & Get_Sys_Event_Flag(kPowerDownEvent)) // 掉电
|
||||
{
|
||||
LOG_D("掉电模式");
|
||||
|
||||
ADC_ITConfig(USED_ADC, ADC_IT_AWD, DISABLE);
|
||||
|
||||
H308_PWR_OFF;
|
||||
SysControl.last_status = SysControl.status;
|
||||
SysControl.status = kPowerDownEvent;
|
||||
|
@ -435,7 +439,9 @@ int main(void)
|
|||
LOG_D("cnt2 = %d", cnt);
|
||||
cnt++;
|
||||
}
|
||||
__disable_irq(); // 关闭中断
|
||||
NVIC_SystemReset(); // 直接重启系统
|
||||
|
||||
}
|
||||
else if (received_event & Get_Sys_Event_Flag(kSelfCheckEvent)) // 自检
|
||||
{
|
||||
|
|
|
@ -136,7 +136,7 @@ void ADC1_2_IRQHandler(void)
|
|||
{
|
||||
ADC_ClearITPendingBit(ADC1, ADC_IT_AWD);
|
||||
|
||||
ADC_ITConfig(USED_ADC, ADC_IT_AWD, DISABLE);
|
||||
// ADC_ITConfig(USED_ADC, ADC_IT_AWD, DISABLE);
|
||||
LOG_D("Enter AnalogWatchdog Interrupt");
|
||||
Send_Laser_Alarm_Event(kPowerDownEvent);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue