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.
129 lines
2.9 KiB
129 lines
2.9 KiB
////////////////////////////////////////////////////////////////////////////
|
|
///@copyright Copyright (c) 2018, 传控科技 All rights reserved.
|
|
///-------------------------------------------------------------------------
|
|
/// @file bsp_drv.c
|
|
/// @brief bsp @ driver config
|
|
///-------------------------------------------------------------------------
|
|
/// @version 1.0
|
|
/// @author CC
|
|
/// @date 20180331
|
|
/// @note cc_AS_stc02
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "app_drv.h"
|
|
#include "../clib/clib.h"
|
|
#include "../app/app_common.h"
|
|
#include "../app/app_task_485.h"
|
|
#include "../app/app_task_gm35.h"
|
|
#include "../msp/uart3.h"
|
|
|
|
/// reg.H,reg.L data0 data1 data2;
|
|
/// (reg.HL)=data0 (reg.HL+1)=data1 (reg.HL+2)=data2 (reg.HL+3)=data3
|
|
/// 0x0f 0----14 15
|
|
#if 0
|
|
TS_drv_ ts_drv[TS_DRV_MAX]=
|
|
{
|
|
0x0e,NULL, /// FE 01 02 03 04
|
|
0x12,NULL, //uart0 reply
|
|
0x0d,NULL, //433 camera //fd 01 02 03 06
|
|
0x99,NULL, //a9 gprs
|
|
0x00,NULL,
|
|
};
|
|
#endif
|
|
|
|
#if 0
|
|
|
|
void L3_task_a9_rcv_handle(TS_Handle_PH3 *p)
|
|
{
|
|
if (1 == p->ok)
|
|
{
|
|
TS_PH3_ccmodbus ccmodbus;
|
|
byte_copy_uc((U8*)&ccmodbus,(U8*)&p->ts_ccmodbus,p->ts_ccmodbus.num + 3);
|
|
p->ok = 0;
|
|
|
|
g_at_send_status.tcp_last_recv_stmp = s_nos_tick.t_1s;
|
|
L3_protocol_handler_uart0_fun(&ccmodbus,1);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
|
|
U8 array[D_s_SSTR_0D0A_len+1];
|
|
|
|
void L3_UARTcom4_exp_protocol(TS_Handle_0d0a *p)
|
|
{
|
|
if (1 == p->ok )
|
|
{
|
|
#if 0
|
|
//U8 array[D_s_SSTR_0D0A_len+1];
|
|
U8 num = p->buf[0];
|
|
byte_copy_uc(array,p->buf+1,num);
|
|
|
|
array[num] = 0;
|
|
L3_protocol_handler_uart4_fun(array);
|
|
p->ok = 0;
|
|
#else
|
|
g_at_send_status.gprs_last_recv_stmp = s_nos_tick.t_1s;
|
|
L3_protocol_handler_uart4_fun(p->buf+1);
|
|
p->ok = 0;
|
|
#endif
|
|
}
|
|
}
|
|
|
|
//FF FE 05 00 00 28 FC CC 从FF开始校验
|
|
int L3_checkCrc16(TS_PH3_ccmodbus *ccmodbus)
|
|
{
|
|
U8 crc[2];
|
|
crc16(crc,&ccmodbus->filter1,ccmodbus->num + 3 - 2);
|
|
if(crc[0] == ccmodbus->buf[ccmodbus->num-2-2] && crc[1] == ccmodbus->buf[ccmodbus->num-2-1])
|
|
{
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void L3_UARTcom0_exp_protocol(TS_Handle_PH3 *p)
|
|
{
|
|
if (1 == p->ok)
|
|
{
|
|
if(L3_checkCrc16(&p->ts_ccmodbus))
|
|
{
|
|
switch(p->ts_ccmodbus.slaver)
|
|
{
|
|
case SLAVER_RFID:
|
|
L0_uart0_uc('r');
|
|
L0_uart0_uchex(p->ts_ccmodbus.buf[0]);
|
|
if(p->ts_ccmodbus.buf[0] != G._rfid) //rfid发生改变
|
|
{
|
|
G.rfid = G._rfid = p->ts_ccmodbus.buf[0];
|
|
}
|
|
break;
|
|
case SLAVER_COM0:
|
|
L3_protocol_handler_uart0_fun(&p->ts_ccmodbus);
|
|
break;
|
|
}
|
|
}
|
|
p->ok = 0;
|
|
}
|
|
}
|
|
|
|
|
|
void L3_UARTcom3_exp_protocol(TS_Handle_PH3 *p)
|
|
{
|
|
if (1 == p->ok)
|
|
{
|
|
if(L3_checkCrc16(&p->ts_ccmodbus))
|
|
{
|
|
L0_uart0_uc('r');
|
|
L0_uart0_uchex(p->ts_ccmodbus.buf[0]);
|
|
|
|
if(p->ts_ccmodbus.buf[0] != G._rfid) //rfid发生改变
|
|
{
|
|
G.rfid = G._rfid = p->ts_ccmodbus.buf[0];
|
|
}
|
|
}
|
|
p->ok = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|