From 867e3a21a703d50373bb06fcadd4082e1df7f6ef Mon Sep 17 00:00:00 2001 From: stark1898y <1658608470@qq.com> Date: Thu, 23 Jan 2025 13:06:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=89=E7=94=B5=E6=A3=80=E6=B5=8B=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .mrs/mrs-setting.json | 10 ++++++++++ applications/main.c | 8 +++++++- bsp/src/bsp_vin_detection.c | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .mrs/mrs-setting.json diff --git a/.mrs/mrs-setting.json b/.mrs/mrs-setting.json new file mode 100644 index 0000000..434a9a0 --- /dev/null +++ b/.mrs/mrs-setting.json @@ -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 +} \ No newline at end of file diff --git a/applications/main.c b/applications/main.c index 3d7e784..57732a1 100644 --- a/applications/main.c +++ b/applications/main.c @@ -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)) // 自检 { diff --git a/bsp/src/bsp_vin_detection.c b/bsp/src/bsp_vin_detection.c index 1fb4c90..9e97843 100644 --- a/bsp/src/bsp_vin_detection.c +++ b/bsp/src/bsp_vin_detection.c @@ -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); }