📄 flcd.c
字号:
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"); if( ( fread(pFrameBuffer, size , 1 , fptr)) == NULL) { printf("File open error!!\n"); } fLib_ConnectInt(32 + int_num, animation ); //it only can be EnableFIQ(); //It enables ARM's IRQ in the Boot.s *(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000004; //IntNxtBaseEn UnmaskFIQ(int_num); SetFIQmode(int_num,LEVEL); while(1) { if( current_frame != animation_frame ) { current_frame = animation_frame; UnmaskFIQ(int_num); SetFIQmode(int_num,LEVEL); if( panel_type == 1 ) SetFrameBase( pFrameBuffer + 320 * 240 *2 * (animation_frame % 10) ); else SetFrameBase( pFrameBuffer + 640 * 480 *2 * (animation_frame % 10) ); } } fclose(fptr); free( pFrameBuffer); fLib_CloseInt(32+int_num); SetFrameBase( pFrameBuffer) ;} void OSD_Test();void Load_Image( char *file, int size, char *pFrameBuffer, int endian){ FILE *fptr; int i; unsigned int temp, temp1, temp2; fptr = fopen( file, "rb"); // the file is in big-endian if( fread(pFrameBuffer, 1, size, fptr) == NULL ) printf("File open error \n"); if( endian == LBBP || endian == LBLP ) { for(i=0; i<size; i=i+4) { temp = * (unsigned int *) (pFrameBuffer + i); temp = ((temp << 16 ) & 0xFFFF0000 ) | ( (temp >> 16) & 0x0000ffff); * (unsigned int *) (pFrameBuffer + i) = temp; } } } int RegisterFile_Test( unsigned int base){ int success = 1; if( Register_Test( base, 0xFFFFFFFC) == 0 ) success =0; if( Register_Test( base + 0x4 , 0xFFFFFFFF) == 0 ) success =0; if( Register_Test( base + 0x8 , 0x0000FFFF) == 0 ) success =0; if( Register_Test( base + 0x10, 0xFFFFFFFC) ==0 ) success =0; if( Register_Test( base + 0x18, 0x0000001E) == 0 ) success =0; if( Register_Test( base + 0x1c, 0x0007BF2F) == 0 ) success =0; if( Register_Test( base + 0x34, 0x0000FFFF) ==0 ) success =0; if( Register_Test( base + 0x38, 0x000FFFFF) ==0) success =0; if( Register_Test( base + 0x3c, 0xFFFFFFFF) ==0 ) success =0; if( Register_Test( base + 0x40, 0xFFFFFFC0) ==0 ) success =0; if( success) printf("Register Testing OK\n"); }int Register_Test( int address, unsigned int compare ){ unsigned int write; write = 0x55555555 & compare; * (volatile unsigned int *) address = write; if( * ( volatile unsigned int *) address != write ) { printf("address = %x, write data = %x, read data = %x\n", address, write, * ( volatile unsigned int *) address); return 0; } write = 0xaaaaaaaa & compare; * (volatile unsigned int *) address = write; if( * ( volatile unsigned int *) address != write ) { printf("address = %x, write data = %x, read data = %x\n", address, write, * ( volatile unsigned int *) address); return 0; } write = 0xFFFFFFFF & compare; * (volatile unsigned int *) address = write; if( * ( volatile unsigned int *) address != write ) { printf("address = %x, write data = %x, read data = %x\n", address, write, * ( volatile unsigned int *) address); return 0; } write = 0x00000000 & compare; * (volatile unsigned int *) address = write; if( * ( volatile unsigned int *) address != write ) { printf("address = %x, write data = %x, read data = %x\n", address, write, * ( volatile unsigned int *) address); return 0; } return 1;}void GPIO_Test(){ unsigned char success=1; *(volatile unsigned int *) (LCD_IO_Base+ 0x44) = 0x0000FF00; if( *(volatile unsigned int *) (LCD_IO_Base+ 0x44) != 0x000000FF ) success =0; *(volatile unsigned int *) (LCD_IO_Base+ 0x44) = 0x0000AA00; if( *(volatile unsigned int *) (LCD_IO_Base+ 0x44) != 0x000000AA ) success =0; *(volatile unsigned int *) (LCD_IO_Base+ 0x44) = 0x00005500; if( *(volatile unsigned int *) (LCD_IO_Base+ 0x44) != 0x00000055 ) success =0; *(volatile unsigned int *) (LCD_IO_Base+ 0x44) = 0x00000000; if( *(volatile unsigned int *) (LCD_IO_Base+ 0x44) != 0x00000000 ) success =0; if( success ) printf("GPIO PASS\n"); else printf("GPIO Fail\n"); } int panel_type;int flcd_main(){ unsigned int i,j; unsigned int height, length;// unsigned short FrameBuffer[640*480]; unsigned char *pFrameBuffer, *CbPtr, *CrPtr; unsigned char next; char *InputFile[10]; FILE *fptr; char sCmd[20],sAddr[20],sData[20],sWidth[20]; unsigned long nData, nWidth; unsigned int block_size=0x1000; unsigned int bytes; char result; unsigned char r, g, b; unsigned int panel_width, panel_height; int int_num; // set_lcdc_default();// saving_mode_burnning(); // ColorBar_RGB( 1, LBLP, pFrameBuffer);// FIFO_UnderRun_test(); // animation_test(); // utilize frame base update interrupt to realize animation printf("\nWhat kind of Panel?\n"); printf("(1) A320(D) with 640 x 480 \n"); printf("(2) A320(D) with 320 x 240 \n"); printf("(3) A330 with 640 x 480 \n"); printf("(4) A330 with 320 x 240 \n"); printf("(5) CEP10x with 640 x 480 \n"); printf("(6) CPE10x with 320 x 240 \n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -