sop板
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.
 
 
 
 

109 lines
3.3 KiB

#ifndef APP_COMMON_H
#define APP_COMMON_H
#include "../clib/type.h"
#include "../bsp/bsp_config.h"
#define APP_VERSION 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 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)
// #define ADC_status_chx_Ready_BASE 0x01
// #define ADC_status_ch1_Ready 0x01
// #define ADC_status_ch2_Ready 0x02
// #define ADC_status_ch3_Ready 0x04
// #define ADC_status_ch4_Ready 0x08
// #define D_ADC_CHANNEL_NUM 4
#define LED_BTN_NUM 14
#define POWER_NORMAL 0
#define POWER_LOW 1
typedef struct global_register
{
//RFID对照表
U16 rfid_table[LED_BTN_NUM];
//本机ID
U8 slave_id;
//低功耗模式
U8 power_mode;
//led状态标志,分表代表第n个led灯的状态
U8 led_status[LED_BTN_NUM];
//授权标志
//高4位代表是否需要授权 高4位0代表无须授权,高4位>0代表需要授权
//低4位 > 0代表已授权,低4位==0代表未授权
//0x01 代表按键不需要授权、已授权
//0x00 代表按键不需要授权、未授权
//0x11 代表按键需要授权、已授权
//0x10 代表按键需要授权、未授权
U8 auth_flag;
//功能按键
U8 func_btn;
//NFC缓冲区
struct {
//nfc卡号,只取后2个字节
U8 nfc_no[2];
}nfc;
//RFID缓冲区
struct {
//rfid卡号,只取后2个字节
U8 rfid_no[2];
//rfid信号强度
U8 rssi;
//rfid天线编号1,2,3,4 FF代表按键
U8 ant;
}rfids[4];
}GlobalRegister;
extern GlobalRegister R;
//寄存器内存基地址
#define REG_MEM_BASE ((U16*)(&R)) //寄存器基础地址(本文件外部不应该使用该宏定义)
//变量地址转寄存器
#define MEM_2_REG(mem) (((U16*)(mem) - REG_MEM_BASE) + 1)
//寄存器转变量地址
#define REG_2_MEM(reg) (REG_MEM_BASE + (U16)((reg) - 1))
//STEP 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Register CONFIG End
//STEP 2 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Global Variables CONFIG
typedef struct global_param
{
U8 xx;
}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);
extern void L3_led_init(void);
extern void L3_set_power_mode(U8 mode);
extern U8 L3_find_rfid_table(U16 rfidno);
extern U8 L3_new_rfid(U16 rfidno, U8 rssi, U8 ant);
#endif