pile_com_stm32/main/stm32/config.h
2023-11-15 22:06:47 +08:00

104 lines
2.6 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 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
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;
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