4G打开就阻断接收UART输入指令,解决4G干扰造成的uart死机
authorSnickerSun <snickersun@163.com>
Thu, 12 Sep 2024 11:46:32 +0000 (19:46 +0800)
committerSnickerSun <snickersun@163.com>
Thu, 12 Sep 2024 11:46:32 +0000 (19:46 +0800)
code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h

index d2203a1..7591167 100755 (executable)
@@ -250,6 +250,12 @@ static uart_recovery_regs_t g_uart_recovery_reg[UART_BUS_MAX_NUMBER] = { 0 };
 #ifdef FT_SINGLE_UART
 void log_factory_at_callback(const void *buffer, uint16_t length, bool remaining)
 {
+#ifndef SUPPORT_RECOVERY_DISPLAY //判定是否是在编译RECOVERY image,本参数不支持RECOVERY
+    if (uapi_custom_uart_rx_enable_flag() == false)
+    {
+        return ;
+    }
+#endif
     log_uart_rx_callback(buffer, length, remaining);
     if (zdiag_is_enable() == false) {
         at_cmd_msg_receive_handler((uint8_t *)buffer, length);
index 51b0176..3991456 100644 (file)
@@ -1192,7 +1192,6 @@ void uapi_set4GCapability(bool isopen)
 {
     errcode_t ret = 0;
     void *tcp_thread_id = NULL;
-
     if(isopen)
     {
         power_on_cat1();
@@ -1200,6 +1199,9 @@ void uapi_set4GCapability(bool isopen)
         {
             uapi_dev_runtime_set_cat1_powerstat(1);
         }
+        /*4G 开电有时有干扰进日志串口,因此关闭日志串口*/
+        uapi_custom_set_uart_rx_enable_flag(false);
+
         #ifdef SUPPORT_TCPIP
             tcp_thread_id = tcp_get_thread_id();
             ret = uapi_resume_thread(tcp_thread_id);
@@ -1216,6 +1218,8 @@ void uapi_set4GCapability(bool isopen)
         {
             uapi_dev_runtime_set_cat1_powerstat(0);
         }
+        /*4G 开电有时有干扰进日志串口,因此关闭4G才开启日志串口*/
+        uapi_custom_set_uart_rx_enable_flag(true);
             
         #ifdef SUPPORT_TCPIP
             tcp_thread_id = tcp_get_thread_id();
@@ -3403,4 +3407,25 @@ errcode_t change_mac_from_chipinfo_map(uint32_t chipinfo_num)
     printf(" chipinfo 0x%08X not found !\n",chipinfo_num);
     return ERRCODE_FAIL;
 }
-#endif
\ No newline at end of file
+#endif
+
+
+static bool g_enable_uart_rx = true;
+/**
+ * return uart enable flag
+ *        true 代表 接收缓存
+ *        false 代表 不接收缓存
+*/
+bool uapi_custom_uart_rx_enable_flag(void)
+{
+    return g_enable_uart_rx;
+}
+
+
+/**
+ * 设置 uart rx enable flag
+*/
+void uapi_custom_set_uart_rx_enable_flag(bool enable_uart)
+{
+    g_enable_uart_rx = enable_uart;
+}
\ No newline at end of file
index b1b44ed..b549a80 100644 (file)
@@ -296,6 +296,19 @@ void start_save_file_thread(void);
 */
 bool check_file(char* buffer,int inputlen,char* outputfile,int max_outputsize);
 
+/**
+ * return uart enable flag
+ *        true 代表 接收缓存
+ *        false 代表 不接收缓存
+*/
+bool uapi_custom_uart_rx_enable_flag(void);
+
+
+/**
+ * 设置 uart rx enable flag
+*/
+void uapi_custom_set_uart_rx_enable_flag(bool enable_uart);
+
 #include "custom_utilscpp.h"