#include "2440addr.h"
#include "mmu.h"
int i,j;
for(i=0;i<times;i++)
for(j=0;j<400;j++);
}
void Led3_Init(void)
{
rGPBCON &= ~(0x03<<14);
rGPBCON |= (0x01<<14);
}
void Led4_Init(void)
{
rGPBCON &= ~(0x03<<16);
rGPBCON |= (0x01<<16);
}
void Led3_run(void)
{
//rGPBDAT = rGPBDAT^(0x1<<5);
if(rGPBDAT &(1<<7))
rGPBDAT &=~(1<<7);
else
rGPBDAT |=(1<<7);
delay(100);
}
void Led4_run(void)
{
//rGPBDAT = rGPBDAT^(0x1<<5);
if(rGPBDAT &(1<<8))
rGPBDAT &=~(1<<8);
else
rGPBDAT |=(1<<8);
}
static void __irq key_handler(void)
{
if(rINTPND==BIT_EINT8_23)
{
ClearPending(BIT_EINT8_23);
if(rEINTPEND&(1<<13))
{
rEINTPEND |= 1<< 13;
rGPBDAT = rGPBDAT^(0x1<<7);
//delay(100);
}
}
}
static void __irq Timer3_irq(void)
{
ClearPending(BIT_TIMER3);
//rINTPND = 0x400;
//rSRCPND = 0X400;
Led4_run();
}
void Key_Init()
{
rGPGCON &= ~(3<<10);
rGPGCON |= (2<<10);
rEXTINT1 &= ~(0xf<<20);
rEXTINT1 |= (0xf<<20);
rEINTPEND |= (0x01<<13);
rEINTMASK &= ~(0x01<<13);
pISR_EINT8_23 = (U32)key_handler;
EnableIrq(BIT_EINT8_23);
}
void Timer_Init()
{
rTCFG0 = 0XF900;
rTCFG1 = 0x3000;
rTCNTB3 = 12500;
rTCMPB3 = 12500/2;
rTCON |= (0x01<<17);
rTCON = 0x090000;
ClearPending(BIT_TIMER3);
pISR_TIMER3 = (U32)Timer3_irq;
EnableIrq(BIT_TIMER3);
}
int Main()
{
MMU_Init();
Led4_Init();
Timer_Init();
Led3_Init();
Key_Init();
while(1);
}
#include "mmu.h"
void delay(int times)
{int i,j;
for(i=0;i<times;i++)
for(j=0;j<400;j++);
}
void Led3_Init(void)
{
rGPBCON &= ~(0x03<<14);
rGPBCON |= (0x01<<14);
}
void Led4_Init(void)
{
rGPBCON &= ~(0x03<<16);
rGPBCON |= (0x01<<16);
}
void Led3_run(void)
{
//rGPBDAT = rGPBDAT^(0x1<<5);
if(rGPBDAT &(1<<7))
rGPBDAT &=~(1<<7);
else
rGPBDAT |=(1<<7);
delay(100);
}
void Led4_run(void)
{
//rGPBDAT = rGPBDAT^(0x1<<5);
if(rGPBDAT &(1<<8))
rGPBDAT &=~(1<<8);
else
rGPBDAT |=(1<<8);
}
static void __irq key_handler(void)
{
if(rINTPND==BIT_EINT8_23)
{
ClearPending(BIT_EINT8_23);
if(rEINTPEND&(1<<13))
{
rEINTPEND |= 1<< 13;
rGPBDAT = rGPBDAT^(0x1<<7);
//delay(100);
}
}
}
static void __irq Timer3_irq(void)
{
ClearPending(BIT_TIMER3);
//rINTPND = 0x400;
//rSRCPND = 0X400;
Led4_run();
}
void Key_Init()
{
rGPGCON &= ~(3<<10);
rGPGCON |= (2<<10);
rEXTINT1 &= ~(0xf<<20);
rEXTINT1 |= (0xf<<20);
rEINTPEND |= (0x01<<13);
rEINTMASK &= ~(0x01<<13);
pISR_EINT8_23 = (U32)key_handler;
EnableIrq(BIT_EINT8_23);
}
void Timer_Init()
{
rTCFG0 = 0XF900;
rTCFG1 = 0x3000;
rTCNTB3 = 12500;
rTCMPB3 = 12500/2;
rTCON |= (0x01<<17);
rTCON = 0x090000;
ClearPending(BIT_TIMER3);
pISR_TIMER3 = (U32)Timer3_irq;
EnableIrq(BIT_TIMER3);
}
int Main()
{
MMU_Init();
Led4_Init();
Timer_Init();
Led3_Init();
Key_Init();
while(1);
}