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

📄 fun_s.c

📁 是用ARM7模拟RGB程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************Copyright (c)*********************************
** 文件说明
**---------------------------------------------------------------------------
**文   件   名: fun_s.c
**创   建   人: 杨宏伟
**修   改   人: 杨宏伟
**创  建 日 期:2003年10月19日
**最后修改日期: 2005年10月20日
**描        述: NT3912/PXC3100,FOR LG PANEL,串行+RGB
**             
****************************************************************************/
#include "config.h"
extern void delay(uint32  dly);
extern uint8  G_CurrContrastValue;  // 全局变量,设置对比度值

#define COMMAND_START_BYTE  0x70
#define DATA_START_BYTE     0x72



/****************************************************************************
** 函数实现
*****************************************************************************/

/*===========================================================================
** 函数名称: send()
** 功能描述: 软件模拟SPI串行,发送数据
============================================================================*/
void  send(uint8 data)
{  
   uint8  i;

   
   for(i=0; i<8; i++)			// 发送8位数据
   {  
      IO0CLR = SCK;			    // SCK = 0
      // 设置SPI的DATA输出值
      //if( (data&0x80)!=0 ) IO0SET = SDA;
      //  else IO0CLR = SDA;
      //data <<= 1;
      if( ((data<<i)&0x80)!=0 ) IO0SET = SDA;
        else IO0CLR = SDA;
      IO0SET = SCK;			   // SCK = 1
   }
 
}


/*===========================================================================
** 函数名称: data_out()
** 功能描述: 输出数据,并行,软件模拟8080
============================================================================*/
void data_out(uint8 i)
{
    // interface  8080
    
	//IO0CLR = 0x000000FF;
	IO1CLR = CS0;
	IO1SET = DC0;

	send(DATA_START_BYTE);
	send(i);

	IO1SET = CS0;
}

/*===========================================================================
** 函数名称: comm_out()
** 功能描述: 输出指令,并行,软件模拟8080
============================================================================*/
void comm_out(uint8 i)
{

    // interface  8080
    
	//IO0CLR = 0x000000FF;
	IO1CLR = CS0;
	IO1CLR = DC0;

	send(COMMAND_START_BYTE);
	send(0x00);
	send(i);

	IO1SET = CS0;
  
}



void powerSettingFunction(void)
{

	comm_out(0x07);	
   	data_out(0x01);
   	data_out(0x04);	    

	comm_out(0x0d);
    data_out(0x02);
    data_out(0x02);

	
    comm_out(0x10);	
	data_out(0x60);
	data_out(0x60); 
	   
    comm_out(0x11);	
	data_out(0x00);
	data_out(0x01);

    comm_out(0x12);
	data_out(0x10);
	data_out(0x18);

    comm_out(0x13);	
	data_out(0x31);
	data_out(0x11);


}


void displayOffFunction(void)
{
    comm_out(0x07);	
	data_out(0x00);
	data_out(0x01);
	
    comm_out(0x07);	
	data_out(0x00);
	data_out(0x11);  
	
    comm_out(0x07);	
	data_out(0x00);
	data_out(0x15);   
	
	comm_out(0x07);	
	data_out(0x00);
	data_out(0x00);  	

}


void displayOnFunction(void)
{

    comm_out(0x07);	
	data_out(0x00);
	data_out(0x01);
	
    comm_out(0x07);	
	data_out(0x00);
	data_out(0x21);  
	
    comm_out(0x07);	
	data_out(0x00);
	data_out(0x35);   
	
	comm_out(0x07);	
	data_out(0x00);
	data_out(0x37);  	
  
}


void sleepSet(void)
{
    comm_out(0x10);	
	data_out(0x62);
	data_out(0x60); 
}


void sleepCancel(void)
{
    comm_out(0x10);	
	data_out(0x60);
	data_out(0x60); 

}



