You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.0 KiB
C

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef __CA_CAU_H__
#define __CA_CAU_H__
#ifdef CFG_DEV_TYPE_LAND_CA
/* Includes ------------------------------------------------------------------*/
#include "ca_main.h"
/* Define --------------------------------------------------------------------*/
#define MODBUS_DATA_LENGTH (512)
#define MESSAGE_HEAD_POS (0)
#define MESSAGE_FUNC_POS (1)
#define MESSAGE_DATA_LEN_POS (2)
//#define MESSAGE_BODY_LEN_POS (1)
//#define MESSAGE_BODY_POS (2)
//#define MODBUS_HEAD_POS (0)
//#define MODBUS_FUNC_POS (1)
#define CALI_POINT_MAX (5) // 5个校准点
/* Exported types ------------------------------------------------------------*/
typedef struct
{
float tag[MAX_CAU_CHANNEL];
}cau_real_data_t;
typedef struct
{
cau_real_data_t cauVal[100];// 每个点采集20次取平均值
cau_real_data_t cauAvg[5];//校准计算平均值
}cali_value_t;
typedef int32_t (*cb_send_data)(int cmd, char *psrc, int len);
typedef struct
{
int serial_fd;
unsigned char modbus_recv_buf[MODBUS_DATA_LENGTH];
unsigned char modbus_send_buf[MODBUS_DATA_LENGTH];
cau_real_data_t real_data;
unsigned int last_collect_time;
Parameters_t cali_param;
cali_value_t cali_val;
int ismanual;
int workstat; //0:正常工作 1:正在校准
cb_send_data send_data;
} cau_t;
typedef struct
{
int vsc;//超级电容 输出电压 单位mv
int vbat;//电池电压 单位mv
int vout;//系统供电电压Vsc ,Vbat,V5v三者的最大值 用于判断电池是否在供电中
} pwr_t;
/* Exported macro ------------------------------------------------------------*/
/* Extern global variables ---------------------------------------------------*/
//extern csg_t csg;
extern cau_t cau;
extern pwr_t pwr;
/* Extern functions ----------------------------------------------------------*/
extern int32_t cau_handle_init(void);
extern int _cau_set_calibration_param(float *pparam);
#endif
#endif