zhuangquan

1.内核配置

  ------->Device Drivers

    -------->Watchdog Timer Support

      -------->WatchDog Timer Driver Core[*]

      -------->Software watchdog[*]

   编译烧录内核,然后在板卡上面可以看到/dev/watchdog

 

2.看门狗编程

 

喂狗、喂狗时间设置、喂狗时间读取的接口如下:

 

ioctl(fd, WDIOC_KEEPALIVE, 0);
ioctl(fd, WDIOC_SETTIMEOUT, &timeout);
ioctl(fd, WDIOC_GETTIMEOUT, &timeout);

 

  

 

3.例程

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/watchdog.h>

void main(int argc, char *argv[])
{
  int fd,timeout;
  timeout = 15;

  fd = open("/dev/watchdog", O_WRONLY);
  if(fd == -1)
  {
    printf("open watchdog error \r\n");
    return 0;
  }

  ioctl(fd,WDIOC_SETTIMEOUT, &timeout);

  while(1)
  {
    ioctl(fd, WDIOC_KEEPALIVE);
    sleep(10);
  }
}

 

在内核中有看门狗的说明以及例程,也可以查看:

 

4.github网址

https://github.com/ssahai/linux/blob/master/Documentation/watchdog/watchdog-api.txt

  

 

 

 

 

 

 

 

      

分类:

技术点:

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2021-10-04
  • 2021-05-05
  • 2021-12-10
猜你喜欢
  • 2021-07-16
  • 2022-02-04
  • 2021-05-06
  • 2021-10-30
  • 2021-11-24
  • 2021-10-19
  • 2022-12-23
相关资源
相似解决方案