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.
76 lines
1.7 KiB
76 lines
1.7 KiB
#ifndef APP_COMMON_H
|
|
#define APP_COMMON_H
|
|
|
|
#include "../clib/type.h"
|
|
|
|
#define APP_VERSION 0x10
|
|
#define P485_SLAVER_ID 0x01
|
|
#define D_ADC_CHANNEL_MAX 4
|
|
|
|
#define D_MCU_BIGENDIAN 1
|
|
// #define D_MCU_LITTLEENDIAN 1
|
|
|
|
#define D_COUNT_WEIGHT(adc,zadc) ((S32)((1.0 * G.p.ratio * G.p.weight_max * (adc - zadc)) / (2 * 0x7FFFFF / 1000 * D_ADS1213_GAIN_VAL * G.p.lmd)))
|
|
//#define D_COUNT_WEIGHT(adc,zWeight) ((S32)((1.0 * G.p.ratio * G.p.weight_max * (adc)) / (2 * 0x7FFFFF / 1000 * D_ADS1213_GAIN_VAL * G.p.lmd)) - zWeight)
|
|
|
|
#define MCU_ID_LEN 7
|
|
#define MCU_ID_KEY_LEN 4
|
|
|
|
enum tp_handle
|
|
{
|
|
TP_HANDLED,
|
|
TP_UNHANDLE
|
|
};
|
|
|
|
/**
|
|
* EEPROM 存储结构
|
|
*/
|
|
#define EEPROM_PARAM_DATA_MAX 64
|
|
#define EEPROM_PARAM_FILTER 0xAA
|
|
typedef struct ts_eeprom_enc
|
|
{
|
|
U8 enc_key[MCU_ID_KEY_LEN];
|
|
U8 enc_val[MCU_ID_LEN];
|
|
//U8 crc[2];
|
|
}EEPROM_ENC;
|
|
|
|
/**
|
|
* 用户协议
|
|
*/
|
|
|
|
|
|
//协议类型: MODBUS RTU模式
|
|
#define D_s_PH4_modbus_max (12)
|
|
typedef struct ts_ph4_modbus
|
|
{
|
|
U8 salver; //从机地址
|
|
U8 oper; //功能码
|
|
U8 buf[D_s_PH4_modbus_max];
|
|
U8 crc[2];
|
|
U8 num;
|
|
}TS_PH4_modbus;
|
|
|
|
/**
|
|
* Register Map
|
|
*/
|
|
typedef struct global_param
|
|
{
|
|
U16 reserved;
|
|
U8 enc_key[MCU_ID_KEY_LEN];
|
|
U8 mcu_id[MCU_ID_LEN];
|
|
U8 mcu_enc_id[MCU_ID_LEN];
|
|
}GlobalParam;
|
|
|
|
extern struct global_param G;
|
|
extern void L3_reg_init(void);
|
|
extern void L3_chip_encrypt_main(void);
|
|
|
|
//寄存器内存基地址
|
|
#define REG_MEM_BASE ((U16*)(&G)) //寄存器基础地址(本文件外部不应该使用该宏定义)
|
|
//变量地址转寄存器
|
|
#define MEM_2_REG(mem) (((U16*)(mem) - REG_MEM_BASE) + 1)
|
|
//寄存器转变量地址
|
|
#define REG_2_MEM(reg) (REG_MEM_BASE + (U16)((reg) - 1))
|
|
|
|
#endif
|
|
|
|
|