Exemplo n.º 1
0
void Soft_Reset(void)
{
	xSemaphoreTake(xDispSemaphore, portMAX_DELAY);
	{
		LCD_Reset();
		Delay1ms(500);
		LCD_Initial();
		Two_Layers();
		Delay1ms(100);
		Active_Window(0,479,0,271);
		Background_color(color_black);
		Text_color(color_white);
		Text_Cursor_Disable();
		Layer1_Visible();
		Write_To_Bank1();
		Clear_Active_Window();
		Write_To_Bank2();
		Clear_Full_Window();
		Display_ON();

		//backlight on for RAiO RA8875_demo_board_V2
		PWM1_enable();
		PWM1_duty_cycle(0xff);

		Text_color(color_white);
		Background_color(color_black);
		xSemaphoreGive(xDispSemaphore);
	}
}
Exemplo n.º 2
0
/*--------------------------------------------------------------------------------------------------------------------
	Function: 		LCD_Init

	Description: 	Initialise LCD

	Revisions:

--------------------------------------------------------------------------------------------------------------------*/
void LCD_Init()
{
	LCD_Reset();		//Run LCD reset routine
	LCD_Com(0x28);		//Set LCD format: 4-bit input, 2 line, 5x7 font
	LCD_Com(0x0C);		//Turn display on
	LCD_Com(0x01);
	LCD_Com(0x06);		//Set input mode: auto increment, no shift
	LCD_Com(0x80);		//Reset cursor position
}
unsigned char wavetype(void)
{
char msg1[16] =  "   START NOW?  ";// LCD line 1 message
char msg2[16] =  "  PRESS ANYKEY ";// LCD line 2 message
unsigned char choice = 0;// represents ADC convert value
LCD_Reset();// initiliaze LCD
sprintf(msg1,"----WAVE TYPE?---");// input to LCD line 1
LCD_Line1(msg1);
do{
	choice = (unsigned char)poten(2)+2;	// let adc convert value to choice	
	switch(choice)
	{
		case SINUSOIDAL:	
								sprintf(msg2,"---SINUSOIDAL---");
		                    	LCD_Line2(msg2);

								bo=1;// 1 represent sine wave
	    break;
		case TRIANGLE:
								sprintf(msg2,"----TRIANGLE----");
								LCD_Line2(msg2);

								bo=2;// 2 represents triangle wave
		break;
		case SAWTOOTH:
								sprintf(msg2,"----SAWTOOTH----");
								LCD_Line2(msg2);

								bo=3;// 3 represents sawtooth wave
		break;
		case SQUARE:
								sprintf(msg2,"-----SQUARE-----");
								LCD_Line2(msg2);

								bo=4;// 4 represents square wave
		break;
        default: 
		break;
	}
								

if (SWITCH_1==0)// if RA5 pressed exit wavetype function goto divice type menu 
 {
 while(SWITCH_1 == 0);// wait for RA5 release
	return 1; 
 }
	
}while(SWITCH_0 == 1);//end do  while RB0 pressed.
 switch_release();// wait for RB0 release
}
Exemplo n.º 4
0
void Init_LCD()
{
	// We assume SSP0 is already initialized
	Init_LCD_Pins();

    // Reset the LCD
    LCD_Reset();

    // Initialize the local variables
    orientation = 1;
    // First line for an 8x8 font
    LCD_Locate(0, 8);

}
Exemplo n.º 5
0
void ILI9325_Init(void)
{
	unsigned int i;
	LCD_Reset();	 
	ILI9325_SetRegister(0x00E3, 0x3008); // Set internal timing
	ILI9325_SetRegister(0x00E7, 0x0012); // Set internal timing
	ILI9325_SetRegister(0x00EF, 0x1231); // Set internal timing
	ILI9325_SetRegister(0x0000, 0x0001); // Start Oscillation
	ILI9325_SetRegister(0x0001, 0x0100); // set SS and SM bit
	ILI9325_SetRegister(0x0002, 0x0700); // set 1 line inversion

	ILI9325_SetRegister(0x0003, 0x10a8); // set GRAM write direction and BGR=0,262K colors,1 transfers/pixel.
	ILI9325_SetRegister(0x0004, 0x0000); // Resize register
	ILI9325_SetRegister(0x0008, 0x0e02); // set the back porch and front porch
	ILI9325_SetRegister(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
	ILI9325_SetRegister(0x000A, 0x0000); // FMARK function
	ILI9325_SetRegister(0x000C, 0x0000); // RGB interface setting
	ILI9325_SetRegister(0x000D, 0x0000); // Frame marker Position
	ILI9325_SetRegister(0x000F, 0x0000); // RGB interface polarity
//Power On sequence 
	ILI9325_SetRegister(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
	ILI9325_SetRegister(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
	ILI9325_SetRegister(0x0012, 0x0000); // VREG1OUT voltage
	ILI9325_SetRegister(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
	Delay(200); // Dis-charge capacitor power voltage
	ILI9325_SetRegister(0x0010, 0x1690); // SAP, BT[3:0], AP, DSTB, SLP, STB
	ILI9325_SetRegister(0x0011, 0x0227); // R11h=0x0221 at VCI=3.3V, DC1[2:0], DC0[2:0], VC[2:0]
	Delay(50); // Delay 50ms
	ILI9325_SetRegister(0x0012, 0x001C); // External reference voltage= Vci;
	Delay(50); // Delay 50ms
	ILI9325_SetRegister(0x0013, 0x1800); // R13=1200 when R12=009D;VDV[4:0] for VCOM amplitude
	ILI9325_SetRegister(0x0029, 0x001C); // R29=000C when R12=009D;VCM[5:0] for VCOMH
	ILI9325_SetRegister(0x002B, 0x000D); // Frame Rate = 91Hz
	Delay(50); // Delay 50ms
	ILI9325_SetRegister(0x0020, 0x0000); // GRAM horizontal Address
	ILI9325_SetRegister(0x0021, 0x0000); // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
	ILI9325_SetRegister(0x0030, 0x0007);
	ILI9325_SetRegister(0x0031, 0x0302);
	ILI9325_SetRegister(0x0032, 0x0105);
	ILI9325_SetRegister(0x0035, 0x0206);
	ILI9325_SetRegister(0x0036, 0x0808);
	ILI9325_SetRegister(0x0037, 0x0206);
	ILI9325_SetRegister(0x0038, 0x0504);
	ILI9325_SetRegister(0x0039, 0x0007);
	ILI9325_SetRegister(0x003C, 0x0105);
	ILI9325_SetRegister(0x003D, 0x0808);
//------------------ Set GRAM area ---------------//
	ILI9325_SetRegister(0x0050, 0x0000); // Horizontal GRAM Start Address
	ILI9325_SetRegister(0x0051, 0x00EF); // Horizontal GRAM End Address
	ILI9325_SetRegister(0x0052, 0x0000); // Vertical GRAM Start Address
	ILI9325_SetRegister(0x0053, 0x013F); // Vertical GRAM Start Address
	ILI9325_SetRegister(0x0060, 0xA700); // Gate Scan Line
	ILI9325_SetRegister(0x0061, 0x0001); // NDL,VLE, REV
	ILI9325_SetRegister(0x006A, 0x0000); // set scrolling line
//-------------- Partial Display Control ---------//
	ILI9325_SetRegister(0x0080, 0x0000);
	ILI9325_SetRegister(0x0081, 0x0000);
	ILI9325_SetRegister(0x0082, 0x0000);
	ILI9325_SetRegister(0x0083, 0x0000);
	ILI9325_SetRegister(0x0084, 0x0000);
	ILI9325_SetRegister(0x0085, 0x0000);
//-------------- Panel Control -------------------//
	ILI9325_SetRegister(0x0090, 0x0010);
	ILI9325_SetRegister(0x0092, 0x0000);
	ILI9325_SetRegister(0x0093, 0x0003);
	ILI9325_SetRegister(0x0095, 0x0110);
	ILI9325_SetRegister(0x0097, 0x0000);
	ILI9325_SetRegister(0x0098, 0x0000);
	ILI9325_SetRegister(0x0007, 0x0133); // 262K color and display ON

  ILI9325_SetRegister(0x20, 0);
  ILI9325_SetRegister(0x21, 319);
	ILI9325_GRAMOperation();
	for(i=0;i<76800;i++)
	{
	  ILI9325_WritePixel(0x0000);
	}
				

}
unsigned char frequencyrange(void)
{
unsigned char m;// represent adc convert value
unsigned int f;// represent frequency 
char msg1[16] =  "   START NOW?  ";//LCD LINE 1 message
char msg2[16] =  "  PRESS ANYKEY ";// LCD line 2 message
LCD_Reset();// initiliaze LCD

sprintf(msg1,"  Please choose  ");// chose frequency message
LCD_Line1(msg1);
sprintf(msg2,"Frequency");
LCD_Line2(msg2);
Delay10KTCYx(250);// delay 0.25s
Delay10KTCYx(250);//delay 0.25s
Delay10KTCYx(250);// delay0.25s
Delay10KTCYx(250);//delay0.25s



LCD_Reset();// initialize lCD
		switch(bo)
	{
		case 1:	
								do
								{
								sprintf(msg1,"Range:11~2277 Hz");
		                    	LCD_Line1(msg1);
								m=poten(8);// ADC convert value
								if (m==0) m=1;// let the least ADC value is 1 
								f=(unsigned int)1/(1/12600+m*0.00035+0.000089);;// caculate sine wave frequency
								if ((m<=60)&&(m>=30))f=f-1;// slightly adjust frequency
								if ((m<=20)&&(m>=10))f=f-4;// slightly adjust frequency
								if ((m>5)&&(m<10) )f=f-5;// slightly adjust frequency
								if(m==5) f=f-6;// slightly adjust frequency
								if(m==4) f=f-7;// slightly adjust frequency
								if(m==3) f=f-7;// slightly adjust frequency
								if (m==2) f=f+13;// slightly adjust frequency 
								sprintf(msg2,"%10d Hz",f);
								LCD_Line2(msg2);// show frequency
if (SWITCH_1==0)
{
switch_release();//wait for RA5 release
	return 2;// if RA5 pressed goto wavetype function
 }
								}
								while(SWITCH_0 == 1);
							    switch_release();//wait for RB0 release
								sinewave(m);//output sine wave
							    switch_release();//wait for RA5 release
								return 3;// if RA5 pressed goto frequency range function
	    break;
		case 2:
								do
								{
									sprintf(msg1,"Range:6~581 Hz");
		                    	LCD_Line1(msg1);
								m=poten(8);// ADC convert value
								if (m==0) m=1;// let the least ADC value is 1 
							 	f=(unsigned int) 1/ (1/847 + m*0.00057+0.001230); //caculate and slightly adjust triangle wave frequency
								if (m==1) f=f+26;//caculate and slightly adjust triangle wave frequency
								if (m==2) f=f+20;//caculate and slightly adjust triangle wave frequency
								if (m==3) f=f+12;//caculate and slightly adjust triangle wave frequency
								if (m==4) f=f+10;//caculate and slightly adjust triangle wave frequency
								if (m==5) f=f+7;//caculate and slightly adjust triangle wave frequency
								if ((m>=6)&&(m<=8)) f=f+5;//caculate and slightly adjust triangle wave frequency
								if (m==9) f=f+4;//caculate and slightly adjust triangle wave frequency
								if ((m>=10)&& (m<=13)) f=f+3;//caculate and slightly adjust triangle wave frequency
								if ((m>=13)&&(m<=17)) f=f+2;//caculate and slightly adjust triangle wave frequency
								if ((m>=18)&&(m<=50)) f=f+1;//caculate and slightly adjust triangle wave frequency
							sprintf(msg2,"%10d Hz",f);
								LCD_Line2(msg2);// show frequency
if (SWITCH_1==0)
{
	switch_release();//wait for RA5 release
	return 2;// if RA5 pressed goto wavetype function
 }
								}
								while(SWITCH_0 == 1);
								switch_release();//wait for RB0 release
								triwave(m);// output triangle wave
								switch_release();//wait for RA5 release
								return 3;// if RA5 pressed goto frequency range function
		break;
		case 3:
								do
								{
								sprintf(msg1,"Range:5~676 Hz");
		                    	LCD_Line1(msg1);
								m=poten(8);// ADC convert value
								if (m<=1) m=2;// let the least ADC value is 2
							 	f=(unsigned int) 1/ (1/15600 + m*0.000709+0.00007);//caculate  sawtooth wave frequency
								if ((m==2)||(m==3)) f=f+4;//caculate and slightly adjust sawtooth wave frequency
								if (m==4) f=f+1;//caculate and slightly adjust sawtooth wave frequency
							sprintf(msg2,"%10d Hz",f);
								LCD_Line2(msg2);// show frequency
							
if (SWITCH_1==0)
{
	switch_release();//wait for RA5 release
	return 2;// if RA5 pressed goto wavetype function
 }								
								}
								while(SWITCH_0 == 1);
								switch_release();//wait for RB0 release
								sawtooth(m);//output sawtooth wave
								switch_release();//wait for RA5 release
								return 3;// if RA5 pressed goto frequency range function
		break;
		case 4:
								do
								{
								sprintf(msg1,"Range:102~7690Hz");
		                    	LCD_Line1(msg1);
								m=poten(8);// adc convert value
								if (m==0) m=1;// let the least ADC value is 1
							 if ((m>=140)&&(m<=255)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-0.5;//caculate and slightly adjust square wave frequency
							 if ((m>=101)&&(m<=139)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-1.5;//caculate and slightly adjust square wave frequency
							if ((m>=70)&&(m<=100)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-2.5;//caculate and slightly adjust square wave frequency
							if ((m>=64)&&(m<=69)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-3.5;//caculate and slightly adjust square wave frequency
							if ((m>=55)&&(m<=63)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-4.5;//caculate and slightly adjust square wave frequency
							if ((m>=46)&&(m<=54)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-5.5;//caculate and slightly adjust square wave frequency
							if ((m>=45)&&(m<=43)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-6.5;//caculate and slightly adjust square wave frequency
							if ((m>=40)&&(m<=42)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-7.5;//caculate and slightly adjust square wave frequency
							if ((m>=30)&&(m<=40)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-9.5;//caculate and slightly adjust square wave frequency
							if ((m>=20)&&(m<=29)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-11.5;//caculate and slightly adjust square wave frequency
							if ((m>=10)&&(m<=19)) f=(unsigned int) 1/ (1/11400 + m*0.0000376+0.000075)-2.5*m;//caculate and slightly adjust square wave frequency
							if (m==10) f=2131;//caculate and slightly adjust square wave frequency
							if (m==9) f=2313;//caculate and slightly adjust square wave frequency
							if (m==8) f=2540;//caculate and slightly adjust square wave frequency
							if (m==7) f=2810;//caculate and slightly adjust square wave frequency
							if (m==6) f=3140;//caculate and slightly adjust square wave frequency
							if (m==5) f=3570;//caculate and slightly adjust square wave frequency
							if (m==4) f=4130;//caculate and slightly adjust square wave frequency
							if (m==3) f=4900;//caculate and slightly adjust square wave frequency
							if (m==2) f=6020;//caculate and slightly adjust square wave frequency
							if (m==1) f=7690;	//caculate and slightly adjust square wave frequency
							sprintf(msg2,"%10d Hz",f);
								LCD_Line2(msg2);// show frequency
if (SWITCH_1==0)
{
	switch_release();//wait for RA5 release
	return 2;// if RA5 pressed goto wavetype function
 }									
								}
								while(SWITCH_0 == 1);
								switch_release();//wait for RB0 release
								squarewave(m);//output square wave
								switch_release();//wait for RA5 release
								return 3;// if RA5 pressed goto frequency range function
		break;
        default: 
		break;
	}

}
Exemplo n.º 7
0
void LCD_Config()//LCD配置
{
	LCD_Init();
	LCD_Reset();
	CS_0;//CS=0 打开片选
	Write_Reg(0x0000,0x0000);
	Write_Reg(0x0000,0x0000);
	Write_Reg(0x0000,0x0000);
	Write_Reg(0x0000,0x0000);
	DelayM(2);
	Write_DAT(0x0000);
	Write_DAT(0x0000);
	Write_DAT(0x0000);
	Write_DAT(0x0000);
	DelayM(2);
	Write_Reg(0x0008,0x0808);
	Write_Reg(0x0400,0x6200);
	
	Write_Reg(0x0300,0x0c0c);
	Write_Reg(0x0301,0xff13);
	Write_Reg(0x0302,0x0f0f);
	Write_Reg(0x0303,0x150b);
	Write_Reg(0x0304,0x1020);
	Write_Reg(0x0305,0x0a0b);
	Write_Reg(0x0306,0x0003);
	Write_Reg(0x0307,0x0d06);
	Write_Reg(0x0308,0x0504);
	Write_Reg(0x0309,0x1030);
	
	Write_Reg(0x0010,0x001b);
	Write_Reg(0x0011,0x0101);
	Write_Reg(0x0012,0x0000);
	Write_Reg(0x0013,0x0001);

	Write_Reg(0x0100,0x0330);
	Write_Reg(0x0101,0x0247);
	Write_Reg(0x0103,0x1000);
	Write_Reg(0x0280,0xbf00);
	Write_Reg(0x0102,0xd1b0);
	DelayM(5);
	Write_Reg(0x0001,0x0100);
	Write_Reg(0x0002,0x0100);
	Write_Reg(0x0003,0x1030);
	Write_Reg(0x0009,0x0001);
	Write_Reg(0x000c,0x0000);
	Write_Reg(0x0090,0x8000);
	Write_Reg(0x000f,0x0000);
	
	Write_Reg(0x0210,0x0000);
	Write_Reg(0x0211,0x00ef);
	Write_Reg(0x0212,0x0000);
	Write_Reg(0x0213,0x018f);
	
	Write_Reg(0x0500,0x0000);
	Write_Reg(0x0501,0x0000);
	Write_Reg(0x0502,0x005f);
	Write_Reg(0x0401,0x0001);
	Write_Reg(0x0404,0x0000);
	DelayM(2);
	Write_Reg(0x0007,0x0100);
	DelayM(5);
	Write_Reg(0x0200,0x0000);
	Write_Reg(0x0201,0x0000);
	DelayM(2);
	Write_COM(0x0202);
	DelayM(2);
	CS_1;
}
Exemplo n.º 8
0
void LCD_Init(void) 
{
  GPIO_InitTypeDef GPIO_InitStructure;
  FSMC_NORSRAMInitTypeDef  FSMC_NORSRAMInitStructure;
  FSMC_NORSRAMTimingInitTypeDef  p;

  //Enable the FSMC Clock
  RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE); 
  //Enable GPIOs clock
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE,ENABLE);
     
  //config tft data lines base on FSMC	
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
  
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_14| GPIO_Pin_15;
  GPIO_Init(GPIOD, &GPIO_InitStructure);

  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;
  GPIO_Init(GPIOE, &GPIO_InitStructure); 
    
  //config tft control lines base on FSMC
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_7 | GPIO_Pin_11; 
  GPIO_Init(GPIOD, &GPIO_InitStructure);
    
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_25MHz;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
    
  //config tft rst gpio
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; 	 
  GPIO_Init(GPIOD, &GPIO_InitStructure); 
   
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource0,GPIO_AF_FSMC);	                //配置GPIOD的Pin0复用连接到FSMC
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource1,GPIO_AF_FSMC);			//配置GPIOD的Pin1复用连接到FSMC
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource4,GPIO_AF_FSMC);			//配置GPIOD的Pin4复用连接到FSMC
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource5,GPIO_AF_FSMC);			//配置GPIOD的Pin5复用连接到FSMC
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource7,GPIO_AF_FSMC);			//配置GPIOD的Pin7复用连接到FSMC
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource11,GPIO_AF_FSMC);		//配置GPIOD的Pin11复用连接到FSMC
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource14,GPIO_AF_FSMC);		//配置GPIOD的Pin14复用连接到FSMC
  GPIO_PinAFConfig(GPIOD,GPIO_PinSource15,GPIO_AF_FSMC);		//配置GPIOD的Pin15复用连接到FSMC
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource7,GPIO_AF_FSMC);			//配置GPIOE的Pin7复用连接到FSMC
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource8,GPIO_AF_FSMC);			//配置GPIOE的Pin8复用连接到FSMC
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource9,GPIO_AF_FSMC);			//配置GPIOE的Pin9复用连接到FSMC
  GPIO_PinAFConfig(GPIOE,GPIO_PinSource10,GPIO_AF_FSMC);		//配置GPIOE的Pin10复用连接到FSMC
   
  p.FSMC_AddressSetupTime = 0x04;	        //地址建立时间
  p.FSMC_AddressHoldTime = 0x04;	        //地址保持时间
  p.FSMC_DataSetupTime = 0x04;  		//数据建立时间
  p.FSMC_BusTurnAroundDuration = 0x00;
  p.FSMC_CLKDivision = 0x00;
  p.FSMC_DataLatency = 0x00;
  p.FSMC_AccessMode = FSMC_AccessMode_B;	 // 一般使用模式B来控制LCD   

  FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
  FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
  FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
  FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
  FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
  FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
  FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
  FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
  FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
  FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
  FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
  FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p;
  FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; 
    
  FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); 
    
  //Enable FSMC Bank1_SRAM Bank
  FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);
  
  LCD_Reset();
  
  LCD_WriteCmd(0xe2);//system reset
  Delay(5);   
  LCD_WriteCmd(0xae);        
  LCD_WriteCmd(0xf8);   
  LCD_WriteCmd(0x00);
  LCD_WriteCmd(0xa2);
  LCD_WriteCmd(0xa0);
  LCD_WriteCmd(0xc0);
  LCD_WriteCmd(0xa6);
  LCD_WriteCmd(0xa4);
  LCD_WriteCmd(0xe0);
  LCD_WriteCmd(0xac);
  LCD_WriteCmd(0x00);
  LCD_WriteCmd(0x21);
  LCD_WriteCmd(0x81);
  LCD_WriteCmd(0x1e);        
  LCD_WriteCmd(0x2f);   
  LCD_WriteCmd(0x40);
  Delay(5);
  LCD_WriteCmd(0xaf);
  
  LCD_Screen = LCD_CreateBuffer(96,32);
}
Exemplo n.º 9
0
/********************************************************************************************************
*  Function: Driver_LcdReset				                                                           
*  Object: lcd reset control
*  Input: sta
*  Output: none                                  
*  brief: none
********************************************************************************************************/
void LCD_Init(void)
{ 
		//-- LCD PORT INIT --
		BSP_LCD_Init();
		//-- LCD RESET--
		LCD_Reset();
		//-------------- Initial Sequence ---------------
		//************* Start Initial Sequence **********//	
#if LCD_DIRECT == DIRECTION_V
		LCD_WriteReg(0xCF);  
		LCD_WriteData(0x00); 
		LCD_WriteData(0xC1); 
		LCD_WriteData(0X30); 
		LCD_WriteReg(0xED);  
		LCD_WriteData(0x64); 
		LCD_WriteData(0x03); 
		LCD_WriteData(0X12); 
		LCD_WriteData(0X81); 
		LCD_WriteReg(0xE8);  
		LCD_WriteData(0x85); 
		LCD_WriteData(0x10); 
		LCD_WriteData(0x7A); 
		LCD_WriteReg(0xCB);  
		LCD_WriteData(0x39); 
		LCD_WriteData(0x2C); 
		LCD_WriteData(0x00); 
		LCD_WriteData(0x34); 
		LCD_WriteData(0x02); 
		LCD_WriteReg(0xF7);  
		LCD_WriteData(0x20); 
		LCD_WriteReg(0xEA);  
		LCD_WriteData(0x00); 
		LCD_WriteData(0x00); 
		LCD_WriteReg(0xC0);    //Power control 
		LCD_WriteData(0x1B);   //VRH[5:0] 
		LCD_WriteReg(0xC1);    //Power control 
		LCD_WriteData(0x01);   //SAP[2:0];BT[3:0] 
		LCD_WriteReg(0xC5);    //VCM control 
		LCD_WriteData(0x30); 	 //3F
		LCD_WriteData(0x30); 	 //3C
		LCD_WriteReg(0xC7);    //VCM control2 
		LCD_WriteData(0XB7); 
		LCD_WriteReg(0x36);    // Memory Access Control 
		LCD_WriteData(0x48); 
		LCD_WriteReg(0x3A);   
		LCD_WriteData(0x55); 
		LCD_WriteReg(0xB1);   
		LCD_WriteData(0x00);   
		LCD_WriteData(0x1A); 
		LCD_WriteReg(0xB6);    // Display Function Control 
		LCD_WriteData(0x0A); 
		LCD_WriteData(0xA2); 
		LCD_WriteReg(0xF2);    // 3Gamma Function Disable 
		LCD_WriteData(0x00); 
		LCD_WriteReg(0x26);    //Gamma curve selected 
		LCD_WriteData(0x01); 
		LCD_WriteReg(0xE0);    //Set Gamma 
		LCD_WriteData(0x0F); 
		LCD_WriteData(0x2A); 
		LCD_WriteData(0x28); 
		LCD_WriteData(0x08); 
		LCD_WriteData(0x0E); 
		LCD_WriteData(0x08); 
		LCD_WriteData(0x54); 
		LCD_WriteData(0XA9); 
		LCD_WriteData(0x43); 
		LCD_WriteData(0x0A); 
		LCD_WriteData(0x0F); 
		LCD_WriteData(0x00); 
		LCD_WriteData(0x00); 
		LCD_WriteData(0x00); 
		LCD_WriteData(0x00); 		 
		LCD_WriteReg(0XE1);    //Set Gamma 
		LCD_WriteData(0x00); 
		LCD_WriteData(0x15); 
		LCD_WriteData(0x17); 
		LCD_WriteData(0x07); 
		LCD_WriteData(0x11); 
		LCD_WriteData(0x06); 
		LCD_WriteData(0x2B); 
		LCD_WriteData(0x56); 
		LCD_WriteData(0x3C); 
		LCD_WriteData(0x05); 
		LCD_WriteData(0x10); 
		LCD_WriteData(0x0F); 
		LCD_WriteData(0x3F); 
		LCD_WriteData(0x3F); 
		LCD_WriteData(0x0F); 
		LCD_WriteReg(0x2B); 
		LCD_WriteData(0x00);
		LCD_WriteData(0x00);
		LCD_WriteData(0x01);
		LCD_WriteData(0x3f);
		LCD_WriteReg(0x2A); 
		LCD_WriteData(0x00);
		LCD_WriteData(0x00);
		LCD_WriteData(0x00);
		LCD_WriteData(0xef);	 
		LCD_WriteReg(0x11); //Exit Sleep
		HAL_Delay(120);
		LCD_WriteReg(0x29); //display on
   	LCD_WriteReg(0x36);  
		LCD_WriteData(0xC9);	  
#else		
		LCD_WriteReg(0xCF);
		LCD_WriteData(0x00);
		LCD_WriteData(0x81);
		LCD_WriteData(0x30);
		LCD_WriteReg(0xED);
		LCD_WriteData(0x64);
		LCD_WriteData(0x03);
		LCD_WriteData(0x12);
		LCD_WriteData(0x81);
		LCD_WriteReg(0xE8);
		LCD_WriteData(0x85);
		LCD_WriteData(0x10);
		LCD_WriteData(0x78);
		LCD_WriteReg(0xCB);
		LCD_WriteData(0x39);
		LCD_WriteData(0x2C);
		LCD_WriteData(0x00);
		LCD_WriteData(0x34);
		LCD_WriteData(0x02);
		LCD_WriteReg(0xF7);
		LCD_WriteData(0x20);
		LCD_WriteReg(0xEA);
		LCD_WriteData(0x00);
		LCD_WriteData(0x00);
		LCD_WriteReg(0xB1);
		LCD_WriteData(0x00);
		LCD_WriteData(0x1B);
		LCD_WriteReg(0xB6);
		LCD_WriteData(0x0A);
		LCD_WriteData(0xA2);
		LCD_WriteReg(0xC0);
		LCD_WriteData(0x35);
		LCD_WriteReg(0xC1);
		LCD_WriteData(0x11);
		LCD_WriteReg(0xC5);
		LCD_WriteData(0x45);
		LCD_WriteData(0x45);
		LCD_WriteReg(0xC7);
		LCD_WriteData(0xA2);
		LCD_WriteReg(0xF2);
		LCD_WriteData(0x00);
		LCD_WriteReg(0x26);
		LCD_WriteData(0x01);
		LCD_WriteReg(0xE0);
		LCD_WriteData(0x0F);
		LCD_WriteData(0x26);
		LCD_WriteData(0x24);
		LCD_WriteData(0x0B);
		LCD_WriteData(0x0E);
		LCD_WriteData(0x09);
		LCD_WriteData(0x54);
		LCD_WriteData(0xA8);
		LCD_WriteData(0x46);
		LCD_WriteData(0x0C);
		LCD_WriteData(0x17);
		LCD_WriteData(0x09);
		LCD_WriteData(0x0F);
		LCD_WriteData(0x07);
		LCD_WriteData(0x00);
		LCD_WriteReg(0xE1);
		LCD_WriteData(0x00);
		LCD_WriteData(0x19);
		LCD_WriteData(0x1B);
		LCD_WriteData(0x04);
		LCD_WriteData(0x10);
		LCD_WriteData(0x07);
		LCD_WriteData(0x2A);
		LCD_WriteData(0x47);
		LCD_WriteData(0x39);
		LCD_WriteData(0x03);
		LCD_WriteData(0x06);
		LCD_WriteData(0x06);
		LCD_WriteData(0x30);
		LCD_WriteData(0x38);
		LCD_WriteData(0x0F);
		LCD_WriteReg(0x36);     //set the model of scanning
		LCD_WriteData((1<<5)|(0<<6)|(1<<7)|(1<<3)); //???
		//LCD_WriteData((1<<5)|(1<<6));????
		//LCD_WriteData(0x08); ???
		LCD_WriteReg(0x2B);     //set the page address ?????
		LCD_WriteData(0x00);
		LCD_WriteData(0x00);
		LCD_WriteData(0x00);
		LCD_WriteData(0xEF);
		LCD_WriteReg(0x2A);    //set the column address
		LCD_WriteData(0x00);
		LCD_WriteData(0x00);
		LCD_WriteData(0x01);
		LCD_WriteData(0x3F);
		//        LCD_WriteReg(0x2A);     //set the page address ?????
		//        LCD_WriteData(0x00);
		//        LCD_WriteData(0x00);
		//        LCD_WriteData(0x00);
		//        LCD_WriteData(0xEF);
		//        LCD_WriteReg(0x2B);    //set the column address
		//        LCD_WriteData(0x00);
		//        LCD_WriteData(0x00);
		//        LCD_WriteData(0x01);
		//        LCD_WriteData(0x3F);        
		LCD_WriteReg(0x3A);
		LCD_WriteData(0x55); //16pixel
		LCD_WriteReg(0x11);
		HAL_Delay(120);
		LCD_WriteReg(0x29);
		LCD_WriteReg(0x2C);
#endif
}
Exemplo n.º 10
0
void st7783_Init(void)
{    
//  uint16_t data = 0;
  
//	m_width     = TFTWIDTH;
//	m_height    = TFTHEIGHT;
    m_height    = TFTWIDTH;
		m_width     = TFTHEIGHT;
	
	//m_rotation  = 0;
	m_rotation  = 1;
	m_cursor_y  = m_cursor_x    = 0;
	m_textsize  = 4;
	m_textcolor = m_textbgcolor = 0xFFFF;
	m_wrap      = 1;
  /* Initialize st7783 low level bus layer -----------------------------------*/
  LCD_IO_Init();
	LCD_Reset();
	
//LCD_WriteRegister16(0xff00, 0x8844);            //test data
	
  LCD_WriteRegister16(0x0001, 0x0100); 
	LCD_WriteRegister16(0x0002, 0x0700);
	LCD_WriteRegister16(0x0003, 0x1030);
	LCD_WriteRegister16(0x0008, 0x0302);
	LCD_WriteRegister16(0x0009, 0x0000);
	LCD_WriteRegister16(0x000A, 0x0008);
	
	//*******POWER CONTROL REGISTER INITIAL*******//
	LCD_WriteRegister16(0x0010, 0x0790);
	LCD_WriteRegister16(0x0011, 0x0005);
	LCD_WriteRegister16(0x0012, 0x0000);
	LCD_WriteRegister16(0x0013, 0x0000);
	//delay
	//HAL_Delay(10);
	//********POWER SUPPPLY STARTUP 1 SETTING*******//
	LCD_WriteRegister16(0x0010, 0x12B0);
	LCD_WriteRegister16(0x0011, 0x0007);
	//delay
	//HAL_Delay(10);
	//********POWER SUPPLY STARTUP 2 SETTING******//
	LCD_WriteRegister16(0x0012, 0x008c);
	LCD_WriteRegister16(0x0013, 0x1700);
	LCD_WriteRegister16(0x0029, 0x0022);
	//delay
	//HAL_Delay(10);
	//******GAMMA CLUSTER SETTING******//
	//LCD_WriteRegister16(0x0020, 0x0000);
	//LCD_WriteRegister16(0x0021, 0x0000);
	
	LCD_WriteRegister16(0x0030, 0x0000);
	LCD_WriteRegister16(0x0031, 0x0505);
	LCD_WriteRegister16(0x0032, 0x0205);
	LCD_WriteRegister16(0x0035, 0x0206);
	LCD_WriteRegister16(0x0036, 0x0408);
	LCD_WriteRegister16(0x0037, 0x0000);
	LCD_WriteRegister16(0x0038, 0x0504);
	LCD_WriteRegister16(0x0039, 0x0206);
	LCD_WriteRegister16(0x003C, 0x0206);
	LCD_WriteRegister16(0x003D, 0x0408);
	
	// -----------DISPLAY WINDOWS 240*320-------------//
	LCD_WriteRegister16(0x0050, 0x0000);
	LCD_WriteRegister16(0x0051, 0x00EF);
	LCD_WriteRegister16(0x0052, 0x0000);
	LCD_WriteRegister16(0x0053, 0x013F);
	//-----FRAME RATE SETTING-------//
	LCD_WriteRegister16(0x0060, 0xA700);
	LCD_WriteRegister16(0x0061, 0x0001);
	LCD_WriteRegister16(0x0090, 0x0033);//RTNI setting
	//-------DISPLAY ON------//
	LCD_WriteRegister16(0x0007, 0x0133);

	LCD_WriteRegister16(0x0001, 0x0100); 
	LCD_WriteRegister16(0x0002, 0x0700);
	LCD_WriteRegister16(0x0003, 0x1030);
	LCD_WriteRegister16(0x0008, 0x0302);
	LCD_WriteRegister16(0x0009, 0x0000);
	LCD_WriteRegister16(0x000A, 0x0008);
	
	//*******POWER CONTROL REGISTER INITIAL*******//
// 	LCD_WriteRegister16(0x0010, 0x0790);
// 	LCD_WriteRegister16(0x0011, 0x0005);
// 	LCD_WriteRegister16(0x0012, 0x0000);
// 	LCD_WriteRegister16(0x0013, 0x0000);
// 	//delay
	//HAL_Delay(10);
	//********POWER SUPPPLY STARTUP 1 SETTING*******//
	LCD_WriteRegister16(0x0010, 0x12B0);
	LCD_WriteRegister16(0x0011, 0x0007);
	//delay
	//HAL_Delay(10);
	//********POWER SUPPLY STARTUP 2 SETTING******//
	LCD_WriteRegister16(0x0012, 0x008c);
	LCD_WriteRegister16(0x0013, 0x1700);
	LCD_WriteRegister16(0x0029, 0x0022);
	//delay
	//HAL_Delay(10);
	//******GAMMA CLUSTER SETTING******//
	//LCD_WriteRegister16(0x0020, 0x0000);
	//LCD_WriteRegister16(0x0021, 0x0000);
	
	LCD_WriteRegister16(0x0030, 0x0000);
	LCD_WriteRegister16(0x0031, 0x0505);
	LCD_WriteRegister16(0x0032, 0x0205);
	LCD_WriteRegister16(0x0035, 0x0206);
	LCD_WriteRegister16(0x0036, 0x0408);
	LCD_WriteRegister16(0x0037, 0x0000);
	LCD_WriteRegister16(0x0038, 0x0504);
	LCD_WriteRegister16(0x0039, 0x0206);
	LCD_WriteRegister16(0x003C, 0x0206);
	LCD_WriteRegister16(0x003D, 0x0408);
	
	// -----------DISPLAY WINDOWS 240*320-------------//
	LCD_WriteRegister16(0x0050, 0x0000);
	LCD_WriteRegister16(0x0051, 0x00EF);
	LCD_WriteRegister16(0x0052, 0x0000);
	LCD_WriteRegister16(0x0053, 0x013F);
	//-----FRAME RATE SETTING-------//
	LCD_WriteRegister16(0x0060, 0xA700);
	LCD_WriteRegister16(0x0061, 0x0001);
	LCD_WriteRegister16(0x0090, 0x0033);//RTNI setting
	//-------DISPLAY ON------//
	LCD_WriteRegister16(0x0007, 0x0133);
	
	LCD_WriteRegister16(0x0020, 0x0000);
	LCD_WriteRegister16(0x0021, 0x0000);

	
}