⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flcd.c

📁 FIC8120方案的 StartCell_Driver
💻 C
📖 第 1 页 / 共 5 页
字号:
   
  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");
  
  result = getchar();
  switch(result)
  {
    case '1': 
      panel_width= 640;
      panel_height = 480;
      panel_type = 0;  
      LCD_IO_Base = 0x90600000;
      int_num = 20;
      break;
    case '2': 
      panel_width= 320;
      panel_height = 240;
      panel_type = 1;  
      LCD_IO_Base = 0x90600000;
      int_num =20;
      break;
    case '3': 
      panel_width= 640;
      panel_height = 480;
      panel_type = 0;  
      LCD_IO_Base = 0x90600000;
      int_num = 20;
      break;  
    case '4': 
      panel_width= 320;
      panel_height = 240;
      panel_type = 1;  
      LCD_IO_Base = 0x90600000;
      int_num = 20;
      break;  
     case '5': 
      panel_width= 640;
      panel_height = 480;
      panel_type = 0;  
      LCD_IO_Base = 0x96500000;
      int_num = 2;
      break;  
     case '6': 
      panel_width= 320;
      panel_height = 240;
      panel_type = 1;  
      LCD_IO_Base = 0x96500000;
      int_num=0;
      break; 
   }        
         
      pFrameBuffer = malloc( (panel_width* panel_height * 2 * 10 ) + 0x3f);    // Maximum 16bpp 10 Frame for motion piture
      if(pFrameBuffer == NULL ) printf("memory allocate fail\n");
      
	  pFrameBuffer += 0x3F;
	  pFrameBuffer = (unsigned char *) ((unsigned int ) pFrameBuffer & 0xffffffc0) ;  
	  SetFrameBase( pFrameBuffer );
      Init_LCD( LCD_IO_Base, FLcdModule, panel_type, 16);

      saving_mode_burnning();     
              
   // *****************RGB 16/32 BPP  vs Endian vs OSD **************
     
      ColorBar_RGB( 1, LBLP, pFrameBuffer, panel_width, panel_height,0);
      OSD_Test(1, "RGB LBLP 1BPP");  //3/19 Τ拜肈
       
      palette_ram_test(LCD_IO_Base);
      
      Vertical_Int_Test(int_num);

     
      ColorBar_RGB( 1, BBBP, pFrameBuffer, panel_width, panel_height,0);
//      OSD_Test(1, "RGB BBP 1BPP"); 
      ColorBar_RGB( 1, LBBP, pFrameBuffer, panel_width, panel_height,0);
//      OSD_Test(1, "RGB LBBP 1BPP"); 
      
      ColorBar_RGB( 2, LBLP, pFrameBuffer, panel_width, panel_height,0);
//      OSD_Test(1, "RGB LBLP 2BPP"); 
      ColorBar_RGB( 2, BBBP, pFrameBuffer, panel_width, panel_height,0);
      OSD_Test(1, "RGB BBP 2BPP"); 
      ColorBar_RGB( 2, LBBP, pFrameBuffer, panel_width, panel_height,0);
//      OSD_Test(1, "RGB LBBP 2BPP"); 
      
      ColorBar_RGB( 4, LBLP, pFrameBuffer, panel_width, panel_height,0);
//      OSD_Test(1, "RGB LBLP 4BPP"); 
      ColorBar_RGB( 4, BBBP, pFrameBuffer, panel_width, panel_height,0);
//      OSD_Test(1, "RGB BBP 4BPP"); 
      ColorBar_RGB( 4, LBBP, pFrameBuffer, panel_width, panel_height,0);
      OSD_Test(1, "RGB LBBP 4BPP"); 
      
      ColorBar_RGB( 8, LBLP, pFrameBuffer, panel_width, panel_height,0);
//      OSD_Test(1, "RGB LBLP 8BPP"); 
      ColorBar_RGB( 8, BBBP, pFrameBuffer, panel_width, panel_height,0);
//      OSD_Test(1, "RGB BBP 8BPP"); 
      ColorBar_RGB( 8, LBBP, pFrameBuffer, panel_width, panel_height,0);
      OSD_Test(1, "RGB LBBP 8BPP"); 

      


      
      
	  
	  Init_LCD( LCD_IO_Base, FLcdModule, panel_type, 16);
	  
      ColorBar_YCbCr_420( BBBP, pFrameBuffer, panel_width, panel_height, 0);
      OSD_Test(2, "YCBCR 420 BBBP");
      ColorBar_YCbCr_420( LBBP, pFrameBuffer, panel_width, panel_height, 0);
//      OSD_Test(2, "YCBCR 420 LBBP");
      ColorBar_YCbCr_420( LBLP, pFrameBuffer, panel_width, panel_height, 0);
