Files

59 lines
1.5 KiB
C
Raw Permalink 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.
/**
* @file fault_flash_impl.h
* @brief 历史故障记录持久化接口(EEPROM索引 + 外部Flash数据)。
*/
#ifndef FAULT_FLASH_IMPL_H
#define FAULT_FLASH_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
#include "main.h"
#include "fault_cheak/faultcheck_task.h"
#include "fault_cheak/fault_interface.h"
#define FAULT_INFO_TEXT_MAX_LEN (64u)
/* 故障历史存储功能开关:
* - 0:先屏蔽(避免影响 EEPROM 可靠性排查)
* - 1:使能(恢复 EEPROM 索引 + Flash 记录读写)
*/
#ifndef FAULT_FLASH_MGR_ENABLE
#define FAULT_FLASH_MGR_ENABLE (1u)
#endif
/**
* @brief 历史故障管理信息(存放在 EEPROM)。
*/
typedef struct
{
U16_T u16_head; /* 固定头 0x5AA5 */
U16_T u16_hisFaultCnt; /* 历史记录总数(上限 HIS_FAULT_MAX_CNT */
U16_T u16_currIndex; /* 当前最新记录逻辑索引,初值 RECORD_ZERO_SAVE */
} S_HIS_FAULT_MNG;
typedef struct
{
E_FAULT_INFO e_mag;
char info[FAULT_INFO_TEXT_MAX_LEN];
} S_FAULT_INFO;
void v_fault_flash_init(void);
void v_write_eeprom_hisFaultMng(S_HIS_FAULT_MNG *hisFaultMng);
void v_read_eeprom_hisFaultMng(S_HIS_FAULT_MNG *hisFaultMng);
void v_fault_clear_his_fault(void);
U16_T u16_fault_get_his_count(void);
U8_T u8_fault_read_his_by_newest(U16_T newest_pos, HIS_FAULT_DATA_T *pt_hisFault);
void v_hisFault_save_record(HIS_FAULT_DATA_T *pt_hisFault_data);
void v_read_hisFault_record(HIS_FAULT_DATA_T *pt_hisFault, U16_T u16_index);
#ifdef __cplusplus
}
#endif
#endif /* FAULT_FLASH_IMPL_H */