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

📄 flcd.c

📁 FIC8120方案的 StartCell_Driver
💻 C
📖 第 1 页 / 共 5 页
字号:
   *(unsigned int *) (LCD_IO_Base + 0x38) = (HPos << 10) |  VPos;
}   

void OSD_Dim( unsigned int LCD_IO_Base, int HDim, int VDim)
{
  int value;
   
  value = *(unsigned int *) (LCD_IO_Base + 0x34);
  value &= 0x0000001f;
  value |= ((HDim << 10) | (VDim << 5));
  *(unsigned int *) (LCD_IO_Base + 0x34) = value;

} 

void OSD_transparent( unsigned int  LCD_IO_Base, int level)
{
   *(unsigned int *) (LCD_IO_Base + 0x40) &= 0xffffff00;
   *(unsigned int *) (LCD_IO_Base + 0x40) |= (level << 6);
}

void OSD_fg_color( unsigned int LCD_IO_Base, int pal0, int pal1, int pal2, int pal3)
{
  unsigned int value;
    
  *(unsigned int *) (LCD_IO_Base + 0x3c) = (pal0) | (pal1 <<8) | (pal2 << 16) | (pal3<< 24);
}

void OSD_bg_color( unsigned int LCD_IO_Base, int pal1, int pal2, int pal3)
{
  unsigned int value;
  
  value = *(unsigned int *) (LCD_IO_Base + 0x40);
  value &= 0x0000003f;
  value |= (pal1 <<8) | (pal2 << 16) | (pal3 << 24);
   *(unsigned int *) (LCD_IO_Base + 0x40) = value;

}

void OSD_Scal( unsigned int LCD_IO_Base, int HScal, int VScal)
{
  unsigned int value;
  
  value = *(unsigned int *) (LCD_IO_Base + 0x34);
  value &= 0xffffffe1;
  value |= (HScal<<3) | (VScal << 1) ;
  *(unsigned int *) (LCD_IO_Base + 0x34) = value;
}

void OSD_putc( char c, int position)
{
 
  
  
  if( c >= '0' && c < '9' )
   {
        *(unsigned int *) (LCD_IO_Base + 0xc000 + position *4 )  = ( (c -'0') << 4);  
   }   
  else if( c>= 'A' && c <= 'Z')
  {  
      *(unsigned int *) (LCD_IO_Base + 0xc000 + position *4 )  = ( ( c - 'A' +10) << 4); 
  } 
               
  if( c == ' ' )
    *(unsigned int *) (LCD_IO_Base + 0xc000 + position *4 )  = ( ( 'Z' - 'A' +10 + 1) << 4); 
    
  if( c == '=')
   *(unsigned int *) (LCD_IO_Base + 0xc000 + position *4 )  = ( ( 'Z' - 'A' +10 + 2) << 4);  
   
  if( c == ',')
   *(unsigned int *) (LCD_IO_Base + 0xc000 + position *4 )  = ( ( 'Z' - 'A' +10 + 3) << 4);       
   
   
   
}

void OSD_puts( char *str, int position)
{
  int i;
  
  for(i=0; i< strlen(str); i++)
    OSD_putc( *(str +i), position +i );

}

