optical/NxBase/trigger.h
2025-09-04 09:45:08 +08:00

71 lines
1.4 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.

#ifndef __TRIGGER_H__
#define __TRIGGER_H__
#include "config.h"
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
typedef void (*TriggerFunc)(void);
typedef struct
{
u32 triggerTimer; // 触发定时值
TriggerFunc triggerExFunc; // 触发执行函数(触发立刻执行,没有延迟,但不能占用时间太长)
int triggerTask; // 触发标志
TriggerFunc triggerTaskFunc; // 触发任务函数(触发创建任务,可能会有延迟)
}TriggerCtrl;
#ifndef MAX_TRIGGER_TASK
#define MAX_TRIGGER_TASK 10
#endif
/*
* 20220726
* 定时任务单次执行所消耗的最大时长,超过此时长则不继续执行,留待下次执行
* 单位us
* 为了避免单次执行所消耗的时间太多,影响到其他任务的运行
*/
#ifndef TRIGGER_MAXTIM
#define TRIGGER_MAXTIM (0)
#endif
//---------------------------------------------------------------------------
void InitTrigger(void);
void TriggerIntProc(void);
void TriggerTask(void);
// 添加触发事件到列表
int AddTriggerToList(int gapms, TriggerFunc exf, TriggerFunc tskf);
u32 GetTickTimer(void);
// 得到时间计数, 单位100ns
u32 Get100NsSoftTimer(void);
// 得到时间计数, 单位1us
u32 GetUsSoftTimer(void);
// 得到时间计数, 单位0.1ms
u32 Get100UsSoftTimer(void);
// 得到时间计数, 单位1ms精度:1ms
u32 GetMsSoftTimer(void);
// 得到时间计数, 单位:1ms 精度:10ms
u32 GetMsSoftTimer10(void);
//---------------------------------------------------------------------------
#endif