User`s manual

UC-7400-LX Plus User’s Manual Programmer’s Guide
5-6
int swtd_open(void)
Description
Open a file handle to control the watchdog. This is the first step to using the watchdog in
your application.
Input
None
Output
The return value is the file handle. If there is an error, it will return a negative value. You
can use errno() to retrieve the error.
int swtd_enable(int fd, unsigned long time)
Description
This function enables the watchdog function in an application. You must acknowledge
after implementing this process.
Input
int fd — the file handle, from the swtd_open() return value.
unsigned long time — The time you wish to acknowledge the watchdog periodically.
NOTE: You must acknowledge the watchdog before timeout. If you do not acknowledge,
the system will be reboot automatically. The minimum time interval is 50 milliseconds,
and the maximum time interval is 60 seconds. The time unit is in millisecond.
Output
0 if OK. An error occurs if you see a non-zero value. Use the function errno() to retrieve
the error code.
int swtd_disable(int fd)
Description:
Disable the watchdog in the application. The kernel will automatically acknowledge the
watchdog.
Input:
int fd — the file handle from the return value of swtd_open().
Output:
0 if OK. An error occurs if you see a non-zero value. Use the function errno () to retrieve
the error code.
int swtd_get(int fd, int *mode, unsigned long *time)
Description:
Get current settings.
mode —
1 to set user mode
0 to set kernel mode
time — The time period to acknowledge the watchdog.
Input:
int fd — the file handle from swtd_open().
int *mode — the function will return the status of the watchdog function
unsigned long *time — the function will return the current time period.
Output: