📄 main.c
字号:
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
#include "myplmm.h"
#define XTOTAL 320
#define YTOTAL 240
#define EVERYX 32
#define HIGHB 32
;
#define SCR_XSIZE (320)
#define SCR_YSIZE (240)
#define LCD_XSIZE (320)
#define LCD_YSIZE (240)
#define M5D(n) ((n) & 0x1fffff)
///////////////////////////////////////////////////////////////
#define ARRAY_SIZE_MONO (SCR_XSIZE/8*SCR_YSIZE)
#define ARRAY_SIZE_G4 (SCR_XSIZE/4*SCR_YSIZE)
#define ARRAY_SIZE_G16 (SCR_XSIZE/2*SCR_YSIZE)
#define ARRAY_SIZE_COLOR (SCR_XSIZE/1*SCR_YSIZE)
#define HOZVAL (LCD_XSIZE/4-1)
#define HOZVAL_COLOR (LCD_XSIZE*3/8-1)
#define LINEVAL (LCD_YSIZE-1)
#define MVAL (9)
///////////////////////////////////////////////////////////////
#define CLKVAL_MONO (13) //60Mhz, CLKVAL=19 ->78.6Hz
#define CLKVAL_G4 (13) //60Mhz, CLKVAL=19 ->78.6Hz
#define CLKVAL_G16 (13) //60Mhz, CLKVAL=19 ->78.6Hz
#define CLKVAL_COLOR (6) //36Mhz, CLKVAL=19 ->78.6Hz
/*************************************************/
unsigned int (*frameBuffer1)[SCR_XSIZE/32];
unsigned int (*frameBuffer4)[SCR_XSIZE/16];
unsigned int (*frameBuffer16)[SCR_XSIZE/8];
unsigned int (*frameBuffer256)[SCR_XSIZE/4];
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void clr_pf(char onebit);
void setb_pf(char onebit);
void clr_pc(char onebit);
void setb_pc(char onebit);
void clr_pg(char onebit);
void setb_pg(char onebit);
void displaylcd(char num);
void displaylcd32(char x, char y, char num,char type);
void clear(void);
void Lcd_kb_MonoInit(void);
void __irq keyboard(void);
//////////////////////////////////////////////////////////////////////////
void __irq keyboard(void)
{
char x=0,y=0,yrecord;
rINTMSK=(BIT_GLOBAL|BIT_EINT3);
Delay(200);
Uart_Printf("come in, \n");
if((rPDATC&0x0f00)==0x0f00)
{
rPDATG=0X0F;
rINTMSK=~(BIT_GLOBAL|BIT_EINT3);
rI_ISPC = BIT_EINT3;
return;
}
else
{
for (x=4; x<8; x++) //for (x=4; x<8; x++)
{
rPCONG=(rPCONG&0x00ff)|0x5500;
rPDATG=0XFF;
clr_pg(x);
if ((rPDATC&0x0f00) !=0x0f00)
{
yrecord=(~((rPDATC&0x0f00)>>8))&0x0f; //使用GPC8-GPC11
for (y=0; yrecord!=0; y++)
{
yrecord=(yrecord>>1);
}
setb_pg(x);
Delay(100);
// Uart_Printf("x = %d, y=%d \n",x, y);
Uart_Printf("key is = %d \n",4*(y-1)+x-4);
switch(y+(7-x)*4-1) // y+(x-4)*4-1
{
case 0:
displaylcd32(255, 176, 4*(y-1)+x-4, 0);
displaylcd32(160, 120, 4*(y-1)+x-4, 1);
break;
default:
displaylcd32(255, 176, 4*(y-1)+x-4, 0);
displaylcd32(160, 120, 4*(y-1)+x-4, 1);
break;
}
rPDATG=0X0F;
rINTMSK=~(BIT_GLOBAL|BIT_EINT3);
rI_ISPC = BIT_EINT3;
return;
}
setb_pg(x);
}
rPDATG=0X0F;
rINTMSK=~(BIT_GLOBAL|BIT_EINT3);
rI_ISPC = BIT_EINT3;
return;
}
}
/*********************************************************/
void setb_pf(char onebit)
{
rPDATF=(rPDATF&0x1ff)|(0x1<<onebit);
}
/*********************************************************/
void clr_pf(char onebit)
{
unsigned int i,s=0;
for(i=0; i<onebit; i++)
{
s=(s|(0x1<<i));
}
rPDATF=(rPDATF&0x1ff)&((0x1fe<<onebit)|s);
}
/*********************************************************/
void setb_pg(char onebit)
{
rPCONG=(rPCONG&0x00ff)|0x5500;
rPDATG=(rPDATG&0xff)|(0x1<<onebit);
}
/*********************************************************/
void clr_pg(char onebit)
{
unsigned int i,s=0;
for(i=0; i<onebit; i++)
{
s=(s|(0x1<<i));
}
rPDATG=(rPDATG&0xff)&((0xfe<<onebit)|s);
}
/*********************************************************/
void clr_pc(char onebit)
{
unsigned int i,s=0;
for(i=0; i<onebit; i++)
{
s=(s|(0x1<<i));
}
rPDATC=(rPDATC&0xffff)&((0xfffe<<onebit)|s);
}
void setb_pc(char onebit)
{
rPDATC=(rPDATC&0xffff)|(0x1<<onebit);
}
/*********************************************************/
/////////////////////////////////////////////////////////////////////////
void Main(void)
{
U8 which_key;
int i=0,j=0;
rSYSCFG=SYSCFG_8KB;
#if (PLLON==1)
ChangePllValue(PLL_M,PLL_P,PLL_S);
#endif
Isr_Init();
Port_Init();
Uart_Init(0,115200);
Uart_Select(0);
Uart_Printf(" S3C44B0X 键盘测试(液晶显示效果) \n");
Uart_Printf("本测试程序 按照如下连接 : \n");
Uart_Printf(" 行1-------------PC8 : \n");
Uart_Printf(" 行2-------------PC9 : \n");
Uart_Printf(" 行3-------------PC10 : \n");
Uart_Printf(" 行4-------------PC11 : \n");
Uart_Printf(" 列1-------------PG4 : \n");
Uart_Printf(" 列2-------------PG5 : \n");
Uart_Printf(" 列3-------------PG6 : \n");
Uart_Printf(" 列4-------------PG7 : \n");
Uart_Printf("键盘中断-------------PG3 : \n");
Uart_Printf("连线完毕后按计算机任意键开始测试 \n");
Uart_Getch();
rEXTINT=0x22222222;
rINTCON=0x5;
pISR_EINT3=(unsigned)keyboard;
rPCONG=(rPCONG&0x00ff)|0x5500;
rPCONC=(rPCONC&0xff00ffff);
Uart_Printf("按下任意键液晶上有相应键值和图标显示! \n");
Uart_Printf("计算机键盘任意键退出!!!\n");
rINTMSK =~(BIT_GLOBAL|BIT_EINT3);
while(!Uart_GetKey())
{ ; }
//
rINTMSK|=BIT_EINT3;
Uart_Printf("测试结束 \n");
}
/////////////////////////////////////////////////////////////////////////////
void Lcd_kb_MonoInit(void)
{
#define MVAL_USED 0
if((U32)frameBuffer256==0)
{
frameBuffer256=(unsigned int (*)[SCR_XSIZE/4])malloc(ARRAY_SIZE_COLOR);
}
rLCDCON1=(0)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
// disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL_COLOR<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | M5D((U32)frameBuffer256>>1);
// 256-color, LCDBANK, LCDBASEU
rLCDSADDR2= M5D(((U32)frameBuffer256+(SCR_XSIZE*(LINEVAL+1)))>>1) | (MVAL<<21);
rLCDSADDR3= (LCD_XSIZE/2) | ( ((SCR_XSIZE-LCD_XSIZE)/2)<<9 );
//The following value has to be changed for better display.
rREDLUT =0xfdb97531;
rGREENLUT=0xfdb97531;
rBLUELUT =0xfb73;
rDITHMODE=0x0;
rDP1_2 =0xa5a5;
rDP4_7 =0xba5da65;
rDP3_5 =0xa5a5f;
rDP2_3 =0xd6b;
rDP5_7 =0xeb7b5ed;
rDP3_4 =0x7dbe;
rDP4_5 =0x7ebdf;
rDP6_7 =0x7fdfbfe;
rLCDCON1=(1)|(2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_COLOR<<12);
}
void displaylcd32(char x, char y, char num, char type)
{
unsigned int *pbuffer,temp_data;
unsigned int i=0, j=0, m=0;
//clrscreen();
pbuffer =(U32*) frameBuffer256;
for(m=0; m<HIGHB; m++)
{
i = (y+m)*XTOTAL*8/EVERYX+x*8/EVERYX;
//Uart_Printf("the i is : %x \n", i);
if (type == 0)
{
temp_data = (Bitmap32[num][m*32] << 24) + (Bitmap32[num][m*32+1] << 16) + (Bitmap32[num][m*32+2] << 8) +(Bitmap32[num][m*32+3]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32[num][m*32+4] << 24) + (Bitmap32[num][m*32+5] << 16) + (Bitmap32[num][m*32+6] << 8) +(Bitmap32[num][m*32+7]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32[num][m*32+8] << 24) + (Bitmap32[num][m*32+9] << 16) + (Bitmap32[num][m*32+10] << 8) +(Bitmap32[num][m*32+11]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32[num][m*32+12] << 24) + (Bitmap32[num][m*32+13] << 16) + (Bitmap32[num][m*32+14] << 8) +(Bitmap32[num][m*32+15]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32[num][m*32+16] << 24) + (Bitmap32[num][m*32+17] << 16) + (Bitmap32[num][m*32+18] << 8) +(Bitmap32[num][m*32+19]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32[num][m*32+20] << 24) + (Bitmap32[num][m*32+21] << 16) + (Bitmap32[num][m*32+22] << 8) +(Bitmap32[num][m*32+23]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32[num][m*32+24] << 24) + (Bitmap32[num][m*32+25] << 16) + (Bitmap32[num][m*32+26] << 8) +(Bitmap32[num][m*32+27]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32[num][m*32+28] << 24) + (Bitmap32[num][m*32+29] << 16) + (Bitmap32[num][m*32+30] << 8) +(Bitmap32[num][m*32+31]);
pbuffer[i]=temp_data;
}
else
{
temp_data = (Bitmap32_num[num][m*32] << 24) + (Bitmap32_num[num][m*32+1] << 16) + (Bitmap32_num[num][m*32+2] << 8) +(Bitmap32_num[num][m*32+3]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32_num[num][m*32+4] << 24) + (Bitmap32_num[num][m*32+5] << 16) + (Bitmap32_num[num][m*32+6] << 8) +(Bitmap32_num[num][m*32+7]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32_num[num][m*32+8] << 24) + (Bitmap32_num[num][m*32+9] << 16) + (Bitmap32_num[num][m*32+10] << 8) +(Bitmap32_num[num][m*32+11]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32_num[num][m*32+12] << 24) + (Bitmap32_num[num][m*32+13] << 16) + (Bitmap32_num[num][m*32+14] << 8) +(Bitmap32_num[num][m*32+15]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32_num[num][m*32+16] << 24) + (Bitmap32_num[num][m*32+17] << 16) + (Bitmap32_num[num][m*32+18] << 8) +(Bitmap32_num[num][m*32+19]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32_num[num][m*32+20] << 24) + (Bitmap32_num[num][m*32+21] << 16) + (Bitmap32_num[num][m*32+22] << 8) +(Bitmap32_num[num][m*32+23]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32_num[num][m*32+24] << 24) + (Bitmap32_num[num][m*32+25] << 16) + (Bitmap32_num[num][m*32+26] << 8) +(Bitmap32_num[num][m*32+27]);
pbuffer[i]=temp_data;
i++;
temp_data = (Bitmap32_num[num][m*32+28] << 24) + (Bitmap32_num[num][m*32+29] << 16) + (Bitmap32_num[num][m*32+30] << 8) +(Bitmap32_num[num][m*32+31]);
pbuffer[i]=temp_data;
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
void clear(void)
{
unsigned int *pbuffer;
int i;
pbuffer =(U32*) frameBuffer256;
for(i = 0; i< (9600*8/4) ;i++)
{
pbuffer[i] = 0;
}
}
/////////////////////////////////////////////////////////////////////////////
void Isr_Init(void)
{
U32 i;
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; // All interrupt is masked.
}
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 + -