pile_com_stm32/main/stm32/config.h
2024-03-15 13:27:37 +08:00

194 lines
4.7 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef SYS_H__
#define SYS_H__
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "esp_err.h"
#define FLOW_REG_ADDR 0
#define DEPTH_REG_ADDR 12
#define AC_CURRENT_REG_ADDR 24
#define MOVE_REG_ADDR 27
#define TILT_SENSER_ADDR 30
#define RECORD_REG_ADDR 32
#define TIME 264
#define CAL_4_20MA_ADDR 384
#define FLOW_CONFIG_ADDR (CAL_4_20MA_ADDR + (sizeof(cal_4_20ma_t) + 15) / 16 * 8)
#define DEPTH_CONFIG_ADDR (FLOW_CONFIG_ADDR + (sizeof(flow_config_t) + 15) / 16 * 8)
#define AD_RAW_REG_ADDR 444
#define LAST_PILE_ID_ADDR 509
#define DEPTH_RESET_ADDR 510
#define REBOOT_REW_ADDR 511
#define REG_GPS_MESSAGE (512 + 48)
#define REG_GPS_WRITE_DATA (REG_GPS_MESSAGE + sizeof(gps_message_t))
// GPS数据
typedef struct gps_message
{
uint8_t gps_status; // GPS定位状态
uint8_t gps_view; // GPS可视状态
uint8_t gps_use; // GPS使用状态
uint8_t reg[1]; // 保留
uint32_t utc; // utc时间
double x; // 大地平面坐标
double y;
double dir; // 方向
double pitch; // 俯仰角
} gps_message_t;
extern gps_message_t *gpsMessageP;
#define WRITE_DOWN_MAGIC 0x55BB // 控制gps采用参数进行运算
#define WRITE_SAVE_MAGIC 0x55AA // 控制gps将参数保存成json文件开机的时候自动加载
typedef struct gps_write_data // addr 600
{
uint16_t magic; // 600 2
uint16_t ellipsoidal_datum; // 椭圆基准 601 2
uint8_t reg[4];
// 604 8
int16_t x0; // 卫星接收器点坐标(坐标系以基站为原点建立)
int16_t y0;
int16_t x1; // 待求点坐标
int16_t y1;
// 608 16
uint64_t central_meridian; // 中央子午线
uint64_t elevation; // 投影高程
// 616 16
int64_t dx; // x轴平移
int64_t ax; // x轴旋转
// 624 16
int64_t dy; // y轴平移
int64_t ay; // y轴旋转
// 632 16
int64_t dz; // z轴平移
int64_t az; // z轴旋转
// 640 8
int64_t k; // 缩放比例
} gps_write_data_t;
extern gps_write_data_t *gpsWriteDataP;
typedef struct
{
uint16_t magic;
struct _ch
{
uint16_t ad_4ma;
uint16_t ad_20ma;
} ch[2];
} cal_4_20ma_t;
typedef struct
{
int16_t flow_min;
int16_t flow_max;
} ad_flow_cal_t; //存储ad转换的最大流量和最小流量
typedef struct
{
uint16_t magic; //可能是一个用于标识流量配置的特殊字段或标志?
uint16_t input_type; // 1 : 4~20ma 2: 0~3.6K
int16_t min_flow[2]; // 小流量切除
ad_flow_cal_t ad_cal[2];
uint16_t pulse_coef[2]; //可能代表了脉冲输出的系数或倍率?
uint16_t rsv[6]; //可能是预留给未来扩展使用的保留字段?
} flow_config_t;
typedef struct
{
uint16_t magic;
uint8_t input_type; // 0正交 1:正交反向 2:方向脉冲 3:方向脉冲反向
uint8_t port; // 编码器端口
uint16_t N; //编码器系数分子
uint16_t M; //编码器系数分母
// int pluse_coef; // 脉冲系数0.001mm
int16_t min_depth; // 最小深度 mm
int16_t max_depth; // 最大深度 mm
int16_t sample_depth; // 采样深度 mm
int16_t depth_offset; // 默认深度偏移
int16_t min_valid_depth; // 最小有效深度
int16_t inc_pile_depth; // 允许换桩深度
uint16_t current_on_threshold; // 行走电机开启电流
uint16_t current_off_threshold; // 行走电机关闭电流
uint16_t move_on_duratino; // 持续时间
uint16_t move_off_duration; // 持续时间
uint16_t move_current_channel; //行走电流通道
} depth_config_t;
typedef struct
{
int16_t flow_;
int16_t flow;
int32_t total_flow;
uint32_t update_time;
} flow_t;
typedef struct
{
uint16_t status; // 0:未开始 1:开始 2:结束
uint16_t time_count; //持续时间
uint16_t pile_inc_req;
} move_t;
typedef struct
{
uint16_t pile_work_state_and_direction; // 12
int16_t speed; // 13
int16_t depth; // 14
uint16_t sample_count; // 15
uint16_t depth_flow[2]; // 16~17
uint32_t last_total_flow[2]; //
int16_t depth_offset; // 22
uint16_t one_pile_work_time;//23 系统工作时间
// uint32_t update_time;
// int16_t tilt_x;
// int16_t tilt_y;
// uint16_t current1;
// uint16_t current2;
// uint16_t current3;
} depth_t;
typedef struct
{
int16_t max_depth;
uint16_t pile_id;
uint16_t count;
// uint16_t work_time;
struct _item
{
int16_t speed;
int16_t depth;
int16_t flow[2];
uint32_t total_flow[2];
int16_t tilt_x;
int16_t tilt_y;
uint16_t current1;
uint16_t current2;
} item[10];
} record_t;
extern depth_config_t *depth_config;
void config_load(void);
void save_cal_4_20ma(void);
void save_flow_cfg(void);
void save_depth_cfg(void);
void restore_default(void);
#endif