From 550f7b4aaa4021db734692e74755b37249d48ca0 Mon Sep 17 00:00:00 2001 From: coffee Date: Wed, 6 Aug 2025 15:32:03 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=88=A0=E9=99=A4=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E5=99=A8=E6=97=A0=E7=94=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/HTimer.h | 8 +++----- src/HTimer.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/HTimer.h b/include/HTimer.h index c7021ee..49ecf87 100644 --- a/include/HTimer.h +++ b/include/HTimer.h @@ -11,15 +11,12 @@ #include -// 定时器最大数量 -#ifndef HTIMER_MAX -#define HTIMER_MAX 10 -#endif - +// 定时器注册最大数量 #ifndef HTIMER_REGISTER_MAX #define HTIMER_REGISTER_MAX (1) #endif +// 无效值 #ifndef HTIMER_INVALID #define HTIMER_INVALID -1 #endif @@ -38,6 +35,7 @@ typedef enum typedef void (*HTimerCallType)(); +///< 注册的定时器信息, 定义为数组, 数量由外部控制 typedef struct HTimerInfo { uint32_t flags : 1; ///< 定时器标志, eTimerFlags uint32_t enable : 1; ///< 定时器使能 diff --git a/src/HTimer.c b/src/HTimer.c index 1f48572..2b14ff5 100644 --- a/src/HTimer.c +++ b/src/HTimer.c @@ -175,7 +175,7 @@ void HTimerRemove(uint8_t id, int16_t index) { return ; } - if (index < 0 || index >= HTIMER_MAX) { + if (index < 0 || index >= sTimeRegisters[id].len) { LogD("error index[%d]", index); return ; }