📄 wdog.c
字号:
//*********************************************************
//
// wdog.c : Test of watchgdog timer.
//
// PROVIDED BY:
// ------------
// Bittware, Inc.
// 33 North Main Street
// Concord, NH 03301
// Ph: 603-226-0404
// Fax: 603-226-6667
// WWW: www.bittware.com
// E-mail: support@bittware.com
//
// Copyright (c) 2001
//
// The user is hereby granted a non-exclusive license to use and or
// modify this software provided that it runs on BittWare hardware.
// Usage of this software on non-BittWare hardware without the express
// written permission of BittWare is strictly prohibited.
// Ver. Dates Author Changes
// ---- -------- ------ -----------------------------
// 1.0 11/29/01 rpc Creation
//*********************************************************
#include <defts101.h>
#include <sysreg.h>
#include <signal.h>
#include "utils.h"
#include "tfin.h"
#define CLKS_PER_MS (unsigned int) 240000
// Set timeout to test particular timeout region
// timeout=0 for for ~150 ms timeout
// timeout=1 for for ~600 ms timeout
// timeout=2 for for ~1200 ms timeout
// Globals
volatile unsigned int timeout = 2;
volatile int step;
volatile int interval;
volatile int intr_count = 0;
int count;
/**********************************************************/
/* */
/* */
/* */
/**********************************************************/
void timer0_handler(int sig)
{
toggle_flags(FLG0 | FLG1);
toggle_leds(FLG2);
intr_count++;
interval += step;
init_timer(0,0, interval*CLKS_PER_MS);
}
/**********************************************************/
/* */
/* */
/* */
/**********************************************************/
void main (void)
{
int my_pid;
int flag_ena;
int *wdog_reg;
// Init
init_Tiger();
my_pid = GetIDC();
wdog_reg = (int *)(MSH + TFIN_RST_CTL_REG);
flag_ena = (my_pid == 0) ? B_T0F1_ENA :
(my_pid == 1) ? B_T1F1_ENA :
(my_pid == 2) ? B_T2F1_ENA : B_T3F1_ENA;
switch (timeout)
{
case 0:
default:
interval = 50;
step = 1;
*wdog_reg = WDOG_SHORT_TO | flag_ena; /* 150 ms (typical) timeout */
break;
case 1:
interval = 200;
step = 5;
*wdog_reg = WDOG_MED_TO | flag_ena; /* 600 ms (typical) timeout */
break;
case 2:
interval = 400;
step = 20;
*wdog_reg = WDOG_LONG_TO | flag_ena; /* 1200 ms (typical) timeout */
break;
}
// Initialize flags
set_flags_as_output(FLG0O | FLG1O); // set FLG1 as output
prep_leds(); // set FLG2 as output
// Set up timer interrupts
interrupt(SIGTIMER0LP, timer0_handler); // attach handler for timer0 interrupt
init_timer(0, 0, interval*CLKS_PER_MS);
start_timer(0);
while(1)
{
count++;
}
}
/**********************************************************/
/* End of file wdog.c */
/**********************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -