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

📄 elcd.c

📁 OMAP1030 处理器的ARM 侧硬件测试代码 OMAP1030 是TI的双核处理器
💻 C
📖 第 1 页 / 共 2 页
字号:
 }                                          // this function i will think if the software need them.
 else {
   
   *(unsigned int *)( ELCD_DATATX_REG ) = elcdPixelData;
  }
  while(!((*(int*)(ELCD_STATUS_REG))&0x00000008));
  
  
}

/********************************************************************************************/
//Function Name:void  Writecommand( int, int  )
//Description  :Operate the DNC and RNW pin to write command to external LCD register.
//Revision     :0.1
/********************************************************************************************/
void  Writecommand(  int elcdCommandData, int nCs )
{

 if( nCs == 0 ){

   *(unsigned int *)( ELCD_CMDTX_REG ) = elcdCommandData; 
   } 

 else {
   
   *(unsigned int *)( ELCD_CMDTX_REG ) = elcdCommandData;  
  }

 
 while( !((*(int*)(ELCD_STATUS_REG))&0x00000200) );
}

/********************************************************************************************/
//Function Name:ResetExtModule( int )
//Description  :Reset external LCD module.
//Parameter    :1.nCs  to indicate which LCD will be reset.
//Revision     :0.1
/********************************************************************************************/
void ResetExtModule( void )
{

   Setgroup32bit( ELCD_CTL_REG2,  3,  1,  0x1 ); // set PULL UP THE RESET SIG
 
   Setgroup32bit( ELCD_CTL_REG2,  3,  1,  0x0 ); // set nreset signal to low to reset ext module.
  
}
/********************************************************************************************/
//Function Name: ReleaseReset( int )
//Description  : Release the reset pin to high.
//Parameter    : nCs indicate which LCD module will be release.
//Revision     : 0.1
/********************************************************************************************/
void ReleaseReset( void  )
{
    Setgroup32bit( ELCD_CTL_REG2,  3,  1,  0x1);  // set the nreset to high to release reset signal.
}

/********************************************************************************************/
//Function Name :updatescreen ( unsigned char*, int , int )
//Description   :Load image pixel data to LCD buffer.
//Parameter     :1.unsigned char *chElcdPixelData 2. nCs to indicate which cs pin . 3. int elcdPiexlSize
//                 to indicate how much Piexl data will be send.
//Revision      :0.1
/********************************************************************************************/
extern UWORD8 snoopy[];
void updatescreen(  int nCs, int elcdExtModulelength,  int elcdExtModulewidth )
{
 
 
 int elcdRowcount = 0;
 int elcdColumcount = 0;
 int i = 0;
 int data, rdata, gdata, bdata,temp1,temp2;
 UWORD8* p;
// Setgroup32bit( ELCD_CTL_REG2, 0, 1, 1 );       //SET NCS0 TO HIGH 051101
// Setgroup32bit( ELCD_COUNTERTX_REG,  0, 20, (320*240) );//TRY 1 . TXFIFO SEND 320*240.

 Setgroup32bit( ELCD_CTL_REG2, 0, 1, 0 );

 
  

 

  
  setdncstatus( 0 );
  Writecommand(packcommand( 0x0007 ), nCs0 );   //SET R07 :0011h  GON=1, D=01
  setdncstatus( 1 ); 
  Writedata(packcommand( 0x0011 ), nCs0 );
  
  elcddelay(400000 );   
  setdncstatus( 0 );
  Writecommand(packcommand( 0x0007 ), nCs0 );   //SET R07 :0X0000  
  setdncstatus( 1 ); 
  Writedata(packcommand( 0x0017 ), nCs0 );     //GON=1, REV = 1, D = 11
  setdncstatus( 0 );                            //RS->0
  Writecommand(packcommand( 0x0020 ), nCs0 );   //SET R20 :0X0000  
  setdncstatus( 1 );                            //RS->1 
  Writedata(packcommand( 0x0000 ), nCs0 );

  setdncstatus( 0 );
  Writecommand(packcommand( 0x0021 ), nCs0 );   //SET R21 :0X0000  
  setdncstatus( 1 ); 
  Writedata(packcommand( 0x0000 ), nCs0 );
  
  setdncstatus( 0 );
  Writecommand(packcommand( 0x0022 ), nCs0 );   //SET R22 :0X0000 
  
  setdncstatus( 1 ); 

    for(i=0; i<2;i++)
	{
   p = snoopy;
    
	for (elcdColumcount=0; elcdColumcount < elcdExtModulewidth; elcdColumcount++ )
	   {
	      for(elcdRowcount=0 ;elcdRowcount < elcdExtModulelength; elcdRowcount++ )
		  {
		   temp1 = (*p);
		   bdata =((temp1&0x1f)<<1);
		   p++;
		  temp2 = (*p);
		  gdata = ((temp1>>5)|((temp2&0x7)<<3));
		  rdata = ((temp2>>3)<<1);
		 
		 data = (rdata<<12)+(gdata<<6)+bdata; 
		   
		   Writedata( (data), nCs );
		   p++;
           
           }
		}
	Setgroup32bit( ELCD_COUNTERTX_REG,  0, 20, (240*320) );
    UART_Printf(UART2, "number: %d \r\n",i);
    elcddelay(100000 );   
    }
     Setgroup32bit( ELCD_CTL_REG2, 0, 1, 1 );
 
  
 
  
}