void OSD_Test( int mode, char *str)
{
   int i,j,x,y, k;
   char result;
   char *msg="                                        ";
   
   
   
   strcpy( msg, str);
   
   
   
   
   for(i=0; i< 16*10 + 16* 26  ; i++)   // 10 digit & 10 alphabet
      *(unsigned int *) (LCD_IO_Base + 0x8000 +i*4 )  = OSD_Font[i];
      
    for(i=0; i< 100  ; i++)
      *(unsigned int *) (LCD_IO_Base + 0xc000 +i*4 )  = OSD_Attribute[i];        
      
    OSD_puts(str, 0);   
//   Init_LCD( LCD_IO_Base, LcdModule, panel_type, 24);
//   ColorBar_RGB( 4, LBBP, pFrameBuffer, panel_width, panel_height, 0);
   
   *(unsigned int *) (LCD_IO_Base + 0x3c) = 0xFF1C03e0;   //Pal3 (FF)= , Pal2 (1C)= Green, Pal1(03) = Red, Pal0(E0)= Blue
   
   if(mode == 2)   //YCbCr
   {
     OSD_fg_color(LCD_IO_Base, 0x57, 0x88, 0x3B, 0xFF);
     OSD_bg_color(LCD_IO_Base, 0x57, 0x88, 0x3B);
//     OSD_puts("YCBCR OSD   ", 0);    
   }
   else
   {
    OSD_fg_color(LCD_IO_Base, 0x07, 0x38, 0xC0, 0xFF);
    OSD_bg_color(LCD_IO_Base, 0x07, 0x38, 0xc0);
//    OSD_puts("RGB OSD ", 0);   
   }
   
   
    OSD_On(LCD_IO_Base);  
    OSD_transparent( LCD_IO_Base, 1);
   
    
   
                  
//  msg="D 10 10,      
  i=j=10;
  OSD_Dim( LCD_IO_Base, i, j);
  

  OSD_Scal(LCD_IO_Base, 0,0 );
  for( x= 1, y=1 ; x< 250; x++)     //Move from "top left" to "top right"
   {
    OSD_Pos(LCD_IO_Base, x,y);
     for(k=0; k<7000;k++);
   }  
    


  OSD_Scal(LCD_IO_Base, 1,1 );
  for( ;y<150; y++)                //Move From "top right" to "bottom right"
   {
    OSD_Pos(LCD_IO_Base, x,y);
     for(k=0; k<7000;k++);
   }  
 

  
  for( ; x> 2; x--)                //Move from "bottom right" to "bottom left"
   {
    OSD_Pos(LCD_IO_Base, x,y);
     for(k=0; k<7000;k++);
   }  
   
  
  OSD_Scal(LCD_IO_Base, 3,3); 
  for( ; y> 2; y--)               //Move from "bottom left" to "top left"
   {
    OSD_Pos(LCD_IO_Base, x,y);
    for(k=0; k<7000;k++);
   }   
   
   
   
  OSD_Scal(LCD_IO_Base, 0, 3);  
  for( ; x< 250; x++, y++)        //Move from "top left" to "bottom right"
    {
    OSD_Pos(LCD_IO_Base, x,y);
    for(k=0; k<7000;k++);
   }   


  OSD_Scal(LCD_IO_Base, 3, 0); 
  OSD_transparent( LCD_IO_Base, 2);  
  for( x=200, y=0; x> 0; x--, y++)   //Move from "top right" to "bottom left"
    {
    OSD_Pos(LCD_IO_Base, x,y);
    for(k=0; k<7000;k++);
   }
   
  
  OSD_Scal(LCD_IO_Base, 0,0 );
  OSD_transparent( LCD_IO_Base, 3); 
  OSD_Pos(LCD_IO_Base, 100, 60); 
  for( i=2; i<=10; i++)
    for( j=2; j<=10; j++)   
     {
        OSD_Dim( LCD_IO_Base, i, j);
        for(k=0; k<50000;k++);
     }         
      
    
    
   


    
}



