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

📄 main.c.bak

📁 s3c44box开发板的源码Provides a project documentation and links to download the
💻 BAK
字号:
/*************************************************
 *          project: YT028C6S-B01      		     *
 *               IC: HX8346                      *
 *         test_mcu: S3C44B0                     *
 *        Interface: I8080/8bit                  *
 *       programmer: Allen                       *
 *             date: 2008.01.13                  *
 *************************************************/
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
//#include "picture.h"
//------------------------------
#define red 0xf800
#define green 0x07e0
#define blue 0x001f
#define white 0x0000
#define black 0xf800
#define LCD_H 320
#define LCD_W 240
//---------------------------
void LCD_CtrlWrite(U16 c,U16 d);
void Write_C (U16 cmd);
void Write_D (U16 dat);
void Initial_LCM(void);
void Display_full(U16 color);
//void Display_bar(U8 x);
//void Draw_bar(U8 x,U8 y,U8 color_data1,U8 color_data2);
//void Display0 (U8 d1,U8 d2,U8 number);
//void Display1(U8 *p);
/**********************************************************
 *					主程序
**********************************************************/
void Main(void)
{
    U8 gray=0;
  	U8 color=1;
    rSYSCFG=CACHECFG;   // Using 8KB Cache//

    Port_Init();
    //---------------
    Uart_Init(0,57600);
    Delay(10);
    Uart_Select(0); //Select UART0

    Uart_Printf("\n本程序由黄初荣编写 !");
    //-------------------------
    Initial_LCM();
    Uart_Printf("\n初始化完毕 !");
    while(1)
  	{
   		Display0(0xf8,0x00,0); //Delay(6000);    //Display the R view
   		//check_key();
		Uart_Printf("\n显示全红色!");
		Delay(10000);
  		Display0(0x07,0xe0,0); //Delay(6000);    //Display the G view
   		//check_key();
		Uart_Printf("\n显示全绿色 !");
		Delay(10000);
   		Display0(0x00,0x1f,0); //Delay(6000);     //Display the B view
   		//check_key();
		Uart_Printf("\n显示全蓝色 !");
		Delay(10000);
   		Display0(0xff,0xff,0);// Delay(6000);     //Display the white view
   		//check_key();
		Uart_Printf("\n显示全白色 !");
		Delay(10000);
   		Display0(0x00,0x00,0); //Delay(6000);    //Display the black view
  		// check_key();
		Uart_Printf("\n显示全黑色 !");
		Delay(10000);
   		Display0(0xff,0xff,1); //Delay(6000);
  		// check_key();
		/*Led_Display(0x02);
		Delay(10000);
   		Display0(0x00,0x00,2); //Delay(6000);
  		// check_key();
		
		Delay(10000);
   		//Display0(0x00,0x00,3); //Delay(6000);
  		// check_key();
		
   		Display0(0xC6,0x18,4); //Delay(6000);
  		// check_key();
  		Led_Display(0x00);
  		Delay(10000);*/
   		Display_bar(gray);     //Delay(6000);
  		// check_key();
		Uart_Printf("\n测试彩条!");
		Delay(10000);
   		Display_bar(color);    //Delay(6000);
  		// check_key();
  		Uart_Printf("\n测试完毕 !");
  		Delay(10000);  
   		//Display1(picture1);   // Delay(6000)
   		//Led_Display(0x04);
  		//Delay(15000);         
  	}
}

/*******************************************************
 *                    液晶初始化子程序                 *
 *******************************************************/

