Initial commit: CCU621_M firmware project with BLE debug link support.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-08 17:28:36 +08:00
commit 9ceb218f80
1597 changed files with 724159 additions and 0 deletions
+93
View File
@@ -0,0 +1,93 @@
#ifndef METER_COLL_TASK_H
#define METER_COLL_TASK_H
#ifdef __cplusplus /*C++编译环境下兼容C语言*/
extern "C" {
#endif
/*------ Exported includes(头文件) ----------------------*/
#include "main.h"
#include "publicdata/publicdata.h"
#include "meter_calculate/meter_calculate_impl.h"
/*------ Exported macro(宏定义) -------------------------*/
#ifndef METER_MAX_CNT
#define METER_MAX_CNT (4) //电表最大数量
#endif
#ifndef METER_COMM_TYPE_CNT
#define METER_COMM_TYPE_CNT (3) //电表通信数据类型数量 3分别为电量、电压、电流
#endif
#ifndef METER_RECV_TIMEOUT_MS
#define METER_RECV_TIMEOUT_MS (600) //电表数据接收超时时间 600ms
#endif
#ifndef METER_COMM_MAX_CNT
#define METER_COMM_MAX_CNT (2) //单路通信口 电表最大数量 - 一路485口最大有几个电表
#endif
#define MAX_BUFFER_SIZE (128)
/*------ Exported struct(结构体定义) --------------------*/
// 第三级:电表控制数据
typedef struct {
U8_T u8_enFlag; //使能标志 0不使能 1使能 用于区分该位置是否存在电表
U8_T u8_isAC; // 是否为交流电表标识 (1:交流 0:直流)
U8_T u8_highPrec; //是否支持高精度 0 不支持 1支持
U8_T u8_meterNumber[6]; // 6字节电表表号 (如: 0x12,0x34,0x56,0x78,0x9A,0xBC)
U8_T u8_comm_flag; //通信标识 0未通信 1已通信
U16_T u16_timeout_cnt[3]; //通信超时计数 -- 三种数据 有一种接收超时则通信超时
U32_T u32_voltage; // 电压值(单位:0.0001V
U32_T u32_current; // 电流值(单位:0.0001A
U64_T u64_energy; // 电量值(单位:0.0001 kWh
} S_METER_DATA;
typedef struct
{
U8_T u8_send_type; //发送数据类型 0电量 1电压 2电流
U8_T u8_recv_flag; //数据接收标志 0未接收到 1已接收到
U16_T u16_recv_timeout_cnt; //接收超时计数 单位ms 最大超时时间 600ms
U8_T u8_buffer_len; // 当前缓冲区数据长度
U8_T u8_buffer[MAX_BUFFER_SIZE]; // 静态接收缓冲区
}S_METER_COMM_CTRL;
typedef struct {
U8_T u8_gunCnt; //枪数量
S_METER_COMM_CTRL s_commCtrl[GUN_MAX_CNT];
S_METER_DATA s_meters[GUN_MAX_CNT][METER_COMM_MAX_CNT]; // 电表控制数据数组(固定2个元素)
} S_METER_CTRL_DATA_DATA;
// 解包结果结构体
typedef struct {
U8_T u8_gunNo; //枪号
U8_T data_len; // 数据长度
U8_T control_code; // 控制码
U32_T u32_datesign; //数据标识
U8_T address[NUM_6]; // 电表地址(小端格式)
U8_T data[NUM_32]; // 数据域
} S_METER_FRAME;
typedef struct
{
U32_T iFlagCode; //标识编码
U16_T iLenth; //数据长度,如果为组合项,则为0
U16_T iCoefficient; //系数
} Meter_Data_Item;
void v_Meter_Coll_task(void *argument);
U8_T u8_get_meter_id_str(U8_T u8_gunNo ,U8_T u8_id ,U8_T *u8_getData , U8_T u8_len);
#ifdef __cplusplus
}
#endif
#endif