I'm using a TS-7260. I monitor a DIO line for the user to shutdown the system, at which point I want to close all open ports and devices, and issue a "shutdown -h now" command via popen (I'm writing c code).
My question is, if the watchdog is initialized and fed by:
int fd = open("/dev/mem", O_RDWR|O_SYNC);
volatile unsigned char *wdt_control;
volatile unsigned char *wdt_feedl;
wdt_control = (unsigned char*)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x23800000);
wdt_feed = (unsigned char*)mmap(0,getpagesize(),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0x23C00000);
*wdt_feed=0x05;
*wdt_control=0x07;//set duration to max = 8 seconds
how can I call fclose(fd)? I don't want the watchdog to reset the board before the "shutdown -h now" is finished, nor do I want the program to be terminated by the shutdown command before I've safely released /dev/mem. Any suggestions?