打盹的消防车 0e254652aa
add:air105 bsp (#5607)
* add:air105 bsp

* add:去掉注释代码

* add:注释修改

* fix:格式化一遍代码格式

* add:main函数添加闪灯

* add:完善bsp

* add:添加一些信息

* add:使用工作队列喂狗

* add:整理目录

* add:去掉乱码部分

* add:修改readme

* add:更新readme说明

* add:去掉bootloader.bin和soc_download.exe,README.md中添加标注

* fix:去除多余文件

* add:补充license

* add:支持scons --dist

* add:更新soc_download.exe连接地址
2022-03-08 12:04:17 +08:00

54 lines
1.3 KiB
C

/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-02-22 airm2m first version
*/
#include <rtthread.h>
#include <rtdevice.h>
static char device_name[] = "wdt";
static rt_device_t wdg_dev;
static struct rt_work wdt_feed;
static void wdt_feed_func(struct rt_work *work, void *work_data)
{
rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_KEEPALIVE, RT_NULL);
rt_work_submit(&wdt_feed, 1200);
}
static int wdt_feed_init(void)
{
rt_err_t ret = RT_EOK;
rt_uint32_t timeout = 2;
wdg_dev = rt_device_find(device_name);
if (!wdg_dev)
{
rt_kprintf("find %s failed!\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_control(wdg_dev, RT_DEVICE_CTRL_WDT_START, RT_NULL);
if (ret != RT_EOK)
{
rt_kprintf("start %s failed!\n", device_name);
return -RT_ERROR;
}
rt_work_init(&wdt_feed, wdt_feed_func, RT_NULL);
rt_work_submit(&wdt_feed, 1200);
return RT_EOK;
}
INIT_COMPONENT_EXPORT(wdt_feed_init);