在嵌入式工控领域,为保障程序的持续运行,使用看门狗是必须的。
调狐上网,发现详细介绍s3c2440 Watchdog的资料真不多。于是就对着linux kernel里的代码自己研究吧。
偶写的测试例程如下所示:
#include time_t backTime; static void sigAlarm(int sig) write(wt_fd, &flag, 1); //Reset Watchdog wt_fd = open('/dev/watchdog', O_RDWR); alarm(3); while(1); write(wt_fd, &flag, 1);
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
struct tm *pBackTime;
int wt_fd;
{
char flag = '0';
(void)time(&backTime);
pBackTime= localtime(&backTime);
printf('day: %d; hour: %d; min: %d; sec: %dn', pBackTime->tm_mday, pBackTime->tm_hour, pBackTime->tm_min, pBackTime->tm_sec);
alarm(2);
return;
}
int main()
{
char flag = 'V';
int ret;
int timeout = 42;
if(SIG_ERR == signal(SIGALRM, sigAlarm))
{
perror('signal (SIGALARM) error');
}
if(wt_fd <= 0)
{
printf('Fail to open watchdog device!n');
}
else
{
write(wt_fd,NULL,0);
printf('Turn on Watch Dogn');
ret = ioctl(wt_fd, WDIOC_SETTIMEOUT, &timeout);
if(EINVAL == ret)
{
printf('EINVAL Returnedn');
}
else if(EFAULT == ret)
{
printf('EFAULT Returnedn');
}
else if(0 == ret)
{
printf('Set timeout %d secs successn', timeout);
}
else
{
printf('Ret %dn', ret);
}
}
printf('Turned off Watch Dogn');
close(wt_fd);
return 0;
}
本代码实现了启用看门狗,设置看门狗超时时间,定时喂狗,关闭看门狗还没有修正。
经实践发现,42秒是s3c2440最长的超时时间。
上一篇:S3C2440上LCD驱动(FrameBuffer)实例开发讲解
下一篇:移植u-boot-2010.12.tar.bz2版本到s3c2440过程
- 热门资源推荐
- 热门放大器推荐
- 用于 7VIN 至 16VIN、1.5V 和 1.2V 输出的 LTM4628EV DC/DC 模块稳压器的典型应用电路
- 使用 Analog Devices 的 LTC3728LIGN 的参考设计
- DER-406 - 适用于 A19 灯的 5.76 W 高 PF 非隔离降压-升压型 TRIAC 调光 LED 驱动器
- ADR5045B 5V 输出精密微功率并联模式电压基准的典型应用
- LT3970EDDB-3.42 2.5V 降压转换器的典型应用
- MC78M08BDTG 8V 电流调节器的典型应用
- LT1021DCN8-5 精密电压基准的典型应用
- DER-282 - 100W, 扁平(11 mm), LLC DC-DC转换器
- REF193 低压差开尔文连接电压基准的典型应用电路
- LT3088EM 线性稳压器用于添加软启动的典型应用

现代雷达系统的信号设计
5962-89541022A

BFR340T






京公网安备 11010802033920号