forked from ccsens_hardware/stc_touch_pen
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.
142 lines
2.6 KiB
142 lines
2.6 KiB
4 years ago
|
//////////////////////////////////////////////////////////////////////////
|
||
|
/// COPYRIGHT NOTICE
|
||
|
/// Copyright (c) 2018, 传控科技
|
||
|
/// All rights reserved.
|
||
|
///
|
||
|
/// @file tpc_fsk.c
|
||
|
/// @brief transaction protocol control of fsk
|
||
|
///
|
||
|
///(本文件实现的功能的详述)
|
||
|
///
|
||
|
/// @version 1.1 CCsens technology
|
||
|
/// @author CC
|
||
|
/// @date 20150102
|
||
|
///
|
||
|
///
|
||
|
/// @version 1.2 CCsens technology
|
||
|
/// @author CC
|
||
|
/// @date 20180308
|
||
|
/// @info 整理
|
||
|
|
||
|
//
|
||
|
//////////////////////////////////////////////////////////////////////////
|
||
|
|
||
|
|
||
|
#ifndef __TPC_MODBUS_H_
|
||
|
#define __TPC_MODBUS_H_
|
||
|
|
||
3 years ago
|
#include "../clib/Type.h"
|
||
4 years ago
|
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
|
||
|
|
||
|
/**
|
||
|
* 用户协议
|
||
|
*/
|
||
|
enum MODBUS_OPER
|
||
|
{
|
||
|
MODBUS_OPER_READ = 0x03,
|
||
|
MODBUS_OPER_WRITE = 0x06,
|
||
|
MODBUS_OPER_WRITE_M = 0x10,
|
||
|
MODBUS_OPER_ERR = 0x8F,
|
||
3 years ago
|
MODBUS_OPER_AUTH = 0x90, //认证包
|
||
|
};
|
||
|
|
||
|
enum MODBUS_ERR_CODE
|
||
|
{
|
||
|
MODBUS_ERR_LEN = 0x01,
|
||
|
MODBUS_ERR_CRC = 0x02,
|
||
|
MODBUS_ERR_OPCODE = 0x03,
|
||
4 years ago
|
};
|
||
|
|
||
|
//协议类型: MODBUS RTU模式
|
||
3 years ago
|
#define D_s_PH4_modbus_max (32)
|
||
4 years ago
|
//#define D_s_PH4_modbus_max (64)
|
||
|
|
||
|
typedef struct ts_ph4_modbus
|
||
|
{
|
||
3 years ago
|
U8 salver; //从机地址
|
||
|
U8 oper; //功能码
|
||
|
U8 buf[D_s_PH4_modbus_max];
|
||
4 years ago
|
U8 crc[2];
|
||
3 years ago
|
U8 num;
|
||
4 years ago
|
}TS_PH4_modbus;
|
||
|
|
||
3 years ago
|
typedef struct s_modbus_03
|
||
|
{
|
||
|
U8 slaverId;
|
||
|
U16 reg;
|
||
|
U16 num;
|
||
|
}Modbus03;
|
||
|
|
||
4 years ago
|
typedef struct s_modbus_03_ack
|
||
|
{
|
||
|
U8 bytes;
|
||
3 years ago
|
U8 buf[D_s_PH4_modbus_max-1];
|
||
4 years ago
|
}Modbus03Ack;
|
||
|
|
||
3 years ago
|
typedef struct s_modbus_06
|
||
|
{
|
||
|
U16 reg;
|
||
|
U16 val;
|
||
|
}Modbus06;
|
||
|
|
||
4 years ago
|
typedef struct s_modbus_06_ack
|
||
|
{
|
||
|
U16 reg;
|
||
|
U16 val;
|
||
|
}Modbus06Ack;
|
||
|
|
||
3 years ago
|
typedef struct s_modbus_10
|
||
|
{
|
||
|
U16 reg;
|
||
|
U16 num;
|
||
|
U8 count;
|
||
|
}Modbus10;
|
||
|
|
||
4 years ago
|
typedef struct s_modbus_10_ack
|
||
|
{
|
||
|
U16 reg;
|
||
|
U16 num;
|
||
|
}Modbus10Ack;
|
||
|
|
||
3 years ago
|
|
||
|
typedef struct s_modbus_err_ack
|
||
|
{
|
||
|
U8 errcode;
|
||
|
}ModbusErrAck;
|
||
|
|
||
4 years ago
|
typedef struct
|
||
|
{
|
||
|
U16 slaver;
|
||
|
U16 oper;
|
||
|
U16 reg;
|
||
|
U16 regnum;
|
||
|
U16 bytes;
|
||
|
U8 *buf;
|
||
|
U16 mask;
|
||
|
}MD_SLAVER_INFO;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
U8 reg;
|
||
|
U8 max; //接收到的数目的最大值
|
||
|
vU8 head; //接收标志头标志
|
||
|
vU8 ok; //接收协议ok标志
|
||
|
vU8 num;
|
||
3 years ago
|
vU8 error; //错误
|
||
4 years ago
|
vU8 *sp;
|
||
|
U8 buf[D_s_PH4_modbus_max + 8];
|
||
|
vU8 crc[2];
|
||
|
}TS_Handle_PH4;
|
||
|
|
||
3 years ago
|
extern U8 L3_pack_modbus(TS_PH4_modbus *pmodbus, MD_SLAVER_INFO *slaver_info);
|
||
|
extern void L1_s2b_PH4_init(TS_Handle_PH4 *p);
|
||
|
extern void L1_s2b_PH4(TS_Handle_PH4 *p);
|
||
4 years ago
|
|
||
|
#endif /* end __TPC_UART_H_ */
|
||
|
/*****************************************************************************
|
||
|
** End Of File
|
||
|
******************************************************************************/
|
||
|
|
||
|
|
||
|
|