Files
DLD110SV4B/BLE/DLD110S_Peripheral_28K/APP/include/storage.h
T

188 lines
5.3 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.
/*
* 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_ */