Files
Leakage-Control/calib_board/usr/app/app_timer.h
2026-01-30 17:04:39 +08:00

48 lines
1.6 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.

#ifndef _APP_TIMER_H_
#define _APP_TIMER_H_
#include "main.h"
/* 时间相关宏定义 */
#define TIME_TRUE 1U /* 时间已到 */
#define TIME_FALSE 0U /* 时间未到 */
/******************************************
* 结构体: app_timer_class_t
* 功能: 任务时间片结构体
* 描述: 定义单个任务的时间片调度参数
*******************************************/
typedef struct
{
u8 run_flag; /* 调度标志1调度0挂起 */
u16 timer_count; /* 时间片计数值 */
u16 timer_reload; /* 时间片重载值 */
void (*task)(void); /* 任务函数指针 */
} app_timer_class_t;
/******************************************
* 结构体: app_timer_t
* 功能: 应用定时器结构体
* 描述: 管理所有任务的定时调度
*******************************************/
typedef struct
{
u16 ms_tick; /* 滴答毫秒级计数器 */
u16 s_tick; /* 滴答秒级计数器 */
u16 task_num; /* 任务数量 */
app_timer_class_t *p_timer_class; /* 任务时间片数组指针 */
void (*init)(u8, app_timer_class_t *); /* 初始化函数指针 */
void (*task)(void); /* 定时器任务函数指针 */
void (*increment_int)(u16); /* 中断递增函数指针 */
} app_timer_t;
/* 函数声明 */
u8 app_timer_check_time_out(u16 time_start, u16 time_now, u16 time_out);
u16 app_timer_check_run_time(u16 time_start, u16 time_now, u16 time_out);
void delay_ms(u16 delay);
/* 声明外部变量 */
extern app_timer_t app_timer;
#endif