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.
 
 
 
 

99 lines
2.9 KiB

#ifndef APP_COMMON_H
#define APP_COMMON_H
#include "../clib/type.h"
#include "../bsp/bsp_config.h"
#include "../bsp/bsp_config.h"
#include "../tpc/ccmodbus.h"
#define APP_VERSION 0x10
#define SLAVER_TCP_SERVER_ID 0x10
#define D_COUNT_WEIGHT(adc) (U32)((adc) / D_ADS1213_GAIN_VAL / R.p.lmd * R.p.weight_max * 1000 / (2 * 0x7FFFFF / 1000 ))
#define D_COUNT_ADC(wInG) (U32)((wInG) * D_ADS1213_GAIN_VAL * R.p.lmd * (2 * 0x7FFFFF / 1000) / R.p.weight_max / 1000)
//STEP 1 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Register CONFIG
//寄存器编号从1开始
//#define D_COUNT_WEIGHT(adc) (U32)(1000.0 * R.p.weight_max * (adc) / (2 * 0x7FFFFF / 1000 * D_ADS1213_GAIN_VAL * R.p.lmd))
//#define D_blur_threshold_2_1(threshold) (U32) ( 1.0 * threshold *(2 * 0x7FFFFF / 1000 * D_ADS1213_GAIN_VAL * R.p.lmd) / (1000.0 * R.p.weight_max ))
#define CCMD_SLAVER_INFO_MAX 4
typedef struct global_register
{
//RO Register
U16 w600_mode;
U16 pen_sta;
U16 pen_net_sta;
U16 pen_ele_sta;
U16 question_sta;
U16 spee_save;
U32 oid3_order;
U16 pack_order;
U16 frame_order;
U32 x_axis1;
U32 y_axis1;
U32 time1;
U32 x_axis2;
U32 y_axis2;
U32 time2;
CCMD_SLAVER_INFO ccmd_slaver_info[CCMD_SLAVER_INFO_MAX];
//RW Register
U16 reserved2;
U16 zero; //清0标志,写入任何值清0(去皮)
U16 status_eep_save; //eep写入寄存器,1则写入eep并清0
//U16 reset; //reset标志,写入任何值,所有参数恢复初始值
struct
{ //需要持久化的参数,不能超过72字节,否则会导致eeprom溢出
U16 slaver_id;
}p;
U16 reserved3;
}GlobalRegister;
extern GlobalRegister R;
//寄存器内存基地址
#define REG_MEM_BASE ((U16*)(&R)) //寄存器基础地址(本文件外部不应该使用该宏定义)
//变量地址转寄存器
#define MEM_2_REG(mem) (((U16*)(mem) - REG_MEM_BASE))
//寄存器转变量地址
#define REG_2_MEM(reg) (REG_MEM_BASE + (U16)((reg))) //寄存及从0地址开始
//STEP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Register CONFIG End
//STEP 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Global Variables CONFIG
typedef struct global_param
{
//调试模式
U8 debug;
//station模式状态
U8 st_status; //0:none 1:wifi_ok 2:tcp_connect_ok
//station模式sid
U8 st_sid[32];//必须是一个字符串 "ccsens\0"
//station模式pwd
U8 st_pwd[32];//必须是一个字符串 "ccsens123\0"
//ap模式状态
U8 ap_status; //0: none 1: ap_ok 2:tcp_server_ok
//ap模式sid
U8 ap_sid[32];
//ap模式pwd
U8 ap_pwd[32];
}GlobalParam;
extern struct global_param G;
//STEP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Global Variables CONFIG End
extern void L3_param_init(void);
extern void L3_reg_2_iap(void);
extern void L3_iap_2_reg(void);
extern void L3_reg_reset(void);
extern void L3_reg_init(void);
#endif