移植到stm32f1,实现手动线赋码控制器功能
This commit is contained in:
@@ -167,7 +167,7 @@ static void protu_run(void *t)
|
||||
arr_appends(data,p->buff,p->buff_index);
|
||||
p->num_to_recv=0;
|
||||
p->buff_index=0;
|
||||
DBG_LOG("recv:%s",str_temp(arr_string(data)));
|
||||
//DBG_LOG("recv:%s",str_temp(arr_string(data)));
|
||||
decode_data=protu_try_decode(p,data);
|
||||
//DBG_LOG("decode:%s",str_temp(arr_string(decode_data)));
|
||||
if(p->codec)
|
||||
@@ -199,21 +199,12 @@ static void protu_set_endecode_fun(protu_def *u)
|
||||
static int protu_init(void)
|
||||
{
|
||||
const sys_param_def *par=sys_param();
|
||||
const char *name="uart4";
|
||||
if(strcmp((par->host_if),"utcp")==0)
|
||||
name="utcp";
|
||||
const char *name="uart1";
|
||||
protu_def *protu=protu_creat(dev_get(name));
|
||||
app_variable("protu",protu,0);
|
||||
|
||||
// 如果通信接口不是用的串口,则增加一个串口的通信
|
||||
if(strcmp(par->host_if,"uart4")==0)
|
||||
{
|
||||
app_variable("protu2",protu,0);
|
||||
}else
|
||||
{
|
||||
protu_def *protu2=protu_creat(dev_get("uart4"));
|
||||
app_variable("protu2",protu2,0);
|
||||
}
|
||||
// 复制一个引用,用于命令行调试
|
||||
app_variable("protu2",protu,0);
|
||||
return 0;
|
||||
}
|
||||
app_init_export(protu_init)
|
||||
@@ -234,7 +225,7 @@ protu_def *protu_creat(uart_def *uart)
|
||||
p->cmd=0xff;// 命令字不可能是0xff
|
||||
protu_set_endecode_fun(p);
|
||||
sprintf(name,"protu_t#%d",count);
|
||||
rt_thread_t rt_t=rt_thread_create(name,protu_run,p,2048,5,20);
|
||||
rt_thread_t rt_t=rt_thread_create(name,protu_run,p,1024,5,20);
|
||||
rt_thread_startup(rt_t);
|
||||
int bsp=sys_param()->uartbsp;
|
||||
if(bsp==9600)
|
||||
@@ -254,7 +245,7 @@ protu_def *protu_creat(uart_def *uart)
|
||||
|
||||
int protu_send(protu_def *p,array_def *data)
|
||||
{
|
||||
DBG_LOG("send:%s",str_temp(arr_string(data)));
|
||||
//DBG_LOG("send:%s",str_temp(arr_string(data)));
|
||||
return p->uart->write(p->uart,arr_data(data),arr_length(data));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user