将收发分为俩个线程,并修复闪红灯问题

This commit is contained in:
OPTOC
2025-09-05 15:26:57 +08:00
parent bd9ffa3de2
commit 25b994cb65
2 changed files with 23 additions and 4 deletions

View File

@@ -27,6 +27,12 @@ void sertrf_start(void)
NULL,
4096,
20);
os_thread_create(&sertrf.pc_thread,
"pc_thread",
pc_thread,
NULL,
4096,
20);
os_thread_create(&sertrf.task_thread,
"task_thread",
task_thread,
@@ -34,6 +40,7 @@ void sertrf_start(void)
2048,
10);
}
//因为 串口
void embedded_thread(void* arg)
{
while(true)
@@ -49,7 +56,17 @@ void embedded_thread(void* arg)
// SYS_LOG_INF("data : %s", data);
pc_device_write(&sertrf.device, data, embedded_size);
}
printf_chill_time(10,1000);
//需要添加一些延时,否则会卡死,导致看门狗复位
// vTaskDelay(( TickType_t ) 1000 / configTICK_RATE_HZ);
os_thread_sleep(1);
}
}
void pc_thread(void* arg)
{
while(true)
{
uint32_t pc_size = pc_device_get_rx_length(&sertrf.device);
if(pc_size > 0)
@@ -66,6 +83,7 @@ void embedded_thread(void* arg)
os_thread_sleep(1);
}
}
void task_thread(void* arg)
{
while(true)
@@ -75,8 +93,8 @@ void task_thread(void* arg)
if(sertrf.device.connect_pc > DISCONNECT)
{
size_t end_time = 0;
if(start_time - end_time > 1000)
static size_t end_time = 0;
if(start_time - end_time > 2000)
{
switch(get_protocol_status())
{