Files
JBao_Heat_Pad_FW/apps/usr_app/app_nvm.c
T

124 lines
2.5 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.
/******************************************************************************
* @file app_nvm.c
* @brief CBR1 VM 持久化(P1 起):heat_switch / linkage 20B / time_en /
* time_config1~7 / run_record 31天 / fault_en / alarm_en
* @author cyWu <1917507415@qq.com>
* @date 2026.09.04
* @version V1.0.0P0 = 空骨架(BOARD_NVM_ENABLE=0P1 填充)
*
* @note ⚠ 写 flash 只能在任务上下文(app_nvm_flush / app_nvm_save),
* 20ms 中断上下文只允许 app_nvm_tick 打脏。
******************************************************************************/
#include "system/includes.h"
#include "app_nvm.h"
#include "board_pin.h"
#define LOG_TAG_CONST APP
#define LOG_TAG "[APP_NVM]"
#define LOG_INFO_ENABLE
#include "debug.h"
static void nvm_disabled_once(void)
{
static uint8_t s_logged;
if (!s_logged) {
s_logged = 1;
log_info("app_nvm disabled (P1)\n");
}
}
/**
* @brief 初始化(P1:校验 VM 有效性)
* @return 无
*/
void app_nvm_init(void)
{
#if BOARD_NVM_ENABLE
/* P1: 校验 VM 有效性 */
#else
nvm_disabled_once();
#endif
}
/**
* @brief 立即保存全部业务字段(任务上下文)
* @return 无
*/
void app_nvm_save(void)
{
#if !BOARD_NVM_ENABLE
nvm_disabled_once();
#endif
}
/**
* @brief 立即保存运行记录 item(跨天旋转用)
* @return 无
*/
void app_nvm_save_runrec(void)
{
#if !BOARD_NVM_ENABLE
nvm_disabled_once();
#endif
}
/**
* @brief 从 VM 加载业务字段并应用(开机调用)
* @return 无
*/
void app_nvm_load(void)
{
#if BOARD_NVM_ENABLE
/* P1: heat_switch 恢复 + linkage/timer/run_record 回填 gDevData */
#else
nvm_disabled_once();
#endif
}
/**
* @brief 业务节拍(中断上下文):变化检测 + 防抖计时,不写 flash
* @param dt 距上次调用的毫秒数
* @return 无
*/
void app_nvm_tick(uint16_t dt)
{
#if !BOARD_NVM_ENABLE
(void)dt;
#endif
}
/**
* @brief 任务上下文落盘:防抖满后真正写 VM(500ms loop 调用)
* @return 无
*/
void app_nvm_flush(void)
{
#if !BOARD_NVM_ENABLE
nvm_disabled_once();
#endif
}
/**
* @brief 标记业务字段有变化,防抖计时归零
* @return 无
*/
void app_nvm_mark_dirty(void)
{
#if !BOARD_NVM_ENABLE
nvm_disabled_once();
#endif
}
/**
* @brief 出厂重置:清全部业务 VM(保留 BLE 配对)
* @return 无
*/
void app_nvm_reset(void)
{
#if !BOARD_NVM_ENABLE
nvm_disabled_once();
#endif
}