#define RT_DEVICE_CTRL_WDT_GET_TIMEOUT (RT_DEVICE_CTRL_BASE(WDT) + 1) /* get timeout(in seconds) */ #define RT_DEVICE_CTRL_WDT_SET_TIMEOUT (RT_DEVICE_CTRL_BASE(WDT) + 2) /* set timeout(in seconds) */ RT_DEVICE_CTRL_WDT_SET_TIMEOUT 的单位是 s,但目前实现做成了 ms Collabor...
bsp/cvitek/cv18xx_risc-v/ master 参考 components/drivers/include/drivers/watchdog.h #define RT_DEVICE_CTRL_WDT_GET_TIMEOUT (RT_DEVICE_CTRL_BASE(WDT) + 1) /* get timeout(in seconds) */ #define RT_DEVICE_CTRL_WDT_SET_TIMEOUT (RT_DEVICE_CTRL_...
rt_err_t rt_device_unregister(rt_device_t dev); 下面代码为看门狗设备的注册示例, 调用 rt_hw_watchdog_register() 接口后, 设备通过rt_device_register() 接口被注册到 I/O 设备管理器中。 const static struct rt_device_ops wdt_ops = { rt_watchdog_init, rt_watchdog_open, rt_watchdog_cl...
ret = rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_SET_TIMEOUT, &timeout); if (ret != RT_EOK) { rt_kprintf("set %s timeout failed!n", device_name); return RT_ERROR; } /启动看门狗/ ret = rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_START, RT_NULL); if (ret != RT_E...
rtthread将设备抽象成rt_device。 /** * Device structure */ struct rt_device { struct rt_object parent; /**< inherit from rt_object */ enum rt_device_class_type type; /**< device type */ rt_uint16_t flag; /**< device flag */ ...
wdg_dev=rt_device_find(device_name); if(!wdg_dev) { rt_kprintf("find %s failed!\n",device_name); returnRT_ERROR; } /* 设置看门狗溢出时间 */ ret=rt_device_control(wdg_dev,RT_DEVICE_CTRL_WDT_SET_TIMEOUT,&timeout); if(ret!=RT_EOK) ...
\n", device_name); return RT_ERROR; } /* 设置看门狗溢出时间 */ ret = rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_SET_TIMEOUT, &timeout); if (ret != RT_EOK) { rt_kprintf("set %s timeout failed!\n", device_name); return RT_ERROR; } /* 启动看门狗 */ ret = rt_device...
ioctl(wdt_fd, CTRL_WDT_KEEPALIVE, NULL) 1.3.6.2 内核态程序使用WDT 获取设备句柄 wdt_dev = rt_device_find(WDT_DEVICE_NAME); 初始化设备 rt_device_init(wdt_dev); 设置超时时间 rt_device_control(wdt_dev, KD_DEVICE_CTRL_WDT_SET_TIMEOUT, &timeout); 启动看门狗计时 rt_device_control(...
\n",IWDG_DEVICE_NAME);returnres;}/* 设置看门狗溢出时间 */res=rt_device_control(wdg_dev,RT_DEVICE_CTRL_WDT_SET_TIMEOUT,&timeout);if(res!=RT_EOK){rt_kprintf("set %s timeout failed!\n",IWDG_DEVICE_NAME);returnres;}/* 设置空闲线程回调函数 */rt_thread_idle_sethook(idle_hook);...
= RT_NULL); device = &(wtd->parent); device->type = RT_Device_Class_Miscellaneous; device->rx_indicate = RT_NULL; device->tx_complete = RT_NULL; device->ops = &wdt_ops; device->user_data = data; /* register a character device */ return rt_device_register(...