bsp: cvitek: fix the wdt timeout unit problem

See `components/drivers/include/drivers/watchdog.h`

maco definition of
RT_DEVICE_CTRL_WDT_GET_TIMEOUT
RT_DEVICE_CTRL_WDT_SET_TIMEOUT
RT_DEVICE_CTRL_WDT_GET_TIMELEFT

The wdt timeout time unit is defined as seconds in the API, but
the code incorrectly uses ms.

Correct this and comply with the API definition.

Signed-off-by: Chen Wang <unicorn_wang@outlook.com>
Reviewed-by: Yuanjie He <943313837@qq.com>
Reviewed-by: Shell <smokewood@qq.com>
This commit is contained in:
Chen Wang 2024-06-13 14:24:52 +08:00
parent 2d5eb2669f
commit 1bcf232d12
1 changed files with 10 additions and 2 deletions

View File

@ -66,6 +66,14 @@ rt_inline int wdt_top_in_ms(unsigned int top)
return (1U << (16 + top)) / (WDT_FREQ_DEFAULT / 1000);
}
/**
* @brief set timeout period
*
* @param reg_base base address of the watchdog controller
* @param ms timeout period (in millisecond)
*
* @return RT_EOK if successed.
*/
static rt_err_t csi_wdt_set_timeout(unsigned long reg_base, uint32_t ms)
{
rt_err_t ret = RT_EOK;
@ -115,13 +123,13 @@ static rt_err_t _wdt_control(rt_watchdog_t *wdt_device, int cmd, void *arg)
break;
case RT_DEVICE_CTRL_WDT_SET_TIMEOUT:
wdt->timeout = *(rt_uint32_t *)arg;
csi_wdt_set_timeout(reg_base, wdt->timeout);
csi_wdt_set_timeout(reg_base, wdt->timeout * 1000);
break;
case RT_DEVICE_CTRL_WDT_GET_TIMEOUT:
*(rt_uint32_t *)arg = wdt->timeout;
break;
case RT_DEVICE_CTRL_WDT_GET_TIMELEFT:
*(rt_uint32_t *)arg = (cvi_wdt_get_counter_value(reg_base) / (WDT_FREQ_DEFAULT / 1000U));
*(rt_uint32_t *)arg = (cvi_wdt_get_counter_value(reg_base) / WDT_FREQ_DEFAULT);
break;
case RT_DEVICE_CTRL_WDT_START:
cvi_wdt_set_respond_system_reset(reg_base);