void Initial_LCM(void)
{
  	//PD3--LCD_reset
	rPDATD&=0x7f;   //LCD_CS=0;PD7
	rPDATD&=0xf7;         // LCD_reset=0;
	Delay(200);          //Delay20ms
	rPDATD|=0x08;         // LCD_reset=1;
	Delay(500);          //Delay10ms
 	
// Gamma

  LCD_CtrlWrite(0x0046,0x0022);
  LCD_CtrlWrite(0x0047,0x0022);
  LCD_CtrlWrite(0x0048,0x0020);
  LCD_CtrlWrite(0x0049,0x0035);
  LCD_CtrlWrite(0x004A,0x0000);
  LCD_CtrlWrite(0x004B,0x0077);
  LCD_CtrlWrite(0x004C,0x0024);
  LCD_CtrlWrite(0x004D,0x0075);
  LCD_CtrlWrite(0x004E,0x0012);
  LCD_CtrlWrite(0x004F,0x0028);
  LCD_CtrlWrite(0x0050,0x0024);
  LCD_CtrlWrite(0x0051,0x0044);


//240x320 window setting

  LCD_CtrlWrite(0x0002,0x0000);  // Column address start2
  LCD_CtrlWrite(0x0003,0x0000);  // Column address start1
  LCD_CtrlWrite(0x0004,0x0000);  // Column address end2
  LCD_CtrlWrite(0x0005,0x00EF);  // Column address end1
  LCD_CtrlWrite(0x0006,0x0000);  // Row address start2
  LCD_CtrlWrite(0x0007,0x0000);  // Row address start1
  LCD_CtrlWrite(0x0008,0x0001);  // Row address end2
  LCD_CtrlWrite(0x0009,0x003F);  // Row address end1

// Display Setting

  LCD_CtrlWrite(0x0001,0x0006);    // IDMON=0, INVON=1, NORON=1, PTLON=0
  LCD_CtrlWrite(0x0016,0x0008);  // MY=0, MX=0, MV=0, BGR=1, TEON=0
  LCD_CtrlWrite(0x0023,0x0095);   // N_DC=1001 0101
  LCD_CtrlWrite(0x0024,0x0095);   // P_DC=1001 0101
  LCD_CtrlWrite(0x0025,0x00FF);   // I_DC=1111 1111
  LCD_CtrlWrite(0x0028,0x0002);   // N_BP=0000 0010
  LCD_CtrlWrite(0x0029,0x0002);   // N_FP=0000 0010
  LCD_CtrlWrite(0x002A,0x0002);   // P_BP=0000 0010
  LCD_CtrlWrite(0x002B,0x0002);   // P_FP=0000 0010
  LCD_CtrlWrite(0x002C,0x0002);   // I_BP=0000 0010
  LCD_CtrlWrite(0x002D,0x0002);   // I_FP=0000 0010
  LCD_CtrlWrite(0x003A,0x0001);   // N_RTN=0000, N_NW=001
  LCD_CtrlWrite(0x003B,0x0001);   // P_RTN=0000, P_NW=001
  LCD_CtrlWrite(0x003C,0x00F0);   // I_RTN=1111, I_NW=000
  LCD_CtrlWrite(0x003D,0x0000);   // DIV=00
  Delay(20);

 // Power Supply Setting

  LCD_CtrlWrite(0x0019,0x0041);  // OSCADJ=100 010, OSD_EN=1
  Delay(10);
  LCD_CtrlWrite(0x0020,0x0080);  // BT=1000
  LCD_CtrlWrite(0x001D,0x0047);  // VC2=100, VC1=001
  LCD_CtrlWrite(0x001E,0x0000);  // VC3=000
  LCD_CtrlWrite(0x001F,0x0003);  // VRH=1101
  LCD_CtrlWrite(0x0044,0x0020);  // VCM=010 0000
  LCD_CtrlWrite(0x0045,0x000E);  // VDV=0 1011
  Delay(10);
  LCD_CtrlWrite(0x001C,0x0004);  // AP=110
  Delay(20);
  LCD_CtrlWrite(0x001B,0x0018);  // NIDSENB=0, PON=1, DK=1, XDK=0,
       // VLCD_TRI=0, STB=0
  Delay(40);
  LCD_CtrlWrite(0x001B,0x0010);  // NIDSENB=0, PON=1, DK=0, XDK=0,
       // VLCD_TRI=1, STB=0
  Delay(40);
  LCD_CtrlWrite(0x0043,0x0080);    // VCOMG=1
  Delay(100);

 // Display ON Setting

  LCD_CtrlWrite(0x0030,0x0008);   // SAPS1=1000
  Delay(40);

  LCD_CtrlWrite(0x0026,0x0004);   //GON=0, DTE=0, D=01
  Delay(40);
  LCD_CtrlWrite(0x0026,0x0024);   //GON=1, DTE=0, D=01
       Delay(40);
  LCD_CtrlWrite(0x0026,0x002C);   //GON=1, DTE=0, D=11
  Delay(40);

  LCD_CtrlWrite(0x0026,0x003C);   //GON=1, DTE=1, D=11
}
     
     /*********************************************************
         *                     显示子程序0                       *
     *********************************************************/

        void  Display0 (U8 d1,U8 d2,U8 number)
        {  U8 a;
           U8 b;
           LCD_CtrlWrite(0x00,0x20);    // set RAM start position
           Write_D(0X00,0x00);
           LCD_CtrlWrite(0x00,0x21);    // set gate scan start position
           Write_D(0X00,0x00);
           LCD_CtrlWrite(0x00,0x22);    // start write RAM
           if (number==3)
            {
             for(a=0;a<320;++a)
              {
              	for(b=0;b<240;++b)
              	 {
              	  if((b==0)||(b==239)||(a==0)||(a==319))
                    	Write_D(0xff,0xff);
                  else
                     	Write_D(d1,d2);
              	 }
              }
            }

           else if (number==4)
           {
            for (a=0;a<160;++a)
            {
             for (b=0;b<120;++b)
              {
                Write_D(d1,d2);
                Write_D(0xff,0xff);
              }
             for (b=0;b<120;++b)
              {
                Write_D(0xff,0xff);
                Write_D(d1,d2);
              }
            }
           }

           else
           {
            for(a=0;a<160;a++)
            {
              for(b=0;b<240;b++)
              {
                Write_D(d1,d2);
              }
              for(b=0;b<240;b++)
              {
                 switch(number)
                  {
                   case 0: Write_D(d1,d2);    break;
                   case 1: Write_D(0x00,0x00);break;
                   case 2: Write_D(0xff,0xff);break;
                  }
               }
            }
           }
         }

        /*******************************************************
         *                     显示条形子程序                  *
         *******************************************************/

         void Display_bar(U8 x)
         { 
           U8 *p;
           U8 gray[24]={0x00,0x00,0x08,0x41,0x29,0x65,0x42,0x08,0x52,0xaa,0x6b,0x6d,0x7b,0xef,0x94,0x92,0xad,0x55,0xbd,0xf7,0xe7,0x3c,0xff,0xff};
           U8 color[24]={0xf8,0x00,0x07,0xe0,0x00,0x1f,0xff,0xe0,0xf8,0x1f,0x07,0xff,0xe6,0xc3,0xce,0x06,0x36,0x78,0x5d,0x34,0x08,0x41,0x50,0x6e};
           LCD_CtrlWrite(0x00,0x20);    // set RAM start position
           Write_D(0X00,0x00);
           LCD_CtrlWrite(0x00,0x21);    // set gate scan start position
           Write_D(0X00,0x00);
           LCD_CtrlWrite(0x00,0x22);    // start write RAM
	       if (x==0)
            p=&gray[0];
           else
            p=&color[0];
           Draw_bar(240,32,*p,*(p+1));
           Draw_bar(240,32,*(p+2),*(p+3));
           Draw_bar(240,32,*(p+4),*(p+5));
           Draw_bar(240,32,*(p+6),*(p+7));
           Draw_bar(240,32,*(p+8),*(p+9));
           Draw_bar(240,32,*(p+10),*(p+11));
           Draw_bar(240,32,*(p+12),*(p+13));
           Draw_bar(240,32,*(p+14),*(p+15));
           Draw_bar(240,32,*(p+16),*(p+17));
           Draw_bar(240,32,*(p+18),*(p+19));
       //  draw_bar(240,32,*(p+20),*(p+21));
       //  draw_bar(240,32,*(p+22),*(p+23));
	   	  }
		void  Draw_bar(U8 x,U8 y,U8 color_data1,U8 color_data2)
           {
            U8 a;
            U8 b; 
            for(b=0;b<y;++b)
            {
             for(a=0;a<x;++a)
             {
              Write_D(color_data1,color_data2);
             }
            }   
           }  

        /*******************************************************
         *                     显示图片子程序1                     *
         *******************************************************/

  		void Display1(U8 *p)
         { 
         	U16 i,j;
					LCD_CtrlWrite(0x00,0x20);    // set RAM start position
         	Write_D(0X00,0x00);
         	LCD_CtrlWrite(0x00,0x21);    // set gate scan start position
         	Write_D(0X00,0x00);
					LCD_CtrlWrite(0x00,0x22);    // start write RAM
					for(i=0;i<320;i++)
           	{ 
           		for(j=0;j<240;j++,p=(p+2))
             	{
              		Write_D (*p,*(p+1));
             	}
           	}
		 		}
