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

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, NULL,
4096, 4096,
20); 20);
os_thread_create(&sertrf.pc_thread,
"pc_thread",
pc_thread,
NULL,
4096,
20);
os_thread_create(&sertrf.task_thread, os_thread_create(&sertrf.task_thread,
"task_thread", "task_thread",
task_thread, task_thread,
@@ -34,6 +40,7 @@ void sertrf_start(void)
2048, 2048,
10); 10);
} }
//因为 串口
void embedded_thread(void* arg) void embedded_thread(void* arg)
{ {
while(true) while(true)
@@ -49,7 +56,17 @@ void embedded_thread(void* arg)
// SYS_LOG_INF("data : %s", data); // SYS_LOG_INF("data : %s", data);
pc_device_write(&sertrf.device, data, embedded_size); 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); uint32_t pc_size = pc_device_get_rx_length(&sertrf.device);
if(pc_size > 0) if(pc_size > 0)
@@ -66,6 +83,7 @@ void embedded_thread(void* arg)
os_thread_sleep(1); os_thread_sleep(1);
} }
} }
void task_thread(void* arg) void task_thread(void* arg)
{ {
while(true) while(true)
@@ -75,8 +93,8 @@ void task_thread(void* arg)
if(sertrf.device.connect_pc > DISCONNECT) if(sertrf.device.connect_pc > DISCONNECT)
{ {
size_t end_time = 0; static size_t end_time = 0;
if(start_time - end_time > 1000) if(start_time - end_time > 2000)
{ {
switch(get_protocol_status()) switch(get_protocol_status())
{ {

View File

@@ -4,11 +4,12 @@
#include "../led_strip/led_strip.h" #include "../led_strip/led_strip.h"
#include "key.h" #include "key.h"
#include "protocol/p_protocol.h" #include "protocol/p_protocol.h"
#include "protocol/kuyi_protl.h"
typedef struct typedef struct
{ {
device_t device; device_t device;
os_thread_t embedded_thread; os_thread_t embedded_thread;
os_thread_t pc_thread;
os_thread_t task_thread; os_thread_t task_thread;
}sertrf_t; }sertrf_t;