Skip to content

Commit 18c9c50

Browse files
[bsp/nrf52x] optimize drv_wdt.c
refer to issue: #4558
1 parent 39c8bef commit 18c9c50

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bsp/nrf5x/libraries/drivers/drv_wdt.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2020-08-18 ylz0923 first version
9+
* 2021-08-12 chenyingchun optimize wdt_control arg usage
910
*/
1011

1112
#include <board.h>
@@ -42,7 +43,7 @@ static rt_err_t wdt_control(rt_watchdog_t *wdt, int cmd, void *arg)
4243
break;
4344
/* set watchdog timeout */
4445
case RT_DEVICE_CTRL_WDT_SET_TIMEOUT:
45-
nrf5x_wdt_cfg.reload_value = (rt_uint32_t)arg * 1000;
46+
nrf5x_wdt_cfg.reload_value = (*((rt_uint32_t*)arg)) * 1000;
4647
break;
4748
case RT_DEVICE_CTRL_WDT_GET_TIMEOUT:
4849
*((rt_uint32_t*)arg) = nrf5x_wdt_cfg.reload_value;
@@ -79,9 +80,10 @@ INIT_BOARD_EXPORT(rt_wdt_init);
7980

8081
static int wdt_sample(int argc, char *argv[])
8182
{
83+
rt_uint32_t timeout = 2; /* 溢出时间,单位:秒*/
8284
rt_device_t wdt = rt_device_find("wdt");
8385
rt_device_init(wdt);
84-
rt_device_control(wdt, RT_DEVICE_CTRL_WDT_SET_TIMEOUT, (void *)2);
86+
rt_device_control(wdt, RT_DEVICE_CTRL_WDT_SET_TIMEOUT, &timeout);
8587
rt_device_control(wdt, RT_DEVICE_CTRL_WDT_START, RT_NULL);
8688
}
8789
MSH_CMD_EXPORT(wdt_sample, wdt sample);

0 commit comments

Comments
 (0)