1.修复定时器失效bug。

This commit is contained in:
MacRsh
2023-07-14 00:39:16 +08:00
parent c503cbfbd4
commit 4e6498c0e7

View File

@@ -130,6 +130,11 @@ static mr_err_t mr_timer_ioctl(mr_device_t device, int cmd, void *args)
{
timer->overflow = 0;
timer->cycles = timer->reload;
/* When the time is not less than one time, the timer is started */
if (timer->cycles == 0)
{
return -MR_ERR_INVALID;
}
timer->ops->start(timer, timer->timeout / (1000000 / timer->config.freq));
return MR_ERR_OK;
}
@@ -186,7 +191,7 @@ static mr_ssize_t mr_timer_write(mr_device_t device, mr_off_t pos, const void *b
send_buffer++;
/* When the time is not less than one time, the timer is started */
if (timer->cycles != 0)
if (timer->cycles == 0)
{
return -MR_ERR_INVALID;
}