📄 main.c
字号:
/****************************************************************************
【文 件 名 称】main.c
【功 能 描 述】三星S3C44B0X板demo程序代码
【程 序 版 本】4.0
【创建人及创建日期】龚俊//2002年11月19日19:26
【修改人及修改日期】龚俊//2004-12-8 17:25
****************************************************************************/
//***************************************************************************
#include "def.h"
#include "44b.h"
#include "44blib.h"
/****************************************************************************
【功能说明】外部电平中断EINT4567响应
****************************************************************************/
volatile char which_int_key = 0 ;
void __irq Key_Interrupt(void)
{
which_int_key = rEXTINTPND ;
rEXTINTPND = 0xf ; //clear EXTINTPND reg.
rI_ISPC = BIT_EINT4567 ; //clear pending_bit
rPCONG = rPCONG & (~(0x3f<<10)); //GPC567 is input
switch(which_int_key)
{
case 2:
Uart_Printf("\nEINT5 had been occured...\n");
Led_Display(0x2);
which_int_key=0;
break;
case 4:
Uart_Printf("\nEINT6 had been occured...\n");
Led_Display(0x4);
which_int_key=0;
break;
case 8:
Uart_Printf("\nEINT7 had been occured...\n");
Led_Display(0x8);
which_int_key=0;
break;
default :
break;
}
while( (rPDATG&0x00e0) != 0x00e0 ) ;
Delay( 50 ) ; //
rPCONG = rPCONG | ( 0x3f<<10 ); //EINT7~5
}
/****************************************************************************
【功能说明】系统主函数
****************************************************************************/
void Main(void)
{
rNCACHBE0 = ((Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12);
//在上面的数据区域不使用高速缓存
rSYSCFG = CACHECFG; //8K字节cache,写缓冲使能,data abort使能
Port_Init(); //IO口初始化
Uart_Select( 0 ) ; //选择串口0
Uart_Init( 0, 115200 ) ;
//串口初始化,波特率为115200(系统主频为32MHz)
Uart_Printf( "\nInterrupt Test!\n" );
rINTMSK = 0x7ffffff; // All interrupt is masked.
pISR_EINT4567 = (unsigned)Key_Interrupt ;
rINTCON = 0x1 ; //向量中断模式
rINTMOD = 0x0 ; //All=IRQ mode
rPCONG = rPCONG | ( 0x3f<<10 ); //EINT7~5
rPUPG = rPUPG & (~(7<<5)) ; //pull up resister is enable
rEXTINT = rEXTINT & (~(0xfff<<20)) ; //EINT567低电平触发中断
//rEXTINT = rEXTINT & (~(0x222<<20)) ; //EINT567下降沿中断
pISR_EINT4567 = (unsigned)Key_Interrupt ;
rINTMSK = ~( BIT_GLOBAL | BIT_EINT4567 ) ; //start INT
Uart_Printf( "\nPlease press the button key2,key3,key4!\n" );
while( 1 )
{
Led_Display(0x05); //LED点亮/熄灭状态设置
Delay(5000);
Led_Display(0x0a); //LED点亮/熄灭状态设置
Delay(5000);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -