Просмотр исходного кода

fix: 变通解决日志走uart1输出的bug, 但底层的printf先禁用了

Wendal Chen 1 год назад
Родитель
Сommit
489f742105
4 измененных файлов с 18 добавлено и 15 удалено
  1. 10 7
      app/main.c
  2. 0 3
      app/network/luat_wlan_air101.c
  3. 4 0
      app/port/luat_log_air101.c
  4. 4 5
      platform/arch/xt804/bsp/board_init.c

+ 10 - 7
app/main.c

@@ -109,13 +109,16 @@ void luat_fs_update_addr(void);
 void UserMain(void){
 	unsigned  char unique_id [20] = {0};
 
-	tls_uart_options_t opt = {0};
-	opt.baudrate = UART_BAUDRATE_B921600;
-	opt.charlength = TLS_UART_CHSIZE_8BIT;
-	opt.flow_ctrl = TLS_UART_FLOW_CTRL_NONE;
-	opt.paritytype = TLS_UART_PMODE_DISABLED;
-	opt.stopbits = TLS_UART_ONE_STOPBITS;
-	tls_uart_port_init(0, &opt, 0);
+	#ifdef LUAT_CONF_LOG_UART1
+	luat_uart_t uart1_conf = {
+		.id = 1,
+		.baud_rate = 921600,
+		.data_bits = 8,
+		.parity = 0,
+		.stop_bits = 1,
+	};
+	luat_uart_setup(&uart1_conf);
+	#endif
 
 	LLOGD("poweron: %s", reason[luat_pm_get_poweron_reason()]);
 	luat_fs_update_addr();

+ 0 - 3
app/network/luat_wlan_air101.c

@@ -616,9 +616,6 @@ static int is_mac_ok(u8 mac_addr[6]) {
 }
 
 void sys_mac_init() {
-#ifdef LUAT_CONF_LOG_UART1
-	luat_log_set_uart_port(1);
-#endif
 	u8 tmp_mac[6] = {0};
     u8 mac_addr[6] = {0};
 	u8 ap_mac[6] = {0};

+ 4 - 0
app/port/luat_log_air101.c

@@ -9,6 +9,9 @@
 extern luat_cmux_t cmux_ctx;
 #endif
 
+#ifdef LUAT_CONF_LOG_UART1
+#else
+
 static uint8_t luat_log_uart_port = 0;
 static uint8_t luat_log_level_cur = LUAT_LOG_DEBUG;
 
@@ -108,3 +111,4 @@ void luat_log_printf(int level, const char* _fmt, ...) {
     }
     luat_heap_free(tmp);
 }
+#endif

+ 4 - 5
platform/arch/xt804/bsp/board_init.c

@@ -97,14 +97,13 @@ static void uart1Init (int bandrate)
 #endif
 void board_init(void)
 {
-
-#ifndef LUAT_CONF_LOG_UART1
+#ifdef LUAT_CONF_LOG_UART1
     /* use uart0 as log output io */
     uart0Init(921600);
 #else
-    uart1_io_init();
+    // uart1_io_init();
     /* use uart1 as log output io */
-	uart1Init(921600);
-	set_printf_port(1);	
+	// uart1Init(921600);
+	set_printf_port(0xff);	
 #endif
 }