#ifndef APP_COMMON_H #define APP_COMMON_H #include "../clib/type.h" #include "../bsp/bsp_config.h" #include "../tpc/ccmodbus.h" #include "../tpc/modbus.h" //#include "../asp/asp_oid.h" #define SERVER_ID 0x01 #define APP_VERSION 0x10 #define SLAVER_TCP_SERVER_ID 0x14 #define APP_VERSION_HEX 0x11 //高4位主版本,低4位次版本 #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 2 typedef struct pen_point { U16 x_axis;//横坐标 U16 y_axis;//纵坐标 U32 time;//时间 U16 angle;//角度 }PenPoint; typedef struct global_register { //RO Register U16 pen_sta;//点读笔状态 U16 pen_net_sta;//联网状态 U16 pen_ele_sta;//电池电量 U16 question_sta;//问题 0上题 1下题 U16 spee_order;//语音序号 U32 oid3_order;//序号通知(oid3普通码) U16 null[25]; //U16 pack_order;//包序号 //U16 frame_order;//帧序号 //U16 pack_mask;//包标志 //Ts_OID_frame_xy_ points[POINT_LEN]; }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 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Global Variables CONFIG typedef struct global_param { //调试模式 U8 debug; U8 reset; //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]; //w600联网模式 U16 w600_mode; U16 status_eep_save; U16 slaver_id; vU32 modbusstmp; U16 authed; U16 flowStartVal; U8 mcu_id[7]; U8 pen_up; U8 pen_down; U8 pen_hold; U8 pen_end; U8 pen_t; U8 oid_p; U8 oid_x; U8 datapkg; CCMD_SLAVER_INFO ccmd_slaver_info[CCMD_SLAVER_INFO_MAX];///16*3 }GlobalParam; extern GlobalParam G; //STEP 2 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<