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

📄 led.c

📁 ARM S3C44B0X 的一段参考代码
💻 C
字号:
#include <string.h>
#include "def.h"
#include "44b.h"
#include "44blib.h"
#include "led.h"

void Isr_Init(void);
//void HaltUndef(void);
//void HaltSwi(void);
//void HaltPabort(void);      
//void HaltDabort(void);
void Eint4567Isr(void);

int Main(void)
{
	U8 which_key;

	rSYSCFG=SYSCFG_8KB;
#if (PLLON==1)
	ChangePllValue(PLL_M,PLL_P,PLL_S);
#endif
	Port_Init();
	Uart_Init(0,115200);
	Uart_Select(0);
	Uart_Printf("\n starting\n");
	//Isr_Init();

	//rPCONG=0x00ff;	//EINT7~0
	//rPUPG=0x0;		//pull up enable    
	
	Delay(0);  //calibrate Delay()
	Led_Display(7);
	Delay(2500);  //calibrate Delay()
	Led_Display(0);
	Delay(5000);  //calibrate Delay()
	Led_Display(7);
	Uart_Printf("\n start, press any key to return \n");
	while(!Uart_GetKey())
		{
		Delay(2000);  //calibrate Delay()
		Led_Display(5);
		Delay(2000);  //calibrate Delay()
		Led_Display(2);
		}
	while(1)
		{
		while((rPDATG & 0xf0)==0xf0);
		which_key=rPDATG&0xf0;
		switch(which_key)
			{
			case 0xe0:
				Led_Display(0x1);
				break;
			case 0xd0:
				Led_Display(0x2);
				break;
			case 0xb0:
				Led_Display(0x4);
				break;
			case 0x70:
				Led_Display(0x7);
				break;
			default :
				    break;
			}
		}
	return 0;
}

void Isr_Init(void)
{
//    U32 i;

	pISR_EINT4567=(unsigned)Eint4567Isr;
/*    
    pISR_UNDEF=(unsigned)HaltUndef;
    pISR_SWI  =(unsigned)HaltSwi;
    pISR_PABORT=(unsigned)HaltPabort;
    pISR_DABORT=(unsigned)HaltDabort;
     for(i=_RAM_STARTADDRESS;i<(_RAM_STARTADDRESS+0x20);i+=4)
    {
	*((volatile unsigned *)i)=0xEA000000+0x1FFE;
    }
*/
//    rINTCON=0x5;	  // Non-vectored,IRQ enable,FIQ disable    

//    rINTMOD=0x0;	  // All=IRQ mode
//    rINTMSK|=BIT_GLOBAL|BIT_EINT3|BIT_EINT4567;	  // All interrupt is masked.
}

//rINTMSK=BIT_GLOBAL;   
//  rINTCON=0x5;   

void Eint4567Isr(void)
  {   
//  which_int=EXTINTPND;   
//  EXTINTPND=0x0f;   //clean   EXTINTPND   
//  I_ISPC=BIT_EINT4567;   //clean   pending_bit   
//  Delay(1000);   //delay   
    
	Uart_Printf("Key interrupt ON!!\n");   
  }   
    


void HaltUndef(void)
{
    Uart_Printf("Undefined instruction exception!!!\n");
    while(1);
}

void HaltSwi(void)
{
    Uart_Printf("SWI exception!!!\n");
    while(1);
}

void HaltPabort(void)
{
    Uart_Printf("Pabort exception!!!\n");
    while(1);
}

void HaltDabort(void)
{
    Uart_Printf("Dabort exception!!!\n");
    while(1);
}

⌨️ 快捷键说明

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