diff --git a/app/drivers/sertrf/sertrf.c b/app/drivers/sertrf/sertrf.c index 63d6f1f..36e7a0a 100644 --- a/app/drivers/sertrf/sertrf.c +++ b/app/drivers/sertrf/sertrf.c @@ -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()) { diff --git a/app/drivers/sertrf/sertrf.h b/app/drivers/sertrf/sertrf.h index 88ca35d..6c2d71f 100644 --- a/app/drivers/sertrf/sertrf.h +++ b/app/drivers/sertrf/sertrf.h @@ -4,11 +4,12 @@ #include "../led_strip/led_strip.h" #include "key.h" #include "protocol/p_protocol.h" - +#include "protocol/kuyi_protl.h" typedef struct { device_t device; os_thread_t embedded_thread; + os_thread_t pc_thread; os_thread_t task_thread; }sertrf_t;