/*===========================================================================
** 函数名称: ini_lcd()
** 功能描述: 实现对LCD的初始化操作
============================================================================*/
void ini_lcd(void)
{

    //FOR NT3912,FOR LG PANEL

    comm_out(0x00);	// R00H,OSC START
	data_out(0x00);
	data_out(0x01);
	
    comm_out(0x01); // R01H,Driver Output Control
	data_out(0x01);
	data_out(0x1B);	
	
    comm_out(0x02);	// R02H,LCD Driving Waveform Control
	data_out(0x07);
	data_out(0x00);

    comm_out(0x03);	 // R03H,Entry Mode
	data_out(0x10);   
	data_out(0x30);

    comm_out(0x04);	 // R04H,Compare Register 1
	data_out(0x00);
	data_out(0x00);
         
    comm_out(0x05);	 // R05H,Compare Register 2
	data_out(0x00);
	data_out(0x00);

    comm_out(0x08);	
	data_out(0x02);
	data_out(0x02);
         
    comm_out(0x09);	// R09H,Display Control 3
	data_out(0x00);
	data_out(0x0f);

    comm_out(0x0B);	// R0BH,Frame Cycle Control
	data_out(0x00);
	data_out(0x00);

    comm_out(0x0C);	// R0CH,External Display interface Control
	data_out(0x00);
	data_out(0x01);
	
    comm_out(0x0e);	// R0EH,Contrast and Brightness Control
	data_out(0x0f);
	data_out(0x04);	

    comm_out(0x40);	// R40H,gate scan position
	data_out(0x00);
	data_out(0x00);
	
    comm_out(0x41); // R41H,vertical scroll control
	data_out(0x00);
	data_out(0x00); 
	        
    comm_out(0x42);	// R42H,1st screen drive position
	data_out(0xdb);
	data_out(0x00);

    comm_out(0x43);	// R43H,2nd screen drive position
	data_out(0xdb);
	data_out(0x00);
	
    comm_out(0x44);	// R44H,horizontal RAM position
	data_out(0xaf);
	data_out(0x00);

    comm_out(0x45);	// R45H,vertical RAM position
	data_out(0xdb);
	data_out(0x00);
	
	
	comm_out(0x21);
    data_out(0x00);
    data_out(0x00);
    
    
    //Gamma Control
	comm_out(0x30);	
	data_out(0x00);
	data_out(0x00); 
	
	comm_out(0x31);	
	data_out(0x02);
	data_out(0x04);
	
	comm_out(0x33);	
	data_out(0x00);
	data_out(0x00); 

	comm_out(0x34);	
	data_out(0x05);
	data_out(0x04); 

	comm_out(0x35);	
	data_out(0x04);
	data_out(0x05); 

	comm_out(0x36);	
	data_out(0x07);
	data_out(0x07); 
	
	comm_out(0x37);	
	data_out(0x01);
	data_out(0x00); 
	
	comm_out(0x3A);	
	data_out(0x15);
	data_out(0x06); 

	comm_out(0x3B);	
	data_out(0x00);
	data_out(0x0F); 
	

  
    // power on sequence
    comm_out(0x07);	
	data_out(0x00);
	data_out(0x00);
	
	comm_out(0x12);	
	data_out(0x00);
	data_out(0x00);

    comm_out(0x13);	
	data_out(0x00);
	data_out(0x00);
 
    comm_out(0x11);	
	data_out(0x00);
	data_out(0x05);     
         
    comm_out(0x12);	
	data_out(0x00);
	data_out(0x08);

    comm_out(0x13);	
	data_out(0x00);
	data_out(0x1e);

    comm_out(0x12);	
	data_out(0x00);
	data_out(0x18);
	
	comm_out(0x10);	
	data_out(0x00);
	data_out(0x04);
     
                 
    comm_out(0x10);	
	data_out(0x00);
	data_out(0x04);

    comm_out(0x11);	
	data_out(0x00);
	data_out(0x01);

    comm_out(0x10);	
	data_out(0x60);
	data_out(0x64);

    comm_out(0x12);
	data_out(0x10);
	data_out(0x18);

    comm_out(0x10);	
	data_out(0x60);
	data_out(0x60);               

    comm_out(0x13);	
	data_out(0x31);
	data_out(0x11);

    comm_out(0x07);	
	data_out(0x00);
	data_out(0x01);
	
    comm_out(0x07);	
	data_out(0x00);
	data_out(0x21);  
	
    comm_out(0x07);	
	data_out(0x00);
	data_out(0x35);   
	
	comm_out(0x07);	
	data_out(0x00);
	data_out(0x37); 


    
}



/*===========================================================================
** 函数名称: selectSeries()
** 功能描述: 时序选择,0-8080,1-6800
============================================================================*/
void selectSeries(uint8 i)
{

   //SELECT SERIES 
   switch(i)
   {
      case 0:
           //SELECT  8080
            IO1SET = RD0;
            IO1SET = WR0;
            break;
      case 1:
           //SELECT  6800
            IO1CLR = RD0;
            IO1CLR = WR0;
            break;
      default:
            ;

   }
}


