精简 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。 规格书与注释同步精简。
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/******************************************************************************
|
||||
* @file app_defer.c
|
||||
* @brief ISR→任务上下文的延后执行标志位实现
|
||||
* @author cyWu <1917507415@qq.com>
|
||||
* @date 2026.08.31
|
||||
* @version V1.0.0,首次发布
|
||||
******************************************************************************/
|
||||
|
||||
#include "system/includes.h"
|
||||
#include "app_defer.h"
|
||||
|
||||
/** 位掩码,volatile:request() 在中断上下文写,take()/is_pending()/cancel()
|
||||
* 在任务上下文读写,两侧都用 local_irq_disable/enable 包一下读改写,
|
||||
* 避免"任务侧正在清 A 位时中断侧设 B 位"这种读改写竞态把 B 位冲丢。 */
|
||||
static volatile uint8_t s_flags;
|
||||
|
||||
void app_defer_request(AppDeferBit_t bit)
|
||||
{
|
||||
if (bit >= APP_DEFER_MAX) {
|
||||
return;
|
||||
}
|
||||
local_irq_disable();
|
||||
s_flags |= (uint8_t)(1u << bit);
|
||||
local_irq_enable();
|
||||
}
|
||||
|
||||
uint8_t app_defer_take(AppDeferBit_t bit)
|
||||
{
|
||||
uint8_t was_set;
|
||||
|
||||
if (bit >= APP_DEFER_MAX) {
|
||||
return 0;
|
||||
}
|
||||
local_irq_disable();
|
||||
was_set = (s_flags & (uint8_t)(1u << bit)) ? 1 : 0;
|
||||
s_flags &= (uint8_t)~(1u << bit);
|
||||
local_irq_enable();
|
||||
return was_set;
|
||||
}
|
||||
|
||||
uint8_t app_defer_is_pending(AppDeferBit_t bit)
|
||||
{
|
||||
if (bit >= APP_DEFER_MAX) {
|
||||
return 0;
|
||||
}
|
||||
return (s_flags & (uint8_t)(1u << bit)) ? 1 : 0;
|
||||
}
|
||||
|
||||
void app_defer_cancel(AppDeferBit_t bit)
|
||||
{
|
||||
if (bit >= APP_DEFER_MAX) {
|
||||
return;
|
||||
}
|
||||
local_irq_disable();
|
||||
s_flags &= (uint8_t)~(1u << bit);
|
||||
local_irq_enable();
|
||||
}
|
||||
Reference in New Issue
Block a user