ppp中断式读取uart,可以正常通讯一段时间。效率还是不够。
author孙春阳 <snickersun@163.com>
Sun, 5 Oct 2025 06:46:12 +0000 (14:46 +0800)
committer孙春阳 <snickersun@163.com>
Sun, 5 Oct 2025 06:46:12 +0000 (14:46 +0800)
code/sdk/drivers/chips/brandy/porting/uart/uart_porting.c
code/sdk/zhihui/ppp/include/ppp_interrupt.h
code/sdk/zhihui/ppp/src/ppp_serial.c

index 943f149..35e02ec 100644 (file)
 #ifdef BUILD_APPLICATION_SSB
 #define UART_RX_BUFFER_SIZE 1
 #else
+
+#if defined(SUPPORT_PPP_SERVICE)    
+#define UART_RX_BUFFER_SIZE 2048
+// #warning "UART_RX_BUFFER_SIZE is 2048"
+#else
 #define UART_RX_BUFFER_SIZE 56
+// #warning "UART_RX_BUFFER_SIZE is 56"
+#endif
+
 #endif
 
 #define AT_BLE_HEADER_LENGTH 49
index 19bdd8f..4f1483f 100644 (file)
@@ -30,6 +30,8 @@ typedef struct {
     
     uint32_t dropped_not_initialized;    // 因PPP未初始化丢弃的字节数
     uint32_t dropped_lwip_error;         // 因lwIP错误丢弃的字节数
+    uint32_t dropped_malloc_fail;        // 因内存分配失败丢弃的字节数
+    uint32_t dropped_queue_full;         // 因消息队列满丢弃的字节数
 } ppp_interrupt_stats_t;
 
 /**
@@ -40,21 +42,13 @@ typedef struct {
  */
 void ppp_uart_rx_interrupt_handler(const void *buffer, uint16_t length, bool error);
 
-/**
- * @brief 获取UART硬件缓冲区配置(供外部UART初始化使用)
- * @param rx_buffer 返回接收缓冲区指针
- * @param buffer_size 返回缓冲区大小
- */
-void ppp_interrupt_get_buffer_config(void **rx_buffer, uint32_t *buffer_size);
-
 /**
  * @brief 启用PPP UART中断接收
  * @return PPP_ERR_OK 成功,其他值失败
  * 
  * @note 调用此函数前:
  *       1. ppp_serial必须已初始化(UART总线号从ppp_serial_get_uart_bus()获取)
- *       2. UART必须已经初始化并配置了硬件缓冲区
- *       3. 使用 ppp_interrupt_get_buffer_config() 获取缓冲区配置
+ *       2. UART必须已经初始化(硬件缓冲区在uart_porting.c中配置)
  */
 ppp_error_t ppp_interrupt_enable(void);
 
index a444b64..3a1e45f 100644 (file)
@@ -2,7 +2,6 @@
 #include "ppp_config.h"
 #include "ppp_types.h"
 #include "ppp_debug.h"
-#include "ppp_interrupt.h"  // 添加此头文件以访问 ppp_interrupt_get_buffer_config
 #include "uart.h"  // 简化路径
 #include "schedule/osal_task.h"
 #include "semaphore/osal_semaphore.h"
@@ -172,26 +171,14 @@ ppp_error_t ppp_serial_init(const ppp_serial_config_t *config)
     // }
     // PPP_DEBUG_INFO("UART deinitialized successfully");
 
-    /* 初始化UART - 使用PPP中断模块提供的硬件缓冲区配置 */
-    PPP_DEBUG_DEBUG("Calling uapi_uart_init with buffer config...");
-    
-    // 从ppp_interrupt模块获取硬件缓冲区配置
-    void *hw_buffer = NULL;
-    uint32_t hw_buffer_size = 0;
-    ppp_interrupt_get_buffer_config(&hw_buffer, &hw_buffer_size);
-    
-    uart_buffer_config_t hw_buffer_config = {
-        .rx_buffer = hw_buffer,
-        .rx_buffer_size = hw_buffer_size
-    };
-    
-    PPP_DEBUG_INFO("Using hardware buffer: %u bytes at 0x%p", hw_buffer_size, hw_buffer);
-    
-    errcode_t ret = uapi_uart_init(g_serial_ctx.uart_bus, 
-                                   &g_serial_ctx.pin_config,
-                                   &g_serial_ctx.uart_attr, 
-                                   NULL, 
-                                   &hw_buffer_config);  // 使用硬件缓冲区配置
+    /* 初始化UART */
+    PPP_DEBUG_DEBUG("Calling uapi_uart_init...");
+    // errcode_t ret = uapi_uart_init(g_serial_ctx.uart_bus, 
+    //                                &g_serial_ctx.pin_config,
+    //                                &g_serial_ctx.uart_attr, 
+    //                                NULL, 
+    //                                &g_serial_ctx.buffer_config);
+    errcode_t ret = uapi_uart_set_attr(g_serial_ctx.uart_bus, &g_serial_ctx.uart_attr);
     if (ret != ERRCODE_SUCC) {
         PPP_DEBUG_ERROR("Failed to initialize UART: error code = %d (0x%x)", ret, ret);
         PPP_DEBUG_ERROR("UART init failed with bus=%u, tx_pin=%u, rx_pin=%u, baudrate=%u", 
@@ -204,7 +191,7 @@ ppp_error_t ppp_serial_init(const ppp_serial_config_t *config)
         return PPP_ERR_UART;
     }
 
-    PPP_DEBUG_INFO("UART initialized successfully with %u-byte hardware buffer", hw_buffer_size);
+    PPP_DEBUG_INFO("UART initialized successfully (error code = %d)", ret);
 
     /* 创建同步对象 */
     PPP_DEBUG_DEBUG("Creating synchronization objects...");