init: DLD154Pro 单线圈蓝牙车检器,从 DLD110SV4 复制初始代码和文档
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* cmcng.h
|
||||
*
|
||||
* Created on: Aug 27, 2024
|
||||
* Author: Thinkpad
|
||||
* 2026-07-18: 算法移� DLD154V4B, 移除 FltHistoryManager / SecondOrderState /
|
||||
* StageRangeConfig ç‰æ—§ç®—法结构
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_CMCNG_H_
|
||||
#define INCLUDE_CMCNG_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define PRODUCT_MODEL "DLD110S"
|
||||
#define FIRMWARE_VER "4.30"
|
||||
#define HARDWARE_VER "4.01"
|
||||
#define FIRMWARE_VER_MAIN 4
|
||||
#define FIRMWARE_VER_SUB 30
|
||||
#define HARDWARE_VER_MAIN 4
|
||||
#define HARDWARE_VER_SUB 1
|
||||
|
||||
/* 功能模�� (direction_mode �4�, �议�留; 新算法��消�) */
|
||||
#define FUNCTION_A 0x01 // äºŒæ¬¡åˆ¤æ– (已废å¼?)
|
||||
#define FUNCTION_B 0x02 // 二次判æ–增强æ�¡ä»¶åˆ¤æ– (已废å¼?)
|
||||
#define FUNCTION_C 0x04 //
|
||||
#define FUNCTION_D 0x08 //
|
||||
|
||||
|
||||
extern uint16_t g_hold_time;
|
||||
extern char g_flag_debug;
|
||||
extern uint8_t g_dev_number[6];
|
||||
extern uint8_t MACAddr[6];
|
||||
|
||||
extern uint8_t g_loop_cut_last;
|
||||
extern uint32_t g_loop_cut_amount;
|
||||
extern uint8_t g_loop_power_up_state;
|
||||
|
||||
extern uint8_t g_function_mode;
|
||||
|
||||
/* 新算法状� (DLD154V4B 移�) */
|
||||
extern uint8_t g_loop_stable; // 稳定期结æ�Ÿæ ‡å¿? (0=æ”¶æ•›ä¸?, 1=稳定)
|
||||
extern uint8_t g_env_activity; // 环境活跃åº? (BLE condition å—æ®µæ�¥æº�)
|
||||
|
||||
uint32_t mstick(void);
|
||||
|
||||
#endif /* INCLUDE_CMCNG_H_ */
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* dbn_ble_srv.h
|
||||
*
|
||||
* Created on: Aug 27, 2024
|
||||
* Author: Thinkpad
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_DBN_BLE_SRV_H_
|
||||
#define INCLUDE_DBN_BLE_SRV_H_
|
||||
|
||||
#include "CONFIG.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* Magic | Header | Data | CheckByte
|
||||
* | Addr/Sub Len CMD | | Xor Sum
|
||||
* 1Byte | 1B 1B 1B | xx | 1B 1B
|
||||
*
|
||||
* * Len = len(CMD) + len(Data)
|
||||
*/
|
||||
#define MAGIC_BYTE_DBN_DEFAULT 0x8F
|
||||
#define MAGIC_BYTE_DBN_TRANSPARENT 0x7F // 用于 显示屏协议、地感协议、探头协议等
|
||||
|
||||
#define CMD_DBN_GET_DEV_INFO 0x10
|
||||
|
||||
#define CMD_DBN_CHECK_PASS 0x1C
|
||||
#define CMD_DBN_MODIFY_PASS 0x1D
|
||||
|
||||
|
||||
#define CMD_DBN_SET_FACTORY 0x1E
|
||||
#define CMD_DBN_RESET_DEV 0x1F
|
||||
|
||||
#define CMD_DBN_SET_NOTIFY 0x20
|
||||
#define CMD_DBN_SET_NOTIFY_LOOP 0x21
|
||||
#define CMD_DBN_SET_SUB_CODE 0x22 //使能 子功能
|
||||
#define CMD_DBN_SET_CJQ_PARAM 0x23 // 设置 车检器参数
|
||||
#define CMD_DBN_GET_CJQ_PARAM 0x24 // 读取 车检器参数
|
||||
|
||||
#define CMD_DBN_DEV_RESET 0x6D
|
||||
|
||||
#define CMD_DBN_LOOP_SAMPLE_PARAM 0x87
|
||||
#define CMD_DBN_LOOP_BALANCE_PARAM 0x88
|
||||
#define CMD_DBN_LOOP_RELEASE_PLANB 0x89
|
||||
#define CMD_DBN_LOOP_SENS_LIST 0x8A
|
||||
#define CMD_DBN_SET_CJQ_FACTORY 0x92
|
||||
|
||||
|
||||
#define CMD_SUB_SENS_REPORT 0xC0 //设备主动上报传感信息
|
||||
// #define CMD_REQUIRE_DEV_MAC_ADDR 0xC1
|
||||
// #define CMD_CHANGE_DEV_ADDR_BY_MAC 0xC2
|
||||
// #define CMD_SET_LED 0xC3
|
||||
// #define CMD_SET_RELAY 0xC4
|
||||
#define CMD_SENS_ACS_ENABLE 0xC5 // 设备主动上报 使能
|
||||
|
||||
|
||||
|
||||
|
||||
#define MAX_BLE_DAT_RESPONSE_LEN (BLE_BUFF_MAX_LEN - 4) // 14 //返回 的所有字节数不能超过20个字节,除去 magic、header和ckb校验字节,剩下数据的字节数为14
|
||||
#define MAX_BLE_Notify_Buf_LEN BLE_BUFF_MAX_LEN //24
|
||||
#define MAX_BLE_BUF_LEN BLE_BUFF_MAX_LEN //128
|
||||
#define MAX_BLE_TMP_BUF_LEN BLE_BUFF_MAX_LEN
|
||||
|
||||
typedef struct _BLE_Notify_Buf_
|
||||
{
|
||||
uint8_t flag; //0 idle, 1 buf ready
|
||||
uint8_t len;
|
||||
uint8_t buf[MAX_BLE_Notify_Buf_LEN];
|
||||
}BLE_Notify_Buf;
|
||||
|
||||
typedef struct _BUF_DBN_BLE_
|
||||
{
|
||||
uint8_t flag;
|
||||
uint8_t magic;
|
||||
uint8_t cmd;
|
||||
uint8_t dat_len ;
|
||||
uint8_t dat_offset;
|
||||
uint8_t pkg_amount;
|
||||
uint8_t pkg_seq;
|
||||
uint8_t dat[MAX_BLE_BUF_LEN];
|
||||
} Buf_DBN_BLE;
|
||||
|
||||
extern Buf_DBN_BLE g_buf_ble_response;
|
||||
|
||||
extern BLE_Notify_Buf g_notify_buftemp;
|
||||
extern uint8_t g_flag_notify_temp;
|
||||
extern BLE_Notify_Buf g_ble_rcv_buf;
|
||||
|
||||
|
||||
extern uint16_t loop1_LPCNT;
|
||||
extern uint8_t g_freq_sens;
|
||||
extern uint8_t loop1_SensLevel;
|
||||
extern uint8_t g_freq_level;
|
||||
extern uint32_t g_sys_freq;
|
||||
extern float g_freq_tmp;
|
||||
|
||||
|
||||
|
||||
void clear_ble_notify_buf(BLE_Notify_Buf * buf);
|
||||
|
||||
void poll_dbn_ble(void);
|
||||
void report_sens_acs(void);
|
||||
|
||||
void set_factory_param(void);
|
||||
void factory_dev(void);
|
||||
void para_store_init(void);
|
||||
|
||||
|
||||
#endif /* INCLUDE_DBN_BLE_SRV_H_ */
|
||||
@@ -0,0 +1,67 @@
|
||||
/********************************** (C) COPYRIGHT *******************************
|
||||
* File Name : peripheral.h
|
||||
* Author : WCH
|
||||
* Version : V1.0
|
||||
* Date : 2018/12/11
|
||||
* Description :
|
||||
*********************************************************************************
|
||||
* Copyright (c) 2021 Nanjing Qinheng Microelectronics Co., Ltd.
|
||||
* Attention: This software (modified or not) and binary are used for
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef PERIPHERAL_H
|
||||
#define PERIPHERAL_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* INCLUDES
|
||||
*/
|
||||
#include "dbn_ble_srv.h"
|
||||
|
||||
/*********************************************************************
|
||||
* CONSTANTS
|
||||
*/
|
||||
|
||||
// Peripheral Task Events
|
||||
#define SBP_START_DEVICE_EVT 0x0001
|
||||
#define SBP_PERIODIC_EVT 0x0002
|
||||
#define SBP_READ_RSSI_EVT 0x0004
|
||||
#define SBP_PARAM_UPDATE_EVT 0x0008
|
||||
|
||||
/*********************************************************************
|
||||
* MACROS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint16_t connHandle; // Connection handle of current connection
|
||||
uint16_t connInterval;
|
||||
uint16_t connSlaveLatency;
|
||||
uint16_t connTimeout;
|
||||
} peripheralConnItem_t;
|
||||
|
||||
/*********************************************************************
|
||||
* FUNCTIONS
|
||||
*/
|
||||
|
||||
/*
|
||||
* Task Initialization for the BLE Application
|
||||
*/
|
||||
extern void Peripheral_Init(void);
|
||||
|
||||
/*
|
||||
* Task Event Processor for the BLE Application
|
||||
*/
|
||||
extern uint16_t Peripheral_ProcessEvent(uint8_t task_id, uint16_t events);
|
||||
|
||||
/*********************************************************************
|
||||
*********************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* storage.h
|
||||
*
|
||||
* Created on: Aug 27, 2024
|
||||
* Author: Thinkpad
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_STORAGE_H_
|
||||
#define INCLUDE_STORAGE_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
// #define Addr_Loop_PlanB_Cng_Offset 0x10
|
||||
// #define Addr_Flag_Sample_In 0x10
|
||||
// #define Addr_Sample_Max_Amplitude 0x11
|
||||
// #define Addr_Flag_Balance_Ori_In 0x13
|
||||
// #define Addr_Balance_Ori_In_Max_Cnt 0x14
|
||||
// #define Addr_Flag_Release_Ori_PlanB 0x16
|
||||
// #define Addr_Release_Ori_PlanB_TimeOut 0x17
|
||||
// #define Addr_Release_Ori_PlanB_Weight 0x18
|
||||
// #define Addr_Release_Ori_Amplitude 0x19
|
||||
// #define Addr_Flag_Release_Rate 0x1B
|
||||
// #define Addr_Release_Rate_First 0x1C
|
||||
// #define Addr_Release_Rate_Second 0x1D
|
||||
// #define Addr_Release_Rate_Weight 0x1E
|
||||
// #define Addr_Release_Rate_Mode 0x1F
|
||||
|
||||
#define Addr_Loop_Sens_List_Offset 0x20
|
||||
|
||||
#define Addr_Sens_Array_In 0x20
|
||||
#define Addr_Sens_Array_Out 0x30
|
||||
|
||||
|
||||
#define MAX_LOOP_SENS_AMOUNT 3 // 4 // 5
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
typedef struct _Loop_Sample_CNG_
|
||||
{
|
||||
uint8_t flag;
|
||||
uint16_t max_amplitude; // 最大幅值
|
||||
}Loop_Sample_Cng;
|
||||
|
||||
typedef struct _Loop_Balance_Ori_CNG_
|
||||
{
|
||||
uint8_t flag;
|
||||
uint16_t max_cnt ; // 最大补偿次数
|
||||
}Loop_Balance_Ori_Cng; // 漂移补偿
|
||||
|
||||
typedef struct _Loop_Release_Ori_PlanB_
|
||||
{
|
||||
uint8_t flag_weight;
|
||||
uint16_t max_amplitude; //最大幅值
|
||||
uint8_t timeout; // 单位:分钟
|
||||
}Loop_Release_Ori_PlanB;
|
||||
|
||||
typedef struct _Loop_Release_Change_Rate_
|
||||
{
|
||||
uint8_t flag_weight;
|
||||
uint8_t rate_first;
|
||||
uint8_t rate_second;
|
||||
uint8_t mode;
|
||||
}Loop_Release_Change_Rate;
|
||||
|
||||
|
||||
typedef struct _Loop_Balance_PlanB_
|
||||
{
|
||||
Loop_Sample_Cng sample_cng;
|
||||
Loop_Balance_Ori_Cng balance_ori_cng;
|
||||
Loop_Release_Ori_PlanB release_ori_planB;
|
||||
Loop_Release_Change_Rate release_change_rate;
|
||||
}Loop_Balance_PlanB;
|
||||
|
||||
extern Loop_Balance_PlanB g_loop_balance_planB;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t sensitvity; // 高四位表示灵敏度的数量,低四位表示当前灵敏度的序号(从0开始)
|
||||
uint8_t delay_time;
|
||||
uint8_t output_mode;
|
||||
uint8_t direction_mode; // 方向判别模式,0 触发模式, 非0 表示方向判别模式
|
||||
uint8_t loopFreq_Level; // 高低频
|
||||
uint8_t loopSafe_Timeout; // 线圈安全模式, 0表示关闭,非0表示开启,以10秒为单位
|
||||
uint8_t exist_mode; // 0 永久存在,非0,表示有限存在的时间,单位为10秒
|
||||
}Loop_Cng_Unit;
|
||||
extern Loop_Cng_Unit g_loop_cng_unit;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t sens_in;
|
||||
uint16_t sens_out;
|
||||
}Loop_Single_Sens;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t total;
|
||||
Loop_Single_Sens sens[MAX_LOOP_SENS_AMOUNT];
|
||||
}Loop_Sens_List;
|
||||
extern Loop_Sens_List g_loop_sens_list;
|
||||
|
||||
|
||||
|
||||
typedef struct _DBN_BLE_STATE_
|
||||
{
|
||||
uint8_t flag; // if need to report
|
||||
uint8_t enable; // 是否使能
|
||||
uint8_t send_flag;
|
||||
uint8_t obj_amount;
|
||||
uint8_t cmd;
|
||||
uint8_t sens_type;
|
||||
uint8_t dat_len ;
|
||||
uint8_t dat_offset;
|
||||
uint8_t pkg_amount;
|
||||
uint8_t pkg_seq;
|
||||
uint16_t interval;
|
||||
uint32_t counter;
|
||||
uint8_t timeout_min; // minute
|
||||
uint32_t timeout_counter;
|
||||
} DBN_BLE_State;
|
||||
|
||||
extern DBN_BLE_State g_dbn_ble_state_acs_enable;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SENS_NONE = 0,
|
||||
SENS_SUB_INFO = 1, // 传感器设备信息
|
||||
SENS_OBJ_DYNAMIC = 2, // 动态目标类型
|
||||
SENS_SOUTPUT_STATUS = 3, // 当前开关量输出的状态
|
||||
SENS_DETAIL_CNG = 4, // 详细配置
|
||||
SENS_LOOP_DYNAMIC = 5, // 线圈动态信息
|
||||
SENS_OBJ_BackGround = 6, //
|
||||
SENS_OBJ_INSIDE = 7, //
|
||||
SENS_LOOP_TREND,
|
||||
SENS_OBJ_DYNAMIC_SIMPLE,
|
||||
SENS_OBJ_STATIC_XuJing, //10, 0x0A
|
||||
SENS_DOBULE_LOOP_ESTIMATE //0x0B, 线圈环境评估
|
||||
} SUB_SENS_TYPE; // 传感数据类型
|
||||
|
||||
|
||||
|
||||
typedef struct _LOOP_ACS_INFO
|
||||
{
|
||||
uint8_t flag_event;
|
||||
uint8_t loop_num;
|
||||
uint8_t freq_level;
|
||||
uint8_t sensity;
|
||||
uint8_t relay1_cng;
|
||||
uint8_t relay1_state;
|
||||
uint8_t relay2_cng;
|
||||
uint8_t relay2_state;
|
||||
uint8_t loop_state;
|
||||
uint8_t output_mode;
|
||||
uint8_t dir_mode;
|
||||
uint8_t delay;
|
||||
uint8_t car_state;
|
||||
uint8_t direction;
|
||||
uint8_t flag_loop_safe;
|
||||
uint32_t loop_safe_counter;
|
||||
uint8_t condition;
|
||||
uint8_t flag_change;
|
||||
uint32_t frequent;
|
||||
uint32_t loop_capvd;
|
||||
int32_t variation;
|
||||
uint32_t event_counter;
|
||||
uint32_t report_counter;
|
||||
} Loop_ACS_Info;
|
||||
extern Loop_ACS_Info g_loop_acs_info;
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
#define HOLD_TIME 5*1200
|
||||
#define LC_HOLD_TIME 4*1200 //时间4分钟
|
||||
#define IN_DELAY 10
|
||||
#define OUT_DELAY 39
|
||||
#define PLUSE_DELAY 10
|
||||
|
||||
|
||||
void write_cfg_to_store(uint32_t wAddr, uint8_t * p, uint32_t len);
|
||||
void read_cfg_from_store(uint32_t addr, uint8_t *p, uint32_t len);
|
||||
|
||||
|
||||
#endif /* INCLUDE_STORAGE_H_ */
|
||||
Reference in New Issue
Block a user