/********************************************************
*		全屏显示程序
********************************************************/
void Display_full(U16 color)
{
	U8 i,j;
	LCD_CtrlWrite(0x0020,0x0000);
	LCD_CtrlWrite(0x0021,0x0000);
	Write_C(0x0022);
	for(i=0;i<LCD_H;i++)
	{
		for(j=0;j<LCD_W;j++)
		{
			Write_D(color);
		}
	}
}
	/**********************************************************
  *                                       *
  **********************************************************
		void LCD_CtrlWrite(U16 c,U16 d)
		{
			Write_C(c);
			Write_D(d);
		}

   /**********************************************************
    *                      写指令子程序                      *
    **********************************************************/

void Write_C (U16 cmd)
   {
     rPDATD&=0xbf;    //LCD_RS=0 PD6
     rPDATD|=0x10;    //LCD_RD=1 PD4
   //  Delay1(1);
     rPDATD&=0x7f;   //LCD_CS=0;PD7
     rPDATC=cmd;     //send the 16 bit
     rPDATD&=0xdf;  //LCD_WR=0;PD5
     Delay(10);
     rPDATD|=0x20;  //LCD_WR=1;PD5
     rPDATC|=0x10;    //LCD_CS=1;PD7
   }


   /********************************************************
    *                       写数据子程序                   *
    ********************************************************/

void Write_D (U16 dat)
   { 
     rPDATD|=0x40;    //LCD_RS=1 PD6
     rPDATD|=0x10;    //LCD_RD=1 PD4
   //  Delay1(1);
     rPDATD&=0x7f;   //LCD_CS=0;PD7
     rPDATC=dat;     //send the 16 bit
     rPDATD&=0xdf;  //LCD_WR=0;PD5
     Delay(10);
     rPDATD|=0x20;  //LCD_WR=1;PD5
     rPDATC|=0x10;    //LCD_CS=1;PD7
   }

⌨️ 快捷键说明

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