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.
199 lines
4.0 KiB
199 lines
4.0 KiB
3 years ago
|
#ifndef _APP_COMMON_H
|
||
|
#define _APP_COMMON_H
|
||
|
|
||
|
#include "../clib/type.h"
|
||
|
#include "../tpc/tpc_uart.h"
|
||
|
#include "../tpc/tpc_modbus.h"
|
||
|
|
||
|
#define APP_VERSION_HEX 0x20 //高4位主版本,低4位次版本
|
||
|
#define APP_VERSION "0x20"
|
||
|
|
||
|
|
||
|
|
||
|
#define PAPER_BOX_NUM 3
|
||
|
#define RELAY_NUM 8
|
||
|
|
||
|
enum RunMode
|
||
|
{
|
||
|
MODE_RUN = 0x00,
|
||
|
MODE_DEBUG_COMMON = 0x01,
|
||
|
MODE_DEBUG_IR = 0x02,
|
||
|
MODE_DEBUG_GM35 = 0x03,
|
||
|
MODE_PAPER_CALIB = 0x04,
|
||
|
};
|
||
|
|
||
|
enum CCMODBUS_ADDR
|
||
|
{
|
||
|
ADDR_UPPER = 0x10,
|
||
|
ADDR_SERVER = 0x11,
|
||
|
ADDR_Maintenance = 0x12,
|
||
|
};
|
||
|
|
||
|
enum CCMODBUS_OPER
|
||
|
{
|
||
|
OPER_RELAY = 0x95,
|
||
|
OPER_REPORT = 0x93,
|
||
|
OPER_ISP = 0x80,
|
||
|
|
||
|
OPER_CALIB_MODE = 0x50,
|
||
|
OPER_CALIB = 0x51,
|
||
|
OPER_CALIB_READ = 0x52,
|
||
|
OPER_PAPER_COUNT = 0x53,
|
||
|
OPER_SET_485_ID = 0x54,
|
||
|
OPER_CALIB_LEAVE = 0x5a,
|
||
|
|
||
|
OPER_RESET = 0x60,
|
||
|
|
||
|
OPER_GPRS_HEART = 0x00,
|
||
|
// OPER_GPRS_ACK = 0x95,
|
||
|
OPER_GPRS_REPORT = 0x97,
|
||
|
};
|
||
|
|
||
|
enum TS_485_OPER
|
||
|
{
|
||
|
OPER_ANGLE_DAT = 0x90,
|
||
|
OPER_ANGLE_SET_ID = 0x91,
|
||
|
};
|
||
|
|
||
|
#define MASTER_ID 0x00
|
||
|
#define SLAVER_ID_MIN 0x01
|
||
|
#define SLAVER_ID_MAX 0x03
|
||
|
#define SLAVER_ID_N 0xee
|
||
|
|
||
|
/**
|
||
|
* Register Memory Map
|
||
|
*/
|
||
|
typedef struct printer_paper
|
||
|
{
|
||
|
U8 version; //版本号(板卡对应版本号)APP_VERSION_HEX
|
||
|
vU16 paperNum:10; //10bit纸张数据 表示最大量程1024 实际170张
|
||
|
vU16 cameraIndex:4; //摄像头编号
|
||
|
vU16 cameraNotWorking:1; //是否正常工作
|
||
|
vU16 LowPower:1; // =1 lowPower 提醒需要充电,或者未连接电池
|
||
|
}TS_P_paper;
|
||
|
|
||
|
typedef struct boardstatus
|
||
|
{
|
||
|
U8 a9Status;
|
||
|
U8 a9RecvDataInterval;
|
||
|
U8 wdtStatus;
|
||
|
}TS_BoardStatus;
|
||
|
|
||
|
typedef struct printer_paper_calib
|
||
|
{
|
||
|
U16 num0; //x0
|
||
|
U16 angle0; //y0
|
||
|
U16 num1; //x1
|
||
|
U16 angle1; //y1
|
||
|
}TS_PaperCalib;
|
||
|
|
||
|
#define MD_SLAVER_INFO_MAX 2
|
||
|
#define SLAVER_ASGA03_01 0x01 //1号倾角传感
|
||
|
#define SLAVER_ASGA03_02 0x02 //2号倾角传感
|
||
|
|
||
|
typedef struct printer_maintenance_global
|
||
|
{
|
||
|
TS_PaperCalib paperCalibs[PAPER_BOX_NUM];
|
||
|
U16 currentSensorVal[PAPER_BOX_NUM]; //当前纸张传感输出
|
||
|
|
||
|
TS_P_paper papers[PAPER_BOX_NUM];
|
||
|
TS_BoardStatus boardstatus;
|
||
|
U8 runmode; //运行模式
|
||
|
U32 lastResetToISPCmdTimeInSeconds; //isp reset time
|
||
|
|
||
|
U8 ccid[21]; //保存ccid卡号空间 20+'\0'
|
||
|
U8 ccid_passwd[22]; //保存ccid密码空间 21+'\0'
|
||
|
U8 reset;
|
||
|
MD_SLAVER_INFO md_slaver_info[MD_SLAVER_INFO_MAX];
|
||
|
vU32 modbusstmp;
|
||
|
}PMGlobal;
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 用户协议
|
||
|
*/
|
||
|
//数据上报协议
|
||
|
typedef struct printer_report
|
||
|
{
|
||
|
TS_P_paper papers[PAPER_BOX_NUM-1];
|
||
|
TS_BoardStatus boardstatus;
|
||
|
U8 ir;
|
||
|
}TS_Printer_Report;
|
||
|
|
||
|
//校准协议
|
||
|
typedef struct
|
||
|
{
|
||
|
U8 no; //paper box no
|
||
|
U8 point; //校准点
|
||
|
U8 paperNum0; //当前纸张数量高位
|
||
|
U8 paperNum1; //当前纸张数量低位
|
||
|
}TS_Paper_Upper_Calib;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
U8 no; //paper box no
|
||
|
}TS_Paper_Upper_Calib_Read;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
U16 num0; //x0
|
||
|
U16 angle0; //y0
|
||
|
U16 num1; //x1
|
||
|
U16 angle1; //y1
|
||
|
}TS_Paper_Upper_calib_ack;
|
||
|
|
||
|
//读取当前纸张数量
|
||
|
typedef struct
|
||
|
{
|
||
|
U8 no; //paper box no
|
||
|
}TS_Paper_Count;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
U8 no; //paper box no
|
||
|
U8 num[2]; //高位在前
|
||
|
}TS_Paper_Count_Ack;
|
||
|
|
||
|
//设置当前angle id
|
||
|
typedef struct
|
||
|
{
|
||
|
U8 id; //paper box no
|
||
|
}TS_Angle_SetId;
|
||
|
|
||
|
//gprs相关协议
|
||
|
typedef struct
|
||
|
{
|
||
|
U8 version;
|
||
|
}TS_gprs_heart;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
U8 xaxis[2];
|
||
|
U8 yaxis[2];
|
||
|
U8 zaxis[2];
|
||
|
}TS_Angle;
|
||
|
|
||
|
|
||
|
extern struct printer_maintenance_global G;
|
||
|
extern TS_PH3_ccmodbus_ack g_pkg_report;
|
||
|
|
||
|
extern void L2_register_init(void);
|
||
|
extern U16 L2_paper_count(U8 index, U32 angle);
|
||
|
|
||
|
extern void L3_protocol_handler_uart0_fun(TS_PH3_ccmodbus *pPara,U8 from);
|
||
|
extern void L3_protocol_handler_uart4_fun(U8 *pPara);
|
||
|
extern U8 L2_constructor_ccmodbus_ack(TS_PH3_ccmodbus_ack *pccmodbus, U8 addr, U8 oper, U8 *buf, U8 len);
|
||
|
extern void L2_do_uart_report(void);
|
||
|
extern void L2_gprs_send_signin_pkg(void);
|
||
|
extern void L2_gprs_send_ack_pkg(void);
|
||
|
extern void L2_gprs_send_heart_pkg(void);
|
||
|
extern void L2_gprs_send_report_pkg(void);
|
||
|
extern void L2_do_angle_setid_ack(U8 id);
|
||
|
extern void L2_do_board_reset(void);
|
||
|
extern void L2_do_gm35_reset(void);
|
||
|
extern U8 *hexBytes2AsciiBytes(U8 asciiBytes[],U8 hexBytes[],U8 hexBytesLen);
|
||
|
|
||
|
|
||
|
#endif
|
||
|
|