2 sample code, Sample code – ADLINK aTCA-6155 User Manual

Page 74

Advertising
background image

60

Watchdog Timer

7.2

Sample Code

This sample code is provided for testing the Watchdog Timer func-
tion of the W83627UHG on the aTCA-6155.

#include<stdlib.h>

#include<stdio.h>

#include<string.h>

#include<dos.h>

void WDTRUN(int config_port,int count_value);

void Enter_W627UHG_Config(int config_port);

void Exit_W627UHG_Config(int config_port);

void main(int argc,char *argv[])

{

int number,DevID1,DevID2,chipflag=0;

int ioport = 0x4E;//Default config_port = 0x4E

if((argc==1) || ((argc == 3)&& (*argv[2] != 'i')) ||

(argc>3))

{

printf("ADLINK Watchdog Timer Utility of aTCA-

6155.\n\n");

printf(" Usage: WDT6155 value [i]\n");

printf(" value is from 1 to 15300, the unit is

second.\n");

printf(" Write 0 will disable watchdog

timer.\n\n");

printf(" i - change IO port to 0x2E. Default

is 0x4E.\n");

exit(1);

}

else

{

if(argc==3) ioport=0x2E;

//Detect W83627UHG.

Enter_W627UHG_Config(ioport);

//Get Chip ID Hi Byte = 0xA2, Chip ID LO Byte = 0x3x

outportb(ioport, 0x20);

DevID1 = inportb(ioport+1);

outportb(ioport, 0x21);

DevID2 = inportb(ioport+1);

if((DevID1 == 0xA2) && ((DevID2 & 0xF0) == 0x30))

chipflag = 1;

Advertising