/********************************************************************************************/
//Function Name :void StartLcd( int )
//Description   :Start the LCD which is been indicated by parameter1.
//Parameter     :1.int nCs
//Revision      : 0.1
/*********************************************************************************************/
void StartLcd( int nCs )
{
 if( nCs == 0 ){
 
   Setgroup32bit( ELCD_CTL_REG2, 0, 1, 0 );    //THE ELCD START WHEN CLEAR THE CTL_REG2{0]
  }
 else {
   
   Setgroup32bit( ELCD_CTL_REG2, 1, 1, 0 );   // start sublcd.

  }


}

/*********************************************************************************************/
//Function Name: StopLcd ( int nCs )
//Description  : switch the elcd module to idle mode.
//Parameter    : 1. int nCs to indicate which LCD will be idle.
/*********************************************************************************************/
void StopLcd ( int nCs )
{
 if( nCs == 0 ){
 
   Setgroup32bit( ELCD_CTL_REG2, 0, 1,1 );    //Set the ELCD module to stop the TX to main lcd.
  }
 else {
   
   Setgroup32bit( ELCD_CTL_REG2, 1, 1, 1 );   // stop  sublcd.

  }

}

/*********************************************************************************************/
//Function Name : SetupBusSize( int )
//Description   : Set the data bus size . 4, 8, 16, 18.
//Parameter     : int elcdBusSize to indicate the bus size.
/*********************************************************************************************/
void SetupBusSize ( int elcdBusSize )
{
   
    if ( elcdBusSize == 18 ){

      Setgroup32bit( ELCD_CTL_REG2, 11, 3, 5 ); // 18bit bus size. other of this reg is default.

    }
	else if ( elcdBusSize == 8 ) {
	  Setgroup32bit( ELCD_CTL_REG2, 11, 3, 1 );// 8 bit bussize for sublcd.  
	  
	}  
}

/*********************************************************************************************/
//Function Name: ConfigurePinofelcdmodule( void )
//Description  : Configure the pin function for ELCD.
//Parameter    : No
//Revision     : 0.1
/*********************************************************************************************/
void ConfigurePinofelcdmodule( void )
{
  	Setgroup32bit( CONF_ELCD_DATA_0, 0, 2, 0x0 )  ;
	Setgroup32bit( CONF_ELCD_DATA_1, 0, 2, 0x0 )  ;
	Setgroup32bit( CONF_ELCD_DATA_2, 0, 2, 0x0 )  ;
    Setgroup32bit( CONF_ELCD_DATA_3, 0, 2, 0x0 )  ;
	Setgroup32bit( CONF_ELCD_DATA_4, 0, 2, 0x0 )  ;
	Setgroup32bit( CONF_ELCD_DATA_5, 0, 2, 0x0 )  ;
	Setgroup32bit( CONF_ELCD_DATA_6, 0, 2, 0x0 )  ;
	Setgroup32bit( CONF_ELCD_DATA_7, 0, 3, 0x0 )  ;
	Setgroup32bit( CONF_ELCD_DATA_8, 0, 3, 0x0 )  ;
	Setgroup32bit( CONF_ELCD_DATA_9, 0, 3, 0x0 )  ;
	Setgroup32bit( CONF_ELCD_DATA_10, 0, 3, 0x0 ) ;
    Setgroup32bit( CONF_ELCD_DATA_11, 0, 3, 0x0 ) ;
	Setgroup32bit( CONF_ELCD_DATA_12, 0, 3, 0x0 ) ;
	Setgroup32bit( CONF_ELCD_DATA_13, 0, 3, 0x0 ) ;
	Setgroup32bit( CONF_ELCD_DATA_14, 0, 3, 0x0 ) ;
	Setgroup32bit( CONF_ELCD_DATA_15, 0, 3, 0x0 ) ;
	Setgroup32bit( CONF_ELCD_DATA_16, 0, 3, 0x0 ) ;
	Setgroup32bit( CONF_ELCD_DATA_17, 0, 3, 0x0 ) ;
    Setgroup32bit( CONF_ELCD_NCS0, 0, 2, 0x0 )    ;
    Setgroup32bit( CONF_ELCD_NRESET, 0, 5, 0x18 ) ;   // configure m15 as ELCD-NRESET  and pull up it.
	Setgroup32bit( CONF_ELCD_ESTRB, 0, 2, 0x0 )   ;
    Setgroup32bit( CONF_ELCD_TE, 0, 2, 0x0 )      ;
    Setgroup32bit( CONF_ELCD_DNC, 0, 2, 0x0 )     ;
    Setgroup32bit( CONF_ELCD_RNW, 0, 2, 0x0 )     ;
    Setgroup32bit( CONF_GPIO_1, 0, 3, 0x0 )       ;

   Setgroup32bit( 0xfffe100c, 0, 16,  0xeaef )   ;  //enable FUNX_CONF
  // CONF_COMP_MODE_CTRL_0_REG = 0x0000eaef;


}