//      OSD_Test(2, "YCBCR 420 LBLP");      

	
	  
	  SetYCbCr(422);  
	  ColorBar_YCbCr_422( BBBP, pFrameBuffer, panel_width, panel_height, 0);
	  OSD_Test(2, "YCBCR 422 BBBP");      
      ColorBar_YCbCr_422( LBBP, pFrameBuffer, panel_width, panel_height, 0);     
//	  OSD_Test(2, "YCBCR 422 LBBP");      
	  ColorBar_YCbCr_422( LBLP, pFrameBuffer, panel_width, panel_height, 0);     
//	  OSD_Test(2, "YCBCR 422 LBLP");      
   	  
	
   
   
   if( panel_type == 1 )       
     {      
      Init_LCD( LCD_IO_Base, FLcdModule, panel_type, 16);
      SetEndian(LBBP);
      OSD_Off(LCD_IO_Base);
      Load_Image( "D:\\FTLCDc100\\Script\\ship565_320x240.bin", 153600, pFrameBuffer, LBBP);
      OSD_Test(1, "RGB LBBP 16 BPP");
      
      SetEndian( BBBP);
      OSD_Off(LCD_IO_Base);
	  Load_Image( "D:\\FTLCDc100\\Script\\ship565_320x240.bin", 153600, pFrameBuffer, BBBP);
	//  OSD_Test(1, "RGB BBBP 16 BPP");
	
	  
	  SetEndian( LBLP);
	  Load_Image( "D:\\FTLCDc100\\Script\\ship565_320x240.bin", 153600, pFrameBuffer, LBLP);
//	  OSD_Test(1, "RGB LBLP 16 BPP");
	  
	  
      Init_LCD( LCD_IO_Base, FLcdModule, panel_type, 24);
      SetEndian( BBBP);
      Set_DivNo(0xf);
	  Load_Image( "D:\\FTLCDc100\\Script\\ship888_320x240.bin", 307200 , pFrameBuffer, BBBP);
//      OSD_Test(1, "RGB  24BPP");
      
      Init_LCD( LCD_IO_Base, FLcdModule, panel_type, 16);
      animation_test( pFrameBuffer, "D:\\FTLCDc100\\Script\\mov3224\\mov3224.bin",  1536000, int_num  );
     }
   else
     { 
              
      Init_LCD( LCD_IO_Base, FLcdModule, panel_type, 16);
      OSD_Off(LCD_IO_Base);
	  SetEndian(LBBP);
	  Load_Image( "D:\\FTLCDc100\\Script\\castle64565.bin", 614400, pFrameBuffer, LBBP);
//	  OSD_Test(1, "RGB LBBP 16 BPP");
	  	 
	  SetEndian( BBBP);
	  OSD_Off(LCD_IO_Base);
	  Load_Image( "D:\\FTLCDc100\\Script\\castle64565.bin", 614400, pFrameBuffer, BBBP);
//	  OSD_Test(1, "RGB BBBP 16 BPP");
	  
	  SetEndian( LBLP);
	  OSD_Off(LCD_IO_Base);
	  Load_Image( "D:\\FTLCDc100\\Script\\castle64565.bin", 614400, pFrameBuffer, LBLP);
	  OSD_Test(1, "RGB LBLP 16 BPP");

      Init_LCD( LCD_IO_Base, FLcdModule, panel_type, 24);     
      OSD_Off(LCD_IO_Base);
      Set_DivNo(0xf);
      Load_Image( "D:\\FTLCDc100\\Script\\samuel64888.bin", 1228800, pFrameBuffer, BBBP);
	  OSD_Test(1, "RGB 32 BPP");
	  
	  OSD_Off(LCD_IO_Base);
      Init_LCD( LCD_IO_Base, FLcdModule, panel_type, 16);
      animation_test(pFrameBuffer, "D:\\FTLCDc100\\Script\\animation565.bin", 6144000, int_num );
	 }  
	    
     ColorBar_RGB( 8, LBBP, pFrameBuffer, panel_width, panel_height,1);
    
    
  //***************************** 1bpp ******************************************* 
           

   Init_LCD( LCD_IO_Base, FLcdModule, panel_type, 16);
   ColorBar_YCbCr_422( LBBP, pFrameBuffer, panel_width , panel_height, 1);
   ColorBar_YCbCr_422( BBBP, pFrameBuffer, panel_width , panel_height, 1);
	
}

/*
Show_Picture( char *file, unsigned char *pFrameBuffer, int width, int height)
{
   FILE *fptr;
   unsigned int bytes;
   
    fptr = fopen( file , "rb");
    pFrameBuffer = malloc( (width *height *4 ) + 0x3f);
    pFrameBuffer += 0x3F;
    pFrameBuffer = (unsigned char *) ((unsigned int ) pFrameBuffer & 0xffffffc0) ;  
    SetFrameBase( pFrameBuffer );
  

  if(  (bytes = fread(pFrameBuffer, sizeof(unsigned int) *640 *480 , 1 , fptr)) == NULL)
   {
    printf("File open error, read %d bytes \n", bytes);
   } 
    
   
    

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -