1. Revise the timerSet function

This commit is contained in:
onexs-xsi
2026-01-29 10:17:11 +08:00
parent 3d94e60587
commit 30a2e0ef2c
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -2833,9 +2833,9 @@ m5pm1_err_t M5PM1::timerSet(uint32_t seconds, m5pm1_tim_action_t action)
return M5PM1_ERR_NOT_INIT;
}
// 验证定时器计数值 (31-bit: 0-0x7FFFFFFF) / Validate timer count
if (seconds > 0x7FFFFFFF) {
M5PM1_LOG_E(TAG, "Invalid timer count: %lu (max 0x7FFFFFFF, ~68 years)", seconds);
// 验证定时器计数值 (最大 214748364 秒) / Validate timer count (max 214748364 seconds)
if (seconds > 214748364) {
M5PM1_LOG_E(TAG, "Invalid timer count: %lu (max 214748364, ~6.8 years)", seconds);
return M5PM1_ERR_INVALID_ARG;
}
+3 -3
View File
@@ -263,7 +263,7 @@ typedef enum {
#define M5PM1_REG_TIM_CNT_2 0x3A // R/W 定时器计数字节2 / Timer counter byte 2
#define M5PM1_REG_TIM_CNT_3 \
0x3B // R/W 定时器计数字节3bit 6:0,最大31位) / Timer counter byte 3 (bit 6:0, max 31 bits)
// 31位定时器,单位秒,最大约68年 / 31-bit timer in seconds, max ~68 years
// 定时器,单位秒,最大214748364秒(约6.8年) / Timer in seconds, max 214748364 (~6.8 years)
#define M5PM1_REG_TIM_CFG \
0x3C // R/W 定时器配置 / Timer configuration
// [7-4] 保留 / Reserved
@@ -1853,8 +1853,8 @@ public:
/**
* @brief
* Set timer
* @param seconds
* Timer duration in seconds
* @param seconds 214748364
* Timer duration in seconds (max 214748364)
* @param action
* Action after timer expires:
* - M5PM1_TIM_ACTION_STOP: / Stop, no action