Appendix a, Programming watchdog timer – Lanner LEC-7105 User Manual

Page 22

Advertising
background image

22

Programming Watchdog Timer

Embedded and Industrial Computing

Appendix A

DIRECT_IO_ACCESS=1, use the command: “./

wd_tst --swt xxx” to start the watchdog timer

instead .

Watchdog timer can support two functions,

2.

- system rest or LAN bypass. However, only

one function can be activated at a time. You

should modify the code or switch it to the

desired state/function accordingly.

For more details, refer to the README file

3.

contained within the program.

A sample Watchdog program in C:

*********************************************************

**********************/
#include “../include/config.h”

#ifdef DJGPP

/* standard include file */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/* For DOS DJGPP */
#include <dos.h>
#include <inlines/pc.h>

#else //DJGPP
/* For Linux */

#ifdef DIRECT_IO_ACCESS
/* For Linux direct io access code */
/* standard include file */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#if defined(LINUX_ENV)
#include <sys/io.h>
#endif

#if defined(FreeBSD_ENV)
#include <machine/cpufunc.h>
#endif

#include <time.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#define delay(x) usleep(x)
#endif

#ifdef MODULE

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <asm/io.h>
#include <linux/delay.h>

#undef delay
#define delay(x) mdelay(x)
#undef fprintf
#define fprintf(S, A) printk(A)

#endif //MODULE

#ifdef KLD_MODULE

#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/bus.h>

Advertising