Files
JBao_Temp_Humi_Fan_FW/apps/usr_app/app_nvm.h
T
wuchuyuan e324ebd99b 精简 usr_app 架构:去掉关机/休眠死代码,按键复用 key.c 状态机,ISR 重活统一延后到任务上下文
Type-C 长供电、上电即工作、无软关机,删除 app_boot/app_power 及 DP0 开关相关逻辑,
去掉空占位 app_fan_run 和无效的 usr_timer_pick_mode/rearm(数码管 4ms 扫描已 priority=1,
系统本来就不会进低功耗)。按键 5s 配对 / 12s OTA 改走 key.c 长按分级,去掉自计时与 1~5s 死区。
新增 app_defer,NVM/配对/OTA 只在 ISR 置位、在 500ms 任务上下文落地,避免再在 usr_timer 里写 flash。
规格书与注释同步精简。
2026-08-31 17:57:52 +08:00

69 lines
2.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.
/******************************************************************************
* @file app_nvm.h
* @brief CBR3 VM 持久化(P1 起):mode/fan_gear/条件/定时/使能
* @author cyWu <1917507415@qq.com>
* @date 2026.08.31
* @version V1.1.0,实现:3 个 VM item(状态/条件/定时)+ 500ms 防抖写入 +
* 立即写接口
*
* @note 存:mode、fan_gear、cond_en、cond_config1~7、time_en、time_config1~7、
* fault_en、alarm_en。不存:DP0、条件作废标志、模式已运行秒数、原始采样。
* 写 VM 时机:APP 改配置后、单次定时自毁、档位/模式稳定变化(500ms 防抖)。
******************************************************************************/
#ifndef __APP_NVM_H__
#define __APP_NVM_H__
#include <stdint.h>
/**
* @brief 初始化(校验 VM 有效性,仅日志;数据加载在 app_nvm_load
* @return 无
*/
void app_nvm_init(void);
/**
* @brief 立即保存全部业务字段到 VM
* @note syscfg 写入不能在裸中断里调用;只由 app_nvm_flush()(任务上下文)调用
* @return 无
*/
void app_nvm_save(void);
/**
* @brief 从 VM 加载业务字段并应用(开机 3s 后调用):
* mode/fan_gear 恢复、条件/定时配置回填 gDevData;mode 从周期头开跑
* @return 无
*/
void app_nvm_load(void);
/**
* @brief 业务节拍(中断上下文):变化检测 + 防抖计时,**不执行写入**
* @param dt 距上次调用的毫秒数
* @note ⚠ 跑在 usr_timer 20ms 回调 = 硬件定时器中断上下文,栈极小,
* 只允许轻量比较计时;禁止在此调 syscfg_write(会栈溢出复位)。
* @return 无
*/
void app_nvm_tick(uint16_t dt);
/**
* @brief 任务上下文落盘:防抖满后真正写 VM(由 usr_timer_loop 500ms 调用)
* @note 必须且只能在非中断上下文调用(VM 擦写 flash 栈用量大)
* @return 无
*/
void app_nvm_flush(void);
/**
* @brief 标记业务字段有变化,防抖计时归零(档位/模式/配置变化时调用)
* @return 无
*/
void app_nvm_mark_dirty(void);
/**
* @brief 出厂重置:清全部业务 VM(保留 BLE 配对,规格书第 14 章)
* @note 由 jb_product DP25 调用;RAM 复位由调用方完成
* @return 无
*/
void app_nvm_reset(void);
#endif /* __APP_NVM_H__ */