미니2440 키 기반 전자 앨범 제어(누드 코드)

#define  GLOBAL_CLK 1
#include "def.h"
#include "option.h"
#include "2440addr.h"
#include "profile.h"

#define LCD_WIDTH 320	//    
#define LCD_HEIGHT 240	//    
#define CLKVAL 4		//    

//         、     
#define VSPW (2-1)
#define VBPD (11-1)
#define VFPD (5-1)

//         、     
#define HSPW (2-1)
#define HBPD (69-1)
#define HFPD (5-1)

//    
#define HOZVAL (LCD_WIDTH-1)
#define LINEVAL (LCD_HEIGHT-1)

#define LED1_on  rGPBDAT = ((0xf<<5)^(1<<5))  	//GPB5=0
#define LED4_on  rGPBDAT = ((0xf<<5)^(1<<8)) 	//GPB8=0
#define LED_off  rGPBDAT = (0xf<<5) //GPB5=1,GPB6=1,GPB7=1,GPB8=1

//      ,volatile           ,        
volatile static U16 LCD_BUFFER[LCD_HEIGHT][LCD_WIDTH];	
//       ,       ,           
static void LCD_IO_init(void);		
static void LCD_init(void);
static void LCD_POWER(void);

void CLK_init(void);
void LCD_on(void);
void LCD_off(void);
void LCD_clear(U16 n);
void BMP_display(int x0,int y0,int x1,int y1,const U8 *bmp);

extern unsigned char gImage_1[];	//extern        
extern unsigned char gImage_2[];
extern unsigned char gImage_3[];
extern unsigned char gImage_4[];
extern unsigned char gImage_5[];
extern unsigned char gImage_6[];
extern unsigned char gImage_7[];
extern unsigned char gImage_8[];

/********************************** 
*   
**********************************/
void Main(void)
{
    U16 n;
	//         
    U16 num[8][2]={320,240,320,240,320,240,320,240
	,320,240,320,240,320,240,320,240};
    U8 *photo[8]={
    gImage_1,gImage_2,
    gImage_3,gImage_4,
    gImage_5,gImage_6,
    gImage_7,gImage_8,
	};
	
    rGPBCON=(01<<00);//     
    rGPBDAT=0x00;
	
    rGPGCON=((0<<1)|(0<<11));	//GPG0,GPG5   ,   KEY1 KEY3  
	rGPBCON = ((1<<16)|(1<<14)|(1<<12)|(1<<10));	//GPB5~8     
	LED_off;
	
    CLK_init();
	LCD_POWER();
    LCD_IO_init();
    LCD_init();
    LCD_on();
	
    LCD_clear((0x1f<<11)|(0x3f<<5)|(0x1f) )  ;        	//      
    BMP_display(0, 0, num[0][0], num[0][1], photo[0]);	//       
	
	n=0;
    while(1)
    { 
	/*           ,  goto      ,
	                    */
	m:
	if(!(rGPGDAT&(1<<0))) 	// KEY1  
		{
			LED1_on;
			n++;
            BMP_display(0, 0, num[n][0], num[n][1], photo[n]);
			if(n>7) n=0;	//       n  
			if(!(rGPGDAT&(1<<0))) //         goto      
			{
			loop1: 
			if(rGPGDAT&(1<<0)) goto m;	//         
			else						//goto         
			goto loop1;
			}
        }
	else 
	
	k:
	if(!(rGPGDAT&(1<<5)))	// KEY3  
		{
		LED4_on;
		if(n==0) n=7;	//       n  
		n--;
		BMP_display(0, 0, num[n][0], num[n][1], photo[n]);
		if(!(rGPGDAT&(1<<5)))
			{
			loop2: 
			if(rGPGDAT&(1<<5)) goto k;
			else
			goto loop2;
			}
		}
	
    }
	
}

/********************************** 
*     
**********************************/
void CLK_init(void)
{
    rMPLLCON &= ~0xFFFFF;
    rMPLLCON |= (127<<12)|(2<<4)|1;	//   FCLK 405M
    rCLKDIVN = (2<<1)|1;	//HCLK = FCLK/4 =100M,PCLK = HCLK/2 = 50M
}

/********************************** 
*LCD     
**********************************/
static void LCD_IO_init(void)
{
    rGPCUP=0xff;	//GPC        
    rGPCCON=0xaaaa02aa;//GPC8-15   VD, VM,VFRAME,VLINE,VCLK,LEND

    rGPDUP=0xff;	//GPD        
    rGPDCON=0xaaaaaaaa;	//GPD0-15   VD
}

/********************************** 
*LCD    
**********************************/
static void LCD_POWER(void)
{
rGPGUP=(1<<4);
rGPGCON=(3<<8);		//GPG4   LCD_PWREN
rLCDCON5=(1<<3);	//Enable PWREN signal
}

/********************************** 
*LCD   
**********************************/
static void LCD_init(void)
{
    rLCDCON1=(CLKVAL<<8)|(3<<5)|(12<<1)|(0<<0); //VCLK=10M,TFT LCD,16bpp
    rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW);
    rLCDCON3=(HBPD<<19)|(HOZVAL<<8)|(HFPD);
    rLCDCON4=HSPW;
	/*5:6:5Format,Enable PWREN signal,Swap Enable*/
    rLCDCON5=(1<<11)|(1<<9)|(1<<8)|(1<<3)|1;
	
	/*      [30:22]   LCDSADDR1[29:21],     [21:1] 
	   LCDSADDR1[20:0],      [21:1]   LCDSADDR2[20:0]*/
    rLCDSADDR1=(((U32)LCD_BUFFER>>22)<<21)|(((U32)LCD_BUFFER&0x3fffff)>>1);
    rLCDSADDR2=(((U32)LCD_BUFFER+LCD_WIDTH*LCD_HEIGHT*2)>>1)&0x1fffff;	
    rLCDSADDR3=LCD_WIDTH; //            ,       
	
    rTPAL=0; //        
    rLCDINTMSK |=3;	//   LCD   
    rTCONSEL &=~(0x17);	//LCC3600,LPC3600   
}

/********************************** 
*LCD  
**********************************/
void LCD_on(void)
{
    rLCDCON1 |=1;	//  LCDCON1          LCD
}

/********************************** 
*LCD  
**********************************/
void LCD_off(void)
{
    rLCDCON1 &=~1;	//  LCDCON1          LCD
}

/********************************** 
*      
**********************************/
void LCD_clear(U16 n)
{
    U32 x,y;
    for(y=0;y

좋은 웹페이지 즐겨찾기