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.4 KiB

4 years ago
#ifndef APP_COMMON_H
#define APP_COMMON_H
#include "../clib/type.h"
#define APP_VERSION 0x10
#define D_MCU_BIGENDIAN 1
// #define D_MCU_LITTLEENDIAN 1
#define D_COUNT_WEIGHT(adc) ((S32)((1000.0 * R.p.weight_max * (adc)) / (2 * 0x7FFFFF / 1000 * D_ADS1213_GAIN_VAL * R.p.lmd)))
enum tp_handle
{
TP_HANDLED,
TP_UNHANDLE
};
/**
* EEPROM
*/
#define EEPROM_PARAM_DATA_MAX 90
#define EEPROM_PARAM_FILTER 0xAA
typedef struct ts_eeprom_param
{
U8 filter;
U8 len;
U8 buf[EEPROM_PARAM_DATA_MAX];
U8 crc[2];
}EEPROM_PARAM;
#define MCU_ID_LEN 7
#define MCU_ID_KEY_LEN 4
#define EEPROM_ENC_DATA_MAX 64
#define EEPROM_ENC_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;
#define baud_rade L3_baud_rate_change(G.p.baud_rate)
typedef struct mcu_encrypt_info
{
U8 enc_key[MCU_ID_KEY_LEN];
U8 mcu_id[MCU_ID_LEN];
U8 mcu_enc_id[MCU_ID_LEN];
}McuEncryptInfo;
#define D_ch_max_num 4
typedef struct global_param
{
//EncryptInfo
McuEncryptInfo e;
//Global Variables
S32 weight[D_ch_max_num]; //4路重量
S32 _total_weight; //实际重量*1000
S32 _total_zweight; //实际皮重*1000
}GlobalParam;
extern struct global_param G;
extern struct ts_eeprom_param eep_param;
extern struct ts_eeprom_enc eep_enc;
extern void L3_param_init(void);
extern int L3_mcu_id_ok();
extern S32 L3_count_std_weight(S32 weight);
extern void L3_eeprom_persist_param(void);
#endif