void setSPIMode(void)
{
    comm_out(0x0C);	//SET SYSTEM INTERFACE
	data_out(0x00);
	data_out(0x00);	
	
}

void setRGBMode(void)
{
	comm_out(0x03);	//SET RGB INTERFACE,HWM=1,AM=0 
	data_out(0x72);
	data_out(0x30);	
	
	comm_out(0x0C);	//SET RGB INTERFACE(16bit)
	data_out(0x01);
	data_out(0x11);

}

void writeRGBdata(uint16 row,uint16 col,uint16 dataH,uint16 dataL)
{
	uint16 i,j;

	IO0CLR = 0x000000FF;
	
    IO1CLR = CS0;
	IO1CLR = VSYNC;	
	IO1SET = VSYNC;	

	for(i=0;i<row;i++)
	{

		IO1CLR=HSYNC;

		
		IO1SET=HSYNC;
		IO1CLR=ENABLE;
		for(j=0;j<col;j++)
		{	
			IO0SET = (dataH<<8)|(dataL);
			IO1CLR = DOTCLK;	
			IO1SET = DOTCLK;	
			
		}

		IO1SET=ENABLE;

	}

	IO1SET=ENABLE;
	IO1CLR=VSYNC; //VSYNC=1;
	IO1CLR=HSYNC; //HSYNC=1;

	IO1SET=CS0;


}


void dispColor_RGB(uint16 row,uint16 col,uint16 rgb1,uint16 rgb2)
{
	

	comm_out(0x21);
	data_out(0x00);
	data_out(0x00);

	setRGBMode();
	comm_out(0x22);
	writeRGBdata(row,col,rgb1,rgb2);


}




/*===========================================================================
** 函数名称: dispColor()
** 功能描述: 显示颜色
============================================================================*/
void dispColor(uint16 row,uint16 col,uint8 rgb1,uint8 rgb2,uint16 dly)
{
    uint16 i,j;
    
    //comm_out(0x21);
    //data_out(0x00);
    //data_out(0x00);
    
    for(i=0;i<row;i++)
	{
          for(j=0;j<col;j++)
		  {
		  	 comm_out(0x22);
		  	 data_out(rgb1 );
		  	 data_out(rgb2);
			 delay(dly);
          }
    }

}


/*===========================================================================
** 函数名称: dispPic()
** 功能描述: 显示图片
============================================================================*/
void dispPic(uint16 row,uint16 col,const uint8 *picture)
{						  
   uint16  i,j;
   //uint16  temp1,temp2;
   
    //comm_out(0x21);
    //data_out(0x00);
    //data_out(0x00);
   
   for(i=0;i<row;i++)
   {
      for(j=0;j<col;j++)
      {
      	 
         //temp1 = *picture;
         //temp2 = *(++picture);
         
         //data_out( ((temp1<<8)&(0xff00))|((temp2)&(0xff)) );  
         //picture ++;
         comm_out(0x22);
         data_out(*(picture++));
         data_out(*(picture++));
      }
   }


}


/*===========================================================================
** 函数名称: dispColorY()
** 功能描述: 显示垂直色条(8种颜色)
============================================================================*/
void dispColorY(uint16 row,  uint16 col,
                uint16 rgbA1,uint16 rgbA2,
                uint16 rgbB1,uint16 rgbB2,
                uint16 rgbC1,uint16 rgbC2,
                uint16 rgbD1,uint16 rgbD2,
                uint16 rgbE1,uint16 rgbE2,
                uint16 rgbF1,uint16 rgbF2,
                uint16 rgbG1,uint16 rgbG2,
                uint16 rgbH1,uint16 rgbH2 
               )
{

	uint16 i,j,k;
	k=col/8;
	
    //comm_out(0x21);
    //data_out(0x00);
    //data_out(0x00);
    comm_out(0x22);
    
	for(i=0;i<row;i++)
	{


		for(j=0;j<k;j++)
		{
		   data_out(rgbA1);
		   data_out(rgbA2);
		}


		for(j=0;j<k;j++)
		{

          data_out(rgbB1);
		  data_out(rgbB2);
		}

		for(j=0;j<k;j++)
		{

          data_out(rgbC1);
		  data_out(rgbC2);
		}

		for(j=0;j<k;j++)
		{

           data_out(rgbD1);
		   data_out(rgbD2);
		}
		for(j=0;j<k;j++)
		{

⌨️ 快捷键说明

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