/*********************************************************************************************/
//Function Name: LcdBlink( int, int  )
//Description  : blink the scren with R,G,B.
//Parameter    : 1. int nCs to indicate which LCD. 2. elcdBlinkRgb to indicate which color.
//Revision     : 0.1
/*********************************************************************************************/
void  LcdBlink( int nCs, int elcdBlinkRgb )
{

}
//********************************************************************************************/
//Function Name:configureclockelcd
//Description  :configure the elcd module's clcok and release the reset signal.
//Parameter    :No
//********************************************************************************************/
void configureclockelcd( void )
{
  Setgroup32bit( ARM_IDLECT2,11,1,1 );                   //enable ADPLL output into CLKM3
  Setgroup32bit( ARM_IDLECT2,2,1,1 );                    //enable perpheral clock.
  Setgroup32bit( ARM_IDLECT2, 1 , 1, 1 );                //enable xor colck.
  Setgroup32bit( ARM_IDLECT3,0,1,1 );                    //enable L3 OCPI clock.
  Setgroup32bit( ARM_IDLECT3,2,1,1 );                    //enable TC1 clock.
  Setgroup32bit( ARM_IDLECT3,4,1,1 );                    //enable TC2 clock.
  Setgroup32bit( ARM_RSTCT2,0,1,1 );                     //release the perpheral reset.
  Setgroup32bit( ARM_RSTCT2,0,1,1 );
  Setgroup32bit( ARM_CKCTL,0,2,1 );                      //CLK260mhz/2 FOR TC CLOCK. 00:0 || 01:2|| 10: 4 ||
  Setgroup32bit( ARM_CKCTL,10,2,1 );
  Setgroup32bit( ARM_CKCTL,8,2,1 );                                                       //11:8 
  }

/*********************************************************************************************/
//Function Name: Txfifostatus( );
//Description  : Read  the TXFIFO's status to check if the the writting data is end.
//Parameter    : No
/*********************************************************************************************/
int  Txfifostatus( )
{
  
}

/*********************************************************************************************/
//Function Name: void localUpdate( int , int , int, int );
//Description  : update local area of scren.
//Parameter    : 1. nCs 2. start address x. 3. start address y. 4. update pixel data size.
//Revision     : 0.1
/**********************************************************************************************/

void localUpdate( int nCs, int elcdStartAddrX, int elcdStartAddrY, int elcdUpdateSize )
{

}


/********************************************************************************************/
//Function Name: void  Lcdtest( void )
//Description:   LCD test program entry point. Initialize the elcd module and initialize the external
//               LCD module then load IMAGE pixels file.
//Parmeter     :void 
//*********************************************************************************************/
void  Lcdtest( void )
{

	//CONFIGURATE THE PIN THEN OPEN THE BACK LIGHT , INIT THE ECLD MODULE INCLUDING TX-MODE, INTERFACE MODE, 
    unsigned int elcdEnddisplay = 0;


	triton_WLED_test();
	configureclockelcd( );

	ConfigurePinofelcdmodule ( );
    

	SetupELCD( nCs0 );

	ResetExtModule( );    

    elcddelay( 400000 );

    ReleaseReset( );

    

	InitOptrexLcd( nCs0 );

    
    updatescreen(nCs0, 240, 320 );
    UART_Printf(UART2, "PLEAS INPUT A KEY ON PC TO END THE LCD DISPLAY.\r\n" );

    elcdEnddisplay = UART_GetNum( UART2 );


    


}


⌨️ 快捷键说明

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