44b0 lcd 16级灰度演示,大虾不要笑,cstudy奉献(24946字)cstudy2004-10-18 12:03:10[215次]
#include "Option.h"
#include "44b.h"
#include "44blib.h"
#include "def.h"
#include "plmm1.h"
#include "lcdlib.h"
#include "ph.h"
#include "pan.h"
#include "bd.h"
#include "che.h"
unsigned int (*frameBuffer16)[SCR_XSIZE/8];
#define XTOTAL 256
#define YTOTAL 320
#define EVERYX 32
#define HIGHB 32
void Lcd_MonoInit(void);
void clrscreen(void);
void displaylcd1(void);
void displaylcd2(void);
void displaylcd3(void);
void displaylcd4(void);
void displaylcd5(void);
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void Lcd_MonoInit(void)
{
//160x240 1bit/1pixel LCD
#define MVAL_USED 0
if((U32)frameBuffer16==0)
{
if (( frameBuffer16=(unsigned int (*)[SCR_XSIZE/8])malloc
(ARRAY_SIZE_G16))==NULL)
{
Uart_Printf("ERROR !!!!!!!! NO MEMERY !!!!!!! \n");
}
else
{
Uart_Printf("ARRAY_SIZE_g16= %d \n", ARRAY_SIZE_G16);
}
}
rLCDCON1=(0)|(1<1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|
(CLKVAL_G16<<12);
// disable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
rLCDSADDR1= (0x2<<27) | ( ((U32)frameBuffer16>>22)<<21 ) | M5D((U32)
frameBuffer16>>1);
// 16-lever gray mode , LCDBANK, LCDBASEU
rLCDSADDR2= M5D (((U32)frameBuffer16+(SCR_XSIZE*(LINEVAL+1))/2)>>1)
| (MVAL<<21) |(0<<29);//MVAL
// 4*SCR_XSIZE*LCD_YSIZE/8
rLCDSADDR3= (LCD_XSIZE/4) | ( ((SCR_XSIZE-LCD_XSIZE)/4)<<9 );
rLCDCON1=(1)|(1<<1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|
(CLKVAL_G16<<12);
// enable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
}
void clrscreen(void)
{
unsigned int *pbuffer;
int i;
pbuffer =(U32*) frameBuffer16;
for(i = 0; i< (38400/4) ;i++)
{
pbuffer[i] = 0;
}
}
void displaylcd1(void)
{
unsigned int *pbuffer,temp_data;
int i,j=0;
pbuffer =(U32*) frameBuffer16;
clrscreen();
for(i = 0; i< (38400/4) ;i++)
{
temp_data = (gImage_ph[i*4] << 24) + (gImage_ph[i*4+1] << 16) +
(gImage_ph[i*4+2] << 8) +(gImage_ph[i*4+3]);
pbuffer[i] = temp_data;
}
}
void displaylcd2(void)
{
unsigned int *pbuffer,temp_data;
int i,j=0;
pbuffer =(U32*) frameBuffer16;
clrscreen();
for(i = 0; i< (38400/4) ;i++)
{
temp_data = (gImage_pan[i*4] << 24) + (gImage_pan[i*4+1] << 16) +
(gImage_pan[i*4+2] << 8) +(gImage_pan[i*4+3]);
pbuffer[i] = temp_data;
}
}
void displaylcd3(void)
{
unsigned int *pbuffer,temp_data;
int i,j=0;
pbuffer =(U32*) frameBuffer16;
clrscreen();
for(i = 0; i< (38400/4) ;i++)
{
temp_data = (gImage_bd[i*4] << 24) + (gImage_bd[i*4+1] << 16) +
(gImage_bd[i*4+2] << 8) +(gImage_bd[i*4+3]);
pbuffer[i] = temp_data;
}
}
void displaylcd4(void)
{
unsigned int *pbuffer,temp_data;
int i,j=0;
pbuffer =(U32*) frameBuffer16;
clrscreen();
for(i = 0; i< (38400/4) ;i++)
{
temp_data = (gImage_che[i*4] << 24) + (gImage_che[i*4+1] << 16) +
(gImage_che[i*4+2] << 8) +(gImage_che[i*4+3]);
pbuffer[i] = temp_data;
}
}
void displaylcd5(void)
{
unsigned int *pbuffer,temp_data;
int i,j=0;
pbuffer =(U32*) frameBuffer16;
clrscreen();
for(i = 0; i< (38400/4) ;i++)
{
temp_data = (plmmBitmap1[i*4] << 24) + (plmmBitmap1[i*4+1] << 16) +
(plmmBitmap1[i*4+2] << 8) +(plmmBitmap1[i*4+3]);
pbuffer[i] = temp_data;
}
}
void Main(void)
{
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);
Delay(0); //calibrate Delay()
Led_Display(7);
Delay(1000); //calibrate Delay()
Led_Display(0);
Delay(5000); //calibrate Delay()
Led_Display(7);
Uart_Printf("\n start \n");
Uart_Printf("\n I am PengHao 2004 10 10 \n");
Uart_Printf("\n cstudy 2004 10 10 \n");
Uart_Printf("\n At BeiJing HaiDian DaYunChun \n");
Uart_Printf("\n 北京海淀大运村 \n");
Lcd_MonoInit();
clrscreen();
while(1)
{
Uart_Printf("\n汽车内部驾驶盘 \n");
displaylcd2();
Delay(5000); //calibrate Delay()
Led_Display(1);
Delay(5000); //calibrate Delay()
Led_Display(2);
Delay(5000); //calibrate Delay()
Led_Display(4);
Uart_Printf("\n智能小车 \n");
displaylcd1();
Delay(5000); //calibrate Delay()
Led_Display(1);
Delay(5000); //calibrate Delay()
Led_Display(2);
Delay(5000); //calibrate Delay()
Led_Display(4);
Uart_Printf("\nprotel dxp 4层板图层示例 \n");
displaylcd3();
Delay(5000); //calibrate Delay()
Led_Display(1);
Delay(5000); //calibrate Delay()
Led_Display(2);
Delay(5000); //calibrate Delay()
Led_Display(4);
Uart_Printf("\n豪华加长车 \n");
displaylcd4();
Delay(5000); //calibrate Delay()
Led_Display(1);
Delay(5000); //calibrate Delay()
Led_Display(2);
Delay(5000); //calibrate Delay()
Led_Display(4);
Uart_Printf("\n漂亮mm图片^+^ \n");
displaylcd5();
Delay(5000); //calibrate Delay()
Led_Display(1);
Delay(5000); //calibrate Delay()
Led_Display(2);
Delay(5000); //calibrate Delay()
Led_Display(4);
}
}
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);
}
Comment:
(no reply)