mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-18 18:43:31 +08:00
Merge pull request #4938 from chenyingchun0312/master
[bsp/nrf52x] optimize drv_wdt.c
This commit is contained in:
commit
d05e209440
@ -6,6 +6,7 @@
|
|||||||
* Change Logs:
|
* Change Logs:
|
||||||
* Date Author Notes
|
* Date Author Notes
|
||||||
* 2020-08-18 ylz0923 first version
|
* 2020-08-18 ylz0923 first version
|
||||||
|
* 2021-08-12 chenyingchun optimize wdt_control arg usage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <board.h>
|
#include <board.h>
|
||||||
@ -42,7 +43,7 @@ static rt_err_t wdt_control(rt_watchdog_t *wdt, int cmd, void *arg)
|
|||||||
break;
|
break;
|
||||||
/* set watchdog timeout */
|
/* set watchdog timeout */
|
||||||
case RT_DEVICE_CTRL_WDT_SET_TIMEOUT:
|
case RT_DEVICE_CTRL_WDT_SET_TIMEOUT:
|
||||||
nrf5x_wdt_cfg.reload_value = (rt_uint32_t)arg * 1000;
|
nrf5x_wdt_cfg.reload_value = (*((rt_uint32_t*)arg)) * 1000;
|
||||||
break;
|
break;
|
||||||
case RT_DEVICE_CTRL_WDT_GET_TIMEOUT:
|
case RT_DEVICE_CTRL_WDT_GET_TIMEOUT:
|
||||||
*((rt_uint32_t*)arg) = nrf5x_wdt_cfg.reload_value;
|
*((rt_uint32_t*)arg) = nrf5x_wdt_cfg.reload_value;
|
||||||
@ -79,9 +80,10 @@ INIT_BOARD_EXPORT(rt_wdt_init);
|
|||||||
|
|
||||||
static int wdt_sample(int argc, char *argv[])
|
static int wdt_sample(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
rt_uint32_t timeout = 2; /* 溢出时间,单位:秒*/
|
||||||
rt_device_t wdt = rt_device_find("wdt");
|
rt_device_t wdt = rt_device_find("wdt");
|
||||||
rt_device_init(wdt);
|
rt_device_init(wdt);
|
||||||
rt_device_control(wdt, RT_DEVICE_CTRL_WDT_SET_TIMEOUT, (void *)2);
|
rt_device_control(wdt, RT_DEVICE_CTRL_WDT_SET_TIMEOUT, &timeout);
|
||||||
rt_device_control(wdt, RT_DEVICE_CTRL_WDT_START, RT_NULL);
|
rt_device_control(wdt, RT_DEVICE_CTRL_WDT_START, RT_NULL);
|
||||||
}
|
}
|
||||||
MSH_CMD_EXPORT(wdt_sample, wdt sample);
|
MSH_CMD_EXPORT(wdt_sample, wdt sample);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user