Răsfoiți Sursa

fix: 更正uart回调不能正确判断出uart0的bug,可能会修好https://gitee.com/openLuat/luatos-soc-air101/pulls/1

chenxuuu 4 ani în urmă
părinte
comite
f67f061602

+ 9 - 2
app/port/luat_shell_air101.c

@@ -3,10 +3,13 @@
 
 #define LUAT_LOG_TAG "luat.shell"
 #include "luat_log.h"
+#include "wm_uart.h"
 
 static int drv = -1;
 #define CONSOLE_BUF_SIZE   512
 
+extern struct tls_uart_port uart_port[TLS_UART_MAX];
+
 typedef struct console_st
 {
     size_t rx_data_len;
@@ -82,8 +85,12 @@ void luat_shell_notify_recv(void) {
 }
 
 int16_t demo_console_rx(uint16_t len, void* user_data){
-    ShellConsole.rx_data_len += len;
-    luat_shell_notify_read();
+	int uartid = (int)user_data;
+	if(uartid >= 100)
+	{
+		ShellConsole.rx_data_len = CIRC_CNT(uart_port[0].recv.head, uart_port[0].recv.tail, TLS_UART_RX_BUF_SIZE);
+    	luat_shell_notify_read();
+	}
     return 0;
 }
 

+ 2 - 2
app/port/luat_uart_air101.c

@@ -28,7 +28,7 @@ static s16 uart_input_cb(u16 len, void* user_data)
 {
     int uartid = (int)user_data;
     //不是fifo超时回调
-    if(uartid <= MAX_DEVICE_COUNT)
+    if(uartid < 100)
     {
         //未读取长度够不够?
         if(CIRC_CNT(uart_port[uartid].recv.head, uart_port[uartid].recv.tail, TLS_UART_RX_BUF_SIZE)
@@ -37,7 +37,7 @@ static s16 uart_input_cb(u16 len, void* user_data)
     }
     else//是fifo超时回调
     {
-        uartid /= 10;
+        uartid -= 100;
     }
 
     rtos_msg_t msg;

BIN
lib/libdrivers.a


+ 3 - 3
platform/drivers/uart/wm_uart.c

@@ -623,7 +623,7 @@ ATTRIBUTE_ISR void UART0_IRQHandler(void)
     }
     if (intr_src & UIS_RX_FIFO_TIMEOUT)
     {
-        port->rx_callback(0, (void*)((int)port->priv_data*10));
+        port->rx_callback(0, (void*)((int)port->priv_data+100));
     }
     csi_kernel_intrpt_exit();
 }
@@ -730,7 +730,7 @@ ATTRIBUTE_ISR void UART1_IRQHandler(void)
     }
     if (intr_src & UIS_RX_FIFO_TIMEOUT)
     {
-        port->rx_callback(0, (void*)((int)port->priv_data*10));
+        port->rx_callback(0, (void*)((int)port->priv_data+100));
     }
     csi_kernel_intrpt_exit();
 }
@@ -818,7 +818,7 @@ ATTRIBUTE_ISR void UART2_4_IRQHandler(void)
     }
     if (intr_src & UIS_RX_FIFO_TIMEOUT)
     {
-        port->rx_callback(0, (void*)((int)port->priv_data*10));
+        port->rx_callback(0, (void*)((int)port->priv_data+100));
     }
     port->regs->UR_INTS = intr_src;
     csi_kernel_intrpt_exit();