#include "myprintf.h"
#define WTCON (*(volatile unsigned int *)0xE2700000)
#define WTDAT (*(volatile unsigned int *)0xE2700004)
#define WTCNT (*(volatile unsigned int *)0xE2700008)
#define WTCLRINT (*(volatile unsigned int *)0xE270000C)
#define VIC0VECTADDR27 (*(volatile unsigned int *)0xF200016C)
#define VICINTENCLEAR (*(volatile unsigned long *)0xF2000014)
#define VIC0INTENABLE (*(volatile unsigned long *)0xF2000010)
#define VIC0INTSELECT (*(volatile unsigned long *)0xF2000F00)
#define VIC0ADDR ( *(volatile unsigned long *)0xF2000F00)
int i=0;
extern void IRQ(void);
void watchdog_irq()
{
WTCLRINT=0x01;
VIC0ADDR = 0;
my_printf("\nwatchdog irq %d \n",i++);
}
void watchdog_init(char flag)
{
VIC0VECTADDR27=(int)IRQ;
VIC0INTSELECT&=~(1<<27);
VIC0INTENABLE|=(1<<27);
if(flag)//reset
{
WTCON=(1<<0)|(1<<2)|(1<<5)|(0x41<<8);
WTDAT=0x8000;
WTCNT=0x8000;
my_printf("\n RESET %d \n");
}
else//irq
{
WTCON=(0<<0)|(1<<2)|(1<<5)|(0x41<<8);
WTDAT=0x8000;
WTCNT=0x8000;
}
}
qt210watchdog
最新推荐文章于 2022-05-31 17:55:54 发布