优化关机代码,解决烧录后不重启,提示bt核没响应问题。
authorSnickerSun <snickersun@163.com>
Sun, 3 Nov 2024 04:09:33 +0000 (12:09 +0800)
committerSnickerSun <snickersun@163.com>
Sun, 3 Nov 2024 04:09:33 +0000 (12:09 +0800)
code/sdk/application/brandy/brandy_standard/board_init.c
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h

index 0c9d428..7cb88a7 100755 (executable)
@@ -157,7 +157,7 @@ void check_pwrkey_3s(void)
         if(pressed_count < PRESS_COUNT_LIMIT )\r
         {\r
             PRINT("not pressed 3 seconds , poweroff!"NEWLINE);\r
-            uapi_poweroff_device();\r
+            mcu_poweroff();\r
         }\r
         PRINT("bootup continue pressed %d pressed count %d"NEWLINE,g_pwrkey_press_state==PRESSED?1:0,pressed_count);\r
 \r
index 0b57926..2ddb1a8 100644 (file)
@@ -161,9 +161,57 @@ uint32_t zh_set_sn(uint8_t *buf_sn, uint32_t len_sn)
 
 }
 
-extern uint32_t mcu_os_sys_reset(uint8_t *para, uint32_t para_len);
-extern void uapi_sys_shipmode(uint32_t arg);
-extern void cm_sync_all_config_to_disk(void);
+#include "pm_control.h"
+#include "non_os_reboot.h"
+#define PM_SHIPMODE_DELAY_SLEEP_MS   100
+
+void mcu_reset(void)
+{
+    set_cpu_utils_reset_cause(REBOOT_CAUSE_APPLICATION_SYSRESETREQ);
+    hal_reboot_chip();    
+}
+static void poweroff_bt_dsp_display(void)
+{
+    uapi_pm_control(PM_BT_POWER_OFF);
+    uapi_pm_control(PM_DSP_POWER_OFF);
+    uapi_pm_control(PM_DISPLAY_POWER_OFF);
+
+}
+void mcu_poweroff(void)
+{
+    /* clr ulp int and event */
+    writel(0x5702C1E4, 0x3F);
+    writel(0x5702C1EC, 0x3F);
+    osDelay(PM_SHIPMODE_DELAY_SLEEP_MS);
+
+    reg16_clrbit(0x5702c508, POS_14);
+    writew(0x5700450c, 0x100);
+
+    // gpio
+    writew(0x5702C200, 0x0);
+    writew(0x5702C204, 0x0);
+    writew(0x5702C208, 0x0);
+    writew(0x5702C20c, 0x0);
+    writew(0x5702C210, 0x0);
+
+    writew(0x5702c200, 0x7);
+    writew(0x57030004, 0x0);
+    writew(0x57030038, 0x1);
+    writew(0x5703003c, 0x1);
+    writew(0x57030034, 0x0);
+    writew(0x57030030, 0x1);
+
+    writew(0x570040d8, 0xc000);
+    writew(0x5702c028, 0x0);
+    writew(0x5702c024, 0x3);
+    writew(0x5702c1d0, 0x1);
+    writew(0x5702C038, 0x0);
+    writew(0x5702C1F0, 0x1C);
+    writew(0x5702C110, 0x101);
+    writew(0x570040d0, 0x1);
+    writew(0x570040e0, 0x1);
+}
+
 //关机
 void uapi_poweroff_device(void)
 {
@@ -173,20 +221,33 @@ void uapi_poweroff_device(void)
     //关机保存
     start_report_log();
     osDelay(50);
+    //同步nand文件系统,重启mount速度快
     reset_deal_with_fs();
     osDelay(50);
-    uapi_sys_shipmode(0);
+// uapi_sys_shipmode(0);
+    uint32_t irq = osal_irq_lock();
+    poweroff_bt_dsp_display();
+    mcu_poweroff();
+    osal_irq_restore(irq);
+
 }
+
+
+
 //重启
 void uapi_reboot_device(void)
 {
     //重启前要保存时间
     uapi_calendar_store_date();
-
     //重启保存
     stop_report_log();
+//   mcu_os_sys_reset(NULL,NULL);
+    osDelay(50);
+    //同步nand文件系统,重启mount速度快
+    reset_deal_with_fs();
+    osDelay(50);
 
-    mcu_os_sys_reset(NULL,NULL);
+    mcu_reset();
 }
 
 
index e2b9a91..eb96191 100644 (file)
@@ -378,6 +378,10 @@ errcode_t touch_resume_in_cmd_queue(void);
 void BtInitSpp(void);
 
 
+
+void mcu_reset(void);
+void mcu_poweroff(void);
+
 #include "custom_utilscpp.h"