Kaynağa Gözat

fix: libgnss,需要兼容drv_uart的调用,否则无法读到任何数据

Wendal Chen 11 ay önce
ebeveyn
işleme
bc7eaac7e8
2 değiştirilmiş dosya ile 17 ekleme ve 1 silme
  1. 8 0
      components/minmea/luat_gnss.c
  2. 9 1
      luat/modules/luat_lib_uart.c

+ 8 - 0
components/minmea/luat_gnss.c

@@ -5,6 +5,10 @@
 #include "luat_rtc.h"
 #include "luat_mcu.h"
 
+#ifdef LUAT_USE_DRV_UART
+#include "luat/drv_uart.h"
+#endif
+
 #define LUAT_LOG_TAG "gnss"
 #include "luat_log.h"
 
@@ -22,7 +26,11 @@ void luat_libgnss_uart_recv_cb(int uart_id, uint32_t data_len) {
     // LLOGD("uart recv cb");
     int len = 0;
     while (1) {
+        #ifdef LUAT_USE_DRV_UART
+        len = luat_drv_uart_read(uart_id, libgnss_recvbuff, RECV_BUFF_SIZE - 1);
+        #else
         len = luat_uart_read(uart_id, libgnss_recvbuff, RECV_BUFF_SIZE - 1);
+        #endif
         if (len < 1 || len >= RECV_BUFF_SIZE)
             break;
         if (libgnss_route_uart_id > 0) {

+ 9 - 1
luat/modules/luat_lib_uart.c

@@ -322,7 +322,11 @@ static int luat_uart_soft_write(const uint8_t *data, uint32_t len)
 }
 #endif
 void luat_uart_set_app_recv(int id, luat_uart_recv_callback_t cb) {
-    if (luat_uart_exist(id)) {
+	#ifndef LUAT_USE_DRV_UART
+	#else
+    if (luat_uart_exist(id)) 
+	#endif
+	{
         uart_app_recvs[id] = cb;
         luat_setup_cb(id, 1, 0); // 暂时覆盖
     }
@@ -772,7 +776,11 @@ static int l_uart_exist(lua_State *L)
 	}
 	return 1;
 #else
+	#ifdef LUAT_USE_DRV_UART
+	lua_pushboolean(L, luaL_checkinteger(L,1) <= LUAT_VUART_ID_0);
+	#else
     lua_pushboolean(L, luat_uart_exist(luaL_checkinteger(L,1)));
+	#endif
     return 1;
 #endif
 }