📄 flcd.c
字号:
}
unsigned char VerticalInt=0;
void LCD_Handler()
{
*(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000000; //disable all LCD interrupt
* (unsigned char *) (LCD_IO_Base + 0x20) = 0x08;
if( ( * (unsigned char *) (LCD_IO_Base + 0x24) ) & 0x08 )
* (unsigned char *) (LCD_IO_Base + 0x20) = 0x08;
VerticalInt = 1;
MaskFIQ(2);
DisableFIQ();
}
unsigned char BaseUpdateInt=0;
void FrameBaseUpdate()
{
*(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000000;
* (unsigned char *) (LCD_IO_Base + 0x20) = 0x04;
if( ( * (unsigned char *) (LCD_IO_Base + 0x24) ) & 0x04 )
* (unsigned char *) (LCD_IO_Base + 0x20) = 0x04;
BaseUpdateInt = 1;
MaskFIQ(2);
DisableFIQ();
}
int animation_frame;
void animation()
{
* (unsigned char *) (LCD_IO_Base + 0x20) = 0x04;
animation_frame++;
MaskFIQ(2);
DisableFIQ();
}
void Vertical_Int_Test( int int_num)
{
int i;
// fLib_ConnectInt(34, LCD_Handler); //it only can be
fLib_ConnectInt(32 + int_num, LCD_Handler);
EnableFIQ(); //It enables ARM's IRQ in the Boot.s
VerticalInt = 0;
*(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000008;
// UnmaskFIQ(2);
UnmaskFIQ(int_num);
SetFIQmode(int_num,LEVEL);
*(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) &= 0xffffcfff;
*(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) |= 0x00000000; //generate interrupt @ start of vertical back porch
if( VerticalInt == 1 ) printf("Interrupt testing: start of vertical sync OK\n");
else printf("Interrupt testing: start of vertical sync fail!!!\n");
if( * (unsigned char *) (LCD_IO_Base + 0x24) ) printf("Interrupt status bit clear fail\n");
else printf("Interrupt status bit clear OK\n");
VerticalInt = 0;
*(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000008;
// UnmaskFIQ(2);
UnmaskFIQ(int_num);
SetFIQmode(int_num,LEVEL);
*(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) &= 0xffffcfff;
*(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) |= 0x00001000; //generate interrupt @ start of vertical back porch
EnableFIQ();
if( VerticalInt == 1 ) printf("Interrupt testing: start of vertical porch OK\n");
else printf("Interrupt testing: start of vertical porch fail!!!\n");
if( * (unsigned char *) (LCD_IO_Base + 0x24) ) printf("Interrupt status bit clear fail\n");
else printf("Interrupt status bit clear OK\n");
VerticalInt = 0;
*(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000008;
//UnmaskFIQ(2);
UnmaskFIQ(int_num);
SetFIQmode(int_num,LEVEL);
*(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) &= 0xffffcfff;
*(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) |= 0x00002000; //generate interrupt @ start of active image
EnableFIQ();
if( VerticalInt == 1 ) printf("Interrupt testing: start of vertical active image OK\n");
else printf("Interrupt testing: start of vertical active image fail!!!\n");
if( * (unsigned char *) (LCD_IO_Base + 0x24) ) printf("Interrupt status bit clear fail\n");
else printf("Interrupt status bit clear OK\n");
VerticalInt = 0;
*(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000008;
//UnmaskFIQ(2);
UnmaskFIQ(int_num);
SetFIQmode(int_num,LEVEL);
*(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) &= 0xffffcfff;
*(volatile unsigned int *) ( LCD_IO_Base + 0x1c ) |= 0x00003000; //generate interrupt @ start of active image
EnableFIQ();
if( VerticalInt == 1 ) printf("Interrupt testing: start of vertical front porch OK\n");
else printf("Interrupt testing: start of vertical front porch fail!!!\n");
if( * (unsigned char *) (LCD_IO_Base + 0x24) ) printf("Interrupt status bit clear fail\n");
else printf("Interrupt status bit clear OK\n");
fLib_CloseInt(34);
*(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000000;
}
/*
void Base_Update_Int_Test()
{
fLib_ConnectInt(34, FrameBaseUpdate ); //it only can be
EnableFIQ(); //It enables ARM's IRQ in the Boot.s
*(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000004; //IntNxtBaseEn
UnmaskFIQ(2);
SetFIQmode(2,LEVEL);
}
*/
void Set_DivNo( unsigned char num ) // divisor is equal to (num + 1)
{
if( num >= 64 ) printf("wrong divisor \n");
* (unsigned int *) (LCD_IO_Base + 0x8) &= 0xffffffc0;
* (unsigned int *) (LCD_IO_Base + 0x8) |= num;
}
int FIFO_Under_Run=0;
void UnderRun_Handler()
{
DisableFIQ();
MaskFIQ(2);
// * (unsigned char *) (LCD_IO_Base + 0x20) = 0x04;
if( ( * (unsigned char *) (LCD_IO_Base + 0x24) ) & 0x02 )
{
* (unsigned char *) (LCD_IO_Base + 0x20) = 0x02;
* (unsigned char *) (LCD_IO_Base + 0x18) = 0x02; //Mask UnderRun Interrupt
FIFO_Under_Run=1;
}
// MaskFIQ(2);
// DisableFIQ();
}
void FIFO_UnderRun_test( int int_num)
{
unsigned char *pFrameBuffer;
int current_frame;
unsigned char result;
int i,j;
Init_LCD( LCD_IO_Base, FLcdModule, LCD_PANEL_TYPE, 16); // 16 bpp
Set_DivNo(31);
pFrameBuffer = malloc( ( (640* 480 * 2 )+ 0x3f ) );
if(pFrameBuffer == NULL ) printf("memory allocate fail\n");
pFrameBuffer += 0x3F;
pFrameBuffer = (unsigned char *) ((unsigned int ) pFrameBuffer & 0xffffffc0);
SetFrameBase( pFrameBuffer );
for(i=0; i<480; i++)
{
for(j=0; j< 210 * 2 ; j=j+2)
* (unsigned int *) (pFrameBuffer + i * 640 *2 + j) = 0x001f001f;
for(j=210 *2 ; j< 420 * 2; j=j+2)
* (unsigned int *) (pFrameBuffer + i * 640 *2 + j) = 0x07E007E0;
for(j= 420 *2; j<640 * 2; j=j+2)
* (unsigned int *) (pFrameBuffer + i * 640 *2 + j) = 0xF100F100;
}
// if( ( fread(pFrameBuffer, 640 *480 * 2 , 1 , fptr)) == NULL)
// printf("File open error!!\n");
fLib_ConnectInt(32 + int_num, UnderRun_Handler ); //it only can be
*(volatile unsigned int *) ( LCD_IO_Base + 0x20 )= 0x00000002;
*(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000002;
UnmaskFIQ(int_num);
SetFIQmode(int_num,LEVEL);
EnableFIQ();
printf("Change divisor, press 'y' or 'Y'");
do{
result = getchar();
}while( (result != 'y') );
Set_DivNo(2);
printf("Check if your screen flash, press 'y' or 'Y'\n");
do{
result = getchar();
}while( (result != 'y') );
if(FIFO_Under_Run) printf("FIFO under run generate interrupt\n");
else printf("FIFO under run interrupt fail\n");
printf("Use adaptive, press 'y' or 'Y'");
do{
result = getchar();
}while( (result != 'y') );
*(volatile unsigned int *) ( LCD_IO_Base + 0x08 ) |= 0x00008000;
printf("If screen is ok, press 'y' or 'Y'");
do{
result = getchar();
}while( (result != 'y') );
while(1);
free( pFrameBuffer);
}
/*
void RAM_DAC_test()
{
unsigned int pal[128], read, i, j;
for(i=0; i<128; i++) //backup palette
{
while (( *(volatile unsigned int *) 0x96500030 & 0x00000010 ) != 0 );
read = *(volatile unsigned int *) (0x96500000 + 0x200 + i*4); // dummy read
while (( *(volatile unsigned int *) 0x96500030 & 0x00000010 ) != 0 );
pal[i]= *(volatile unsigned int *) (0x96500000 + 0x200 + i*4);
}
for( i=0; i<3; i++)
*(volatile unsigned int *) (0x96500000 + 0x200 + i*4) = pal[i] + 1;
do
{
while (( *(volatile unsigned int *) 0x96500030 & 0x00000010 ) != 0 );
read = *(volatile unsigned int *) (0x96500000 + 0x200 + i*4); // dummy read
}
while( *(volatile unsigned int *) (0x96500000 + 0x200 ) != pal[0] )
}
*/
void palette_write( unsigned int data)
{
unsigned int i;
for( i=LCD_IO_Base + 0x200; i< LCD_IO_Base + 0x3FC; i+=4 )
*(unsigned int *) i = data;
}
int palette_check( unsigned int data)
{
unsigned int i, read;
for( i=LCD_IO_Base + 0x200; i< LCD_IO_Base + 0x3FC; i+=4 )
{
read = *(volatile unsigned int *) i; // dummy read
while ( ( (*(volatile unsigned int *) (LCD_IO_Base + 0x30) ) & 0x00000010 ) != 0 );
read = *(volatile unsigned int *) i;
if( read != data )
{
printf("Palette RW Fail\n");
return 0;
}
}
return 1;
}
void palette_write_seq() //write palette sequentially by address
{
unsigned int i;
for( i=LCD_IO_Base + 0x200; i< LCD_IO_Base+ 0x3FC; i+=4 )
*(unsigned int *) i = i;
}
int palette_check_seq()
{
unsigned int i, read;
for( i=LCD_IO_Base + 0x200; i<LCD_IO_Base + 0x3FC; i+=4 )
{
while (( *(volatile unsigned int *) (LCD_IO_Base + 0x30) & 0x00000010 ) != 0 );
read = *(volatile unsigned int *) i; // dummy read
while (( *(volatile unsigned int *) (LCD_IO_Base + 0x30) & 0x00000010 ) != 0 );
read = *(volatile unsigned int *) i; //real read
if( read != i )
{
printf("Palette RW Fail\n");
return 0;
}
}
return 1;
}
void palette_ram_test( unsigned int base)
{
int success=1;
unsigned int pal[128], read, i;
for(i=0; i<128; i++)
{
while (( *(volatile unsigned int *) (base + 0x30) & 0x00000010 ) != 0 );
read = *(volatile unsigned int *) (base + 0x200 + i*4); // dummy read
while (( *(volatile unsigned int *) (base + 0x30) & 0x00000010 ) != 0 );
pal[i]= *(volatile unsigned int *) (base + 0x200 + i*4);
}
//palette_write(0xffffffff);
//if( palette_check(0xffffffff) == 0 ) success =0;
palette_write(0x55555555);
if( palette_check(0x55555555) == 0 ) success =0;
palette_write(0xaaaaaaaa);
if( palette_check(0xaaaaaaaa) == 0 ) success =0;
palette_write(0x0);
if( palette_check(0x0) == 0 ) success =0;
palette_write_seq();
if( palette_check_seq() == 0) success = 0;
if( success ) printf("Palette RAM test PASS!!\n");
for(i=0; i<128; i++)
*(volatile unsigned int *) (base + 0x200 + i*4) = pal[i];
}
extern panel_type;
void animation_test( char *pFrameBuffer, char *file, int size , int int_num)
{
// unsigned char *pFrameBuffer;
int current_frame;
char *InputFile[10];
FILE *fptr;
Init_LCD( LCD_IO_Base, FLcdModule, panel_type , 16); // 16 bpp
//InputFile[0]="D:\\FTLCDc100\\Script\\animation565.bin";
fptr = fopen( file, "rb");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -