⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 三星2410的一些DEMO小例程
💻 C
字号:
/****************************************************************************
【文  件  名  称】main.c
【功  能  描  述】三星S3C2410A板demo程序代码
【程  序  版  本】4.0
【创建人及创建日期】龚俊//2002年11月19日19:26
【修改人及修改日期】李熠//2006-7 
****************************************************************************/
#include "def.h"
#include "2410addr.h"
#include "config.h"
#include "board.h"
#include "utils.h"



void __irq key1ISR(void);
void __irq key2ISR(void);
void __irq key3ISR(void);
void __irq key4ISR(void);
void keyinit(void);



/*************************************************************/
void Main(void)
{

	BoardInitStart();
	SystemClockInit();
	TimerInit(TIMER_FREQ);
	MemCfgInit();
	PortInit();
	
	
	
	
 
     keyinit();
 
	pISR_EINT1=(unsigned)key1ISR;
	pISR_EINT2=(unsigned)key2ISR;
	pISR_EINT3=(unsigned)key3ISR;
	pISR_EINT4_7=(unsigned)key4ISR;
	
	EnableIrq(BIT_EINT1);
	EnableIrq(BIT_EINT2);
	EnableIrq(BIT_EINT3);
	rEINTMASK&=0x0ff7f; //enable EXINT7
	EnableIrq(BIT_EINT4_7);
	EnableInt();
	

	SerialSwitch(0);
	SerialChgBaud(115200);
	
	printf("S3C2410 KeyInt Test!!!\n");
	
	while( 1 )
	{
	
	}
	DisableIrq(BIT_EINT1);
	DisableIrq(BIT_EINT2);
	DisableIrq(BIT_EINT3);
	rEINTMASK|=0x80; //disable EXINT7
	DisableIrq(BIT_EINT4_7);
	DisableInt();
}



void keyinit(void)
{
rGPFCON&=0x3f03;
rGPFCON|=0x80a8;
rGPFUP=0;
}





void __irq key1ISR(void)
{
	DisableIrq(BIT_EINT1);
	ClearPending(BIT_EINT1);
	printf("Press key 1!\n");
	
	Delay(50);
	EnableIrq(BIT_EINT1);
}

void __irq key2ISR(void)
{
	DisableIrq(BIT_EINT2);
	ClearPending(BIT_EINT2);
	printf("Press key 2!\n");
	
	Delay(50);	
	EnableIrq(BIT_EINT2);
}

void __irq key3ISR(void)
{
	DisableIrq(BIT_EINT3);
	ClearPending(BIT_EINT3);
	printf("Press key 3!\n");
	
	Delay(50);	
	EnableIrq(BIT_EINT3);
}

void __irq key4ISR(void)
{
	rEINTMASK|=0x80; //disable EXINT7
	DisableIrq(BIT_EINT4_7);
    rEINTPEND|=0x80;
	ClearPending(BIT_EINT4_7);
	printf("Press key 4!\n");

	Delay(50);	
	rEINTMASK&=0x0ff7f; //enable EXINT7
	EnableIrq(BIT_EINT4_7);	
}


/*
The S3C2410A has two interrupt pending resisters: source pending register (SRCPND) and interrupt pending register
(INTPND). These pending registers indicate whether or not an interrupt request is pending. When the interrupt
sources request interrupt service, the corresponding bits of SRCPND register are set to 1, and at the same time,
only one bit of the INTPND register is set to 1 automatically after arbitration procedure. If interrupts are masked, the
corresponding bits of the SRCPND register are set to 1. This does not cause the bit of INTPND register changed.
When a pending bit of the INTPND register is set, the interrupt service routine starts whenever the I-flag or F-flag is
cleared to 0. The SRCPND and INTPND registers can be read and written, so the service routine must clear the
pending condition by writing a 1 to the corresponding bit in the SRCPND register first and then clear the pending
condition in the INTPND registers by using the same method.
2410有两个中断悬挂寄存器,一个"源悬挂寄存器",一个"中断悬挂寄存器".这些悬挂寄存器标识了一个中断请求是否被悬挂.
当一个中断源请求一个中断服务,"源悬挂寄存器SRCPND"相应的位被置位,与此同时,"中断悬挂寄存器INTPND"在仲裁结束后1个bit被置位
如果中断被掩埋,"源悬挂寄存器SRCPND"相应的位被置位,但"中断悬挂寄存器INTPND"不会变化.
如果"中断悬挂寄存器INTPND"中的某一位被置位,则中断服务机制在 I-flag 或 F-flag 被清除的时候马上开始中断服务
SRCPND和INTPND可以读写,所以,服务程序需要在"源悬挂寄存器SRCPND"相应位置为1,然后清除"中断悬挂寄存器INTPND"相应位
*/

/*
Interrupt Mask Register
This register indicates that an interrupt has been disabled if the corresponding mask bit is set to 1. 
If an interruptmask bit of INTMSK is 0, the interrupt will be serviced normally.
 If the corresponding mask bit is 1 and the interrupt is generated, the source pending bit will be set.
中断屏蔽寄存器
这个寄存器中的某一位如果被置位,标志着相应的中断被屏蔽
如果相应位为0,则中断被正常的处理
如果中断被屏蔽,但中断被触发,则"源悬挂寄存器SRCPND"被置位

*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -