看门狗在注册之后
并没有初始化
仿真的时候发现drv_init并没有执行,所以设备的基地址hiwdg.Instance=0
在open设备设置溢出时间的时候使用非法的地址导致硬件错误
所以初始化函数drv_init在哪里用,怎么用?
[i=s] 本帖最后由 misonyo 于 2018-10-31 17:39 编辑 [/i]
[md]参考下面的代码使用看门狗
```
static rt_device_t wdg_dev;
static void idle_hook(void)
{
/ 在空闲线程的回调函数里喂狗 /
rt_device_control(wdg_dev, RT_DEVICE_CTRL_WDT_KEEPALIVE, NULL);
}
static int iwdg_sample(int argc,char argv[])
{
rt_err_t result = RT_EOK;
rt_uint32_t timeout = 1000; / 超时时间为1000ms*/
char device_name[RT_NAME_MAX];
}
/ 导出到 msh 命令列表中 /
MSH_CMD_EXPORT(iwdg_sample, iwdg sample);
```[/md]
[md]参考下面的代码使用看门狗
```
您好,我在操作看门狗的时候根据您贴出的例程来操作 rt_device_find()返回失败。从MSH上查看device_list并没有找到iwg的设备
msh >list_d
list_device
msh >list_device
device type ref count
uart3 Character Device 0
uart2 Character Device 0
uart1 Character Device 2
pin Miscellaneous Device 0
msh >
麻烦问题项我应该怎么把iwg注册上去呢?
在main函数中增加res = rt_hw_watchdog_register((rt_watchdog_t *)&wtt, wdg_name, RT_DEVICE_FLAG_RDWR,NULL);可以查找到设备但是在init的时候就会产生
psr: 0x21000200
r00: 0x00000000
r01: 0x20000191
r02: 0x00000008
r03: 0xdeadbee3
r04: 0xdeadbeef
r05: 0x00000075
r06: 0x20000190
r07: 0xdeadbee3
r08: 0xdeadbeef
r09: 0xdeadbeef
r10: 0xdeadbeef
r11: 0xdeadbeef
r12: 0x00000000
lr: 0x0800ae09
pc: 0x0800c6c2
hard fault on thread: tshell
thread pri status sp stack size max used left tick error
tshell 20 ready 0x00000044 0x00001000 03% 0x0000000a 000
tidle 31 ready 0x00000048 0x00000100 28% 0x00000020 000
timer 4 suspend 0x00000060 0x00000200 18% 0x00000009 000
main 10 close 0x0000006c 0x00000800 10% 0x0000000e 000
bus fault:
SCB_CFSR_BFSR:0x82 PRECISERR SCB->BFAR:DEADBEE3
您好,我在操作看门狗的时候根据您贴出的例程来操作 rt_device_find()返回失败。从MSH上查看device_list …
看了下stm32f10x_HAL这个库是有看门狗驱动的,建议楼主使用最新的stm32的bsp哈,也有看门狗驱动,旧BSP没有维护了。新系列文档很全的。在rt-thread\bsp\stm32目录下。