void ColorBar_RGB( unsigned char bpp, unsigned char endian, unsigned char *pFrameBuffer, int width, int height, int int_test)
{
   int i,j;
   char result;
   unsigned pixel_per_byte;
   unsigned char pattern[4][5]={
                                 {0x00, 0xff, 0x00, 0x0f, 0xf0},  //1bpp {Bar1, Bar2, Bar3, pixel-enidan1, pixel-endian2}
                                 {0x00, 0x55, 0xaa, 0x05, 0x50},  //2bpp {Bar1, Bar2, Bar3, pixel-enidan1, pixel-endian2}
                                 {0x00, 0x11, 0x22, 0x01, 0x10},  //4bpp {Bar1, Bar2, Bar3, pixel-enidan1, pixel-endian2}
                                 {0x00, 0x1,  0x2,  0x99, 0x99}  //8bpp {Bar1, Bar2, Bar3, no-pixel-endian, no-pixel-endian}                             
                               };  
   unsigned char bpp_tbl[9]={99,0,1,99,2,99,99,99,3};                            
   
   pixel_per_byte = 8/bpp;
  // Init_LCD( LCD_IO_Base, LcdModule, panel_type, bpp);

  
  
  OSD_Off(LCD_IO_Base); 
  *(unsigned int *) (LCD_IO_Base + 0x200) = 0x07E0001F;  // Palette 0 = Red,  Palette 1=Green
  *(unsigned int *) (LCD_IO_Base + 0x204) = 0xF800F800;  // Palette 2 = Blue,  
     
   SetBPP(bpp);
    
    switch(endian)
  {
    case BBBP:  printf("RGB %d BBBP Testing\n", bpp);
                break;
    case LBLP:  printf("RGB %d LBLP Testing\n", bpp);
                break;
    case LBBP:   printf("RGB %d LBBP Testing\n", bpp);
                break;                                  
  
  }
   
  
   if( endian == LBLP) 
    {
   
  	 
	 SetEndian( LBLP );
	
  
  
  
     printf("Little Byte Little Pixel Testing\n");
  
   
    
    
     for(i=0; i<height; i++)  //***********  draw pattern
      {
        for(j=0; j<width* 1/3; j++)
          if( (j% pixel_per_byte ) ==0 ) *( pFrameBuffer + i*(width/pixel_per_byte) + j/pixel_per_byte) = pattern[ bpp_tbl[bpp] ][0];
          
        for(j=width* 1/3; j< width * 2/3; j++)
          if( (j% pixel_per_byte ) == 0 ) *( pFrameBuffer + i*(width/pixel_per_byte) + j/pixel_per_byte) = pattern[ bpp_tbl[bpp] ][1];
        for(j=width * 1/3 *2 ; j<width; j++)       
          if( (j% pixel_per_byte )== 0 ) *( pFrameBuffer + i*(width/pixel_per_byte) + j/pixel_per_byte) = pattern[bpp_tbl[bpp]][2];  
      }    
   }   
  
  
  if( endian == BBBP )
    {
      printf("Big Byte Big Pixel Testing\n");  
      SetEndian( BBBP );     

  
      for(i=0; i<height; i++)  //***********  draw pattern    
        {
        for(j=0; j<( width* 1/3) || (j%pixel_per_byte) != 0 ; j++)             // Byte order formula floor(j/4) *4  + (3-(j%4)) ; 4 -> means 1 words = 4bytes
          if( (j%pixel_per_byte) ==0 ) 
            *( pFrameBuffer + i*(width/pixel_per_byte) + (unsigned int) floor( (j/pixel_per_byte)/4) *4  +3 - ((j/pixel_per_byte) % 4) ) = pattern[ bpp_tbl[bpp] ][0];   
            
           // Test pixel endian
         *( pFrameBuffer + i*(width/pixel_per_byte) + (unsigned int) floor( (j/pixel_per_byte)/4) *4  +3 - ((j/pixel_per_byte) % 4) ) = pattern[ bpp_tbl[bpp] ][3]; 
        
        for(/*j=width* 1/3*/ ; j< width * 2/3 || (j%pixel_per_byte) != 0 ; j++)
        if( (j%pixel_per_byte) == 0 ) 
            *( pFrameBuffer + i*(width/pixel_per_byte) + (unsigned int) floor( (j/pixel_per_byte)/4) *4  +3 - ((j/pixel_per_byte) % 4)) = pattern[ bpp_tbl[bpp] ][1];    
            
//        j=419;  // Test pixel endian 
            *( pFrameBuffer + i*(width/pixel_per_byte) + (unsigned int) floor( (j/pixel_per_byte)/4) *4  +3 - ((j/pixel_per_byte) % 4) ) = pattern[ bpp_tbl[bpp] ][4];             
         
        for(/*j=width * 1/3 *2*/  ; j<width; j++)       
          if( (j%pixel_per_byte)== 0 ) 
            *( pFrameBuffer + i*(width/pixel_per_byte) + (unsigned int) floor( (j/pixel_per_byte)/4) *4  +3 - ((j/pixel_per_byte) % 4) ) =pattern[ bpp_tbl[bpp] ][2];    
       }             
  } 
  
  
  

      
  
  
   
  
  
 if( endian == LBBP )
  { 
    printf("Little Byte Big Pixel Testing\n");
    SetEndian( LBBP );
    
    for(i=0; i<height; i++)  //***********  draw pattern
     {
      for(j=0; j<( width* 1/3) || (j%pixel_per_byte) != 0 ; j++)  
        if( (j% pixel_per_byte ) ==0 ) 
            *( pFrameBuffer + i*(width/pixel_per_byte) + j/pixel_per_byte) = pattern[ bpp_tbl[bpp] ][0];
    
      *( pFrameBuffer + i*(width/pixel_per_byte) + j/pixel_per_byte) = pattern[ bpp_tbl[bpp] ][3];
        
      for(/*j=width* 1/3*/ ; j< width * 2/3 || (j%pixel_per_byte) != 0 ; j++)
        if( (j%pixel_per_byte) == 0 ) 
           *( pFrameBuffer + i*(width/pixel_per_byte) + j/pixel_per_byte) =pattern[ bpp_tbl[bpp] ][1];
           
      *( pFrameBuffer + i*(width/pixel_per_byte) + j/pixel_per_byte) = pattern[ bpp_tbl[bpp] ][4];  
        
      for(/*j=width * 1/3 *2*/  ; j<width; j++)        
        if( (j%pixel_per_byte)== 0 ) 
           *( pFrameBuffer + i*(width/pixel_per_byte) + j/pixel_per_byte) = pattern[ bpp_tbl[bpp] ][2];    
     }    
  
 
  } 
  
 if( int_test)
 {
     printf("	Check the screen, if it is correct press 'y' or 'Y'");
    do{
        result = getchar();
     }while( (result != 'y') );  
     
  //************* Check Buffer Under Run ***************************************
  
  

 
   FIFO_Under_Run=0;
   
   *(volatile unsigned int *) ( LCD_IO_Base + 0x20 )= 0x00000002;
   *(volatile unsigned int *) ( LCD_IO_Base + 0x18 )= 0x00000002;
   
   fLib_ConnectInt(34,  UnderRun_Handler );	//it only can be
   
  
    
 
   UnmaskFIQ(2);
   SetFIQmode(2,LEVEL);  
   
   EnableFIQ();	
  
  
 
 
   *(volatile unsigned int *) ( LCD_IO_Base + 0x08 ) &= 0xffff7fff;  //Adpative off
   printf("If the color bar is ok, press y to pass\n");
   do{
     result = getchar();
    }while( (result != 'y') );  
    
    
     printf("Change divisor, press 'y' or 'Y'");
   do{
      result = getchar();
    }while( (result != 'y') );  
    
   Set_DivNo(1); 
   
  
   printf("Check if your screen flash, press 'y' or 'Y'\n");
   do{
     result = getchar();
    }while( (result != 'y') );

   if( FIFO_Under_Run ) printf("Generate FIFO Under Run Interrupt Successfully\n");
   else  printf("FIFO Under Run Interrupt Fail\n");    
  
   
   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') );     
     
 
   UnmaskFIQ(2);  
   DisableFIQ();	
   fLib_CloseInt(34);         
   
 }  
}


void rgb2ycbcr( unsigned char *r, unsigned char *g, unsigned char *b)
{
  unsigned char r_tmp, g_tmp, b_tmp;
  
  r_tmp = *r;
  g_tmp = *g;
  b_tmp = *b;
  
   
  *r= (unsigned char) (0.299   * r_tmp + 0.578  * g_tmp + 0.114  * b_tmp);        //Y =

⌨️ 快捷键说明

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