You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

303 lines
6.5 KiB

1 year ago
/*****************************************************************************
update by cc @201501101001
.
uartcom/uartlib.c:
(线),
(lcd等固屏输出的)使
void Lc_print(void (*L0pf_send_uc)(char ww), char *dat,...)
-----------------------------------------------------------------------------------------
uartcom/uartcom0
uart相关的通讯协议 com + n
uart口来对应
typedef struct _ts_lcm_pro_; ? LCM的协议------------
L3_UARTcom0_exp_protocol
-----------------------------------------------------------------------------------------
uartcom/uprotocol: uartcom + n服务的
struct _s_protocol_ ()------struct _s_protocol_
void L1_uart_2buf(struct _s_protocol_ *p)
--------------------------------------------------------------------------------------------
msp/uartx.c cpu相关
L0_UART0_Init
UART0_IRQHandler
L0_Usend_uc----------s_at0
-----------------------------------------------------------------------------------------
********************************************************************************/
#include "tpc_road.h"
///#include "c_lib.h"
///TS_pp_debug_ ts_debug_rec;
///TS_s2b_debug_ ts_s2b1_road;////协议处理变量
void L1_s2b_road_init(u8 ch) //
{
ts_Urec[ch].ok = 0;
ts_Urec[ch].debugok = 0;
ts_Urec[ch].head = 0;
ts_Urec[ch].num = 0;
///printf("\r\nw ts_Urec[D_UART1].max = %d num = %d",(int)ts_Urec[D_UART1].rmax,(int)ts_Urec[D_UART1].num);
}
//MODBUS协议解析函数 012345
//透传协议 就像路过 有时间超时溢出 收到啥就向上传递啥
void L1_s2b_road(u8 ch)
{
/// ts_Urec[ch].ok = 1;
if(ts_Urec[ch].head == 0)
{
{
ts_Urec[ch].head = 1;
ts_Urec[ch].num = 0;
ts_Urec[ch].ok = 0;
ts_Urec[ch].fifo = 0;
ts_Urec[ch].sp[ts_Urec[ch].num ] = ts_Urec[ch].reg;
/// ts_Urec[ch].sp[ts_Urec[ch].num ] = SBUF;// L0_uart1_get();;
ts_Urec[ch].num ++;
}
}
else
{
ts_Urec[ch].sp[ts_Urec[ch].num ] = ts_Urec[ch].reg;
ts_Urec[ch].num ++;
/// ts_Urec[ch].len = ts_Urec[ch].num;
ts_Urec[ch].fifo = ts_Urec[ch].num;
if(ts_Urec[ch].num < ts_Urec[ch].rmax)
{
}else
{////保护使用
ts_Urec[ch].ok = 2;
ts_Urec[ch].debugok = 1;
ts_Urec[ch].head = 0;
ts_Urec[ch].num = 0;
}
}
}
void L1_s2b_road2(u8 ch)
{
if(ts_Urec[ch].head == 0)
{
{
ts_Urec[ch].head = 1;
ts_Urec[ch].num = 0;
ts_Urec[ch].ok = 0;
ts_Urec[ch].fifo = 0;
ts_Urec[ch].sp[ts_Urec[ch].num ++] = ts_Urec[ch].reg;
}
}
else
{
ts_Urec[ch].sp[ts_Urec[ch].num ++] = ts_Urec[ch].reg;
/// ts_Urec[ch].len = ts_Urec[ch].num;
ts_Urec[ch].fifo = ts_Urec[ch].num;
if(ts_Urec[ch].num < ts_Urec[ch].rmax)
{
}else
{////保护使用
ts_Urec[ch].ok = 2;
ts_Urec[ch].debugok = 1;
ts_Urec[ch].head = 0;
ts_Urec[ch].num = 0;
}
}
}
void L1_s2b_road3(u8 ch)
{
if(ts_Urec[ch].head == 0)
{
{
ts_Urec[ch].head = 1;
ts_Urec[ch].num = 0;
ts_Urec[ch].ok = 0;
ts_Urec[ch].fifo = 0;
ts_Urec[ch].sp[ts_Urec[ch].num ++] = ts_Urec[ch].reg;
}
}
else
{
ts_Urec[ch].sp[ts_Urec[ch].num ++] = ts_Urec[ch].reg;
/// ts_Urec[ch].len = ts_Urec[ch].num;
ts_Urec[ch].fifo = ts_Urec[ch].num;
if(ts_Urec[ch].num < ts_Urec[ch].rmax)
{
}else
{////保护使用
ts_Urec[ch].ok = 2;
ts_Urec[ch].debugok = 1;
ts_Urec[ch].head = 0;
ts_Urec[ch].num = 0;
}
}
}
void L1_s2b_road4(u8 ch)
{
if(ts_Urec[ch].head == 0)
{
{
ts_Urec[ch].head = 1;
ts_Urec[ch].num = 0;
ts_Urec[ch].ok = 0;
ts_Urec[ch].fifo = 0;
ts_Urec[ch].sp[ts_Urec[ch].num ++] = ts_Urec[ch].reg;
}
}
else
{
ts_Urec[ch].sp[ts_Urec[ch].num ++] = ts_Urec[ch].reg;
/// ts_Urec[ch].len = ts_Urec[ch].num;
ts_Urec[ch].fifo = ts_Urec[ch].num;
if(ts_Urec[ch].num < ts_Urec[ch].rmax)
{
}else
{////保护使用
ts_Urec[ch].ok = 2;
ts_Urec[ch].debugok = 1;
ts_Urec[ch].head = 0;
ts_Urec[ch].num = 0;
}
}
}
/******************************************************************************
** End Of File
******************************************************************************/
/******************************************************************************
** c func lib
void L1_s2b_road(TS_rec_road_ *p)
{
/// p->ok = 1;
if(p->head == 0)
{
{
p->head = 1;
//// p->max = D_debug_max;
p->num = 0;
p->ok = 0;
p->fifo = 0;
p->sp[p->num ++] = p->reg;
}
}
else
{
p->sp[p->num ++] = p->reg;
/// p->len = p->num;
p->fifo = p->num;
if(p->num < p->rmax)
{
}else
{////保护使用
p->ok = 2;
p->debugok = 1;
p->head = 0;
p->num = 0;
}
}
}
//透传协议 就像路过 有时间超时溢出 收到啥就向上传递啥
void L1_s2b_road2(TS_rec_road_ *p)
{
/// p->ok = 1;
if(p->head == 0)
{
{
p->head = 1;
//// p->max = D_debug_max;
p->num = 0;
p->ok = 0;
p->fifo = 0;
p->sp[p->num ++] = p->reg;
}
}
else
{
p->sp[p->num ++] = p->reg;
/// p->len = p->num;
p->fifo = p->num;
if(p->num < p->rmax)
{
}else
{////保护使用
p->ok = 2;
p->debugok = 1;
p->head = 0;
p->num = 0;
}
}
}
void L1_s2b_road3(TS_rec_road_ *p)
{
/// p->ok = 1;
if(p->head == 0)
{
{
p->head = 1;
//// p->max = D_debug_max;
p->num = 0;
p->ok = 0;
p->fifo = 0;
p->sp[p->num ++] = p->reg;
}
}
else
{
p->sp[p->num ++] = p->reg;
/// p->len = p->num;
p->fifo = p->num;
if(p->num < p->rmax)
{
}else
{////保护使用
p->ok = 2;
p->debugok = 1;
p->head = 0;
p->num = 0;
}
}
}
void L1_s2b_road4(TS_rec_road_ *p)
{
/// p->ok = 1;
if(p->head == 0)
{
{
p->head = 1;
//// p->max = D_debug_max;
p->num = 0;
p->ok = 0;
p->fifo = 0;
p->sp[p->num ++] = p->reg;
}
}
else
{
p->sp[p->num ++] = p->reg;
/// p->len = p->num;
p->fifo = p->num;
if(p->num < p->rmax)
{
}else
{////保护使用
p->ok = 2;
p->debugok = 1;
p->head = 0;
p->num = 0;
}
}
}
******************************************************************************/