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

📄 main.c

📁 arm9 s3c2440与zlg7290的接口程序。在 ADS1.2下通过编译并能运行。
💻 C
字号:
#include <stdlib.h>
#include <string.h>
#include "option.h"
#include "2440addr.h"
#include "2440lib.h"
#include "userlib.h"
#include "def.h"
#include "2440ZLG7290.h"

//extern void Calc_Clock(int print_msg);



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

void Clk0_Enable(int clock_sel);	
void Clk1_Enable(int clock_sel);
void Clk0_Disable(void);
void Clk1_Disable(void);

// Clock select argument.
#define	UCLK_SEL	(1)
#define	HCLK_SEL	(3)
#define	PCLK_SEL	(4)
#define	DCLK_SEL	(5)
// Hidden
#define	MPLL_SEL	(0)
#define	FCLK_SEL	(2)


void Main()
{
	Port_Init();
	Calc_Clock(0);
	Isr_Init();
	ZLG7290_IIC_Init();
	Uart_Init(0, 115200);
	Uart_Select(0);
	Uart_TxEmpty(0);
	Uart_Printf("TEST ZLG7290:\n");
	keypress=0;
	while(1)
	 {	
	 	//TestIIC();
	    if(keypress)
	   	 	{
				GetKey_ZLG7290();
				keypress=0;
			 }
	 }
}

void Isr_Init(void)
{
   	  pISR_UNDEF  = (unsigned)HaltUndef;
  	  pISR_SWI    = (unsigned)HaltSwi;
  	  pISR_PABORT = (unsigned)HaltPabort;
	  pISR_DABORT = (unsigned)HaltDabort;
   	  pISR_EINT8_23 = (unsigned)KeyScan;

	rGPGCON = rGPGCON & (~(3<<2)) | ((2<<2)) ; 
	rEXTINT1 &= ~(7<<4); 
 	rEXTINT1 |= (2<<4); //set eint9 falling edge int 
	rEINTPEND |= (1<<9); //clear eint 9                                                
	rEINTMASK &= ~(1<<9); //enable eint9
	
   	 rINTMOD     = 0x0;					   //All=IRQ mode
	//rINTCON=0x5;					   //Non-vectored,IRQ enable,FIQ disable    
  	rINTMSK     = BIT_ALLMSK;			   //All interrupt is masked.
	rINTSUBMSK  = BIT_SUB_ALLMSK;		   //All sub-interrupt is masked. <- April 01, 2002 SOP
	ClearPending(BIT_EINT8_23);
  	rINTMSK &=~(BIT_EINT8_23);                   //EINT8-23 is not masked.


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

//===================================================================
void HaltSwi(void)
{
#if !SEMIHOSTING	
		Uart_Printf("SWI exception!!!\n");
		while(1);
#endif	
}

//===================================================================
void HaltPabort(void)
{
    Uart_Printf("Pabort exception.\n");
    while(1);
}

//===================================================================
void HaltDabort(void)
{
    Uart_Printf("Dabort exception.\n");
    while(1);
}
void Clk0_Enable(int clock_sel)	
{	// 0:MPLLin, 1:UPLL, 2:FCLK, 3:HCLK, 4:PCLK, 5:DCLK0
	rMISCCR = rMISCCR&~(7<<4) | (clock_sel<<4);
	rGPHCON = rGPHCON&~(3<<18) | (2<<18);
}
void Clk1_Enable(int clock_sel)
{	// 0:MPLLout, 1:UPLL, 2:RTC, 3:HCLK, 4:PCLK, 5:DCLK1	
	rMISCCR = rMISCCR&~(7<<8) | (clock_sel<<8);
	rGPHCON = rGPHCON&~(3<<20) | (2<<20);
}
void Clk0_Disable(void)
{
	rGPHCON = rGPHCON&~(3<<18);	// GPH9 Input
}
void Clk1_Disable(void)
{
	rGPHCON = rGPHCON&~(3<<20);	// GPH10 Input
}

⌨️ 快捷键说明

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