Esempio n. 1
0
// Write a command word
void lcd_write_cmd(int command)
{
    lcd_dma_ready();
    LCD_RS_LOW();
    lcd_write(command);
    lcd_dma_ready();
    LCD_RS_HIGH();
}
void LCD_CHAR(unsigned char data)
{
	LCD_E_LOW();
	LCD_RS_HIGH();
	LCD_DATA(data);
	LCD_E_HIGH();
	tme_tempo(1);
	LCD_E_LOW();
}
Esempio n. 3
0
// Write register
void lcd_write_reg(int reg, int command)
{
    lcd_dma_ready();
    LCD_RS_LOW();
    lcd_write(reg);
    lcd_dma_ready();
    LCD_RS_HIGH();
    lcd_write(command);
}
Esempio n. 4
0
/*******************************************************************************
 LCD_WR_REG: Set LCD Register  Input: Register addr., Data
*******************************************************************************/
void LCD_WR_REG(unsigned short Reg, unsigned short Data) 
{
  LDC_DATA_OUT=Reg;     //Reg. Addr.
  LCD_RS_LOW();         //RS=0,Piont to Index Reg.
  LCD_nWR_ACT();        //WR Cycle from 1 -> 0 -> 1
  LCD_RS_HIGH();        //RS=1,Piont to object Reg.
  LDC_DATA_OUT=Data;    //Reg. Data 
  LCD_nWR_ACT();        //WR Cycle from 1 -> 0 -> 1
}
Esempio n. 5
0
/*******************************************************************************
Point_SCR: Set display position   Input: X, Y 
*******************************************************************************/
void Point_SCR(unsigned short x0, unsigned short y0) 
{
  LCD_WR_REG(0x0020,y0);
  LCD_WR_REG(0x0021,x0);
  LDC_DATA_OUT=0x0022;  //DRAM Reg.      
  LCD_RS_LOW();             
  LCD_nWR_ACT();        //WR Cycle from 1 -> 0 -> 1
  LCD_nWR_ACT();        //WR Cycle from 1 -> 0 -> 1
  LCD_RS_HIGH();            
}
/*************************************************************************
 * Function Name: HD44780WrData
 * Parameters: Int8U Data
 * Return: none
 * Description: Write data to HD44780
 *
 *************************************************************************/
static void HD44780WrData (Int8U Data)
{
  LCD_RS_HIGH();
#if HD44780_BUS_WIDTH == 8
  HD44780WrIO(Data);
#else
  HD44780WrIO((Data>>4) & 0xF);
  HD44780WrIO(Data & 0xF);
#endif
}
/*************************************************************************
 * Function Name: HD44780RdData
 * Parameters: none
 * Return: Int8U
 * Description: Read data from HD44780
 *
 *************************************************************************/
static Int8U HD44780RdData (void)
{
Int8U Data;
  LCD_RS_HIGH();
#if HD44780_BUS_WIDTH == 8
  Data = HD44780RdIO();
#else
  Data = (HD44780RdIO() << 4) & 0xF0;
  Data |= HD44780RdIO()       & 0x0F;
#endif
  return Data;
}
Esempio n. 8
0
void lcd_write_data(unsigned char data)
{	
    OS_CPU_SR_ALLOC();
    

    OS_ENTER_CRITICAL();
    
    LCD_RS_HIGH();
    LCD_CS_LOW();
    lcd_send_byte(data);
    LCD_CS_HIGH();

    OS_EXIT_CRITICAL();
}
Esempio n. 9
0
//************************************************************************************
//*函数名称:void LCD_Write(unsigned char Data_Command , unsigned char uc_Content ) *
//*函数功能:并行模式向LCD发送数据或指令												 *
//*形式参数:unsigned char Data_Command , unsigned char uc_Content					 *
//*形参说明:数据或指令的标志位,指令或数据的内容										 *
//*返回参数:无																		 *
//*使用说明:无																		 *
//************************************************************************************
void LCD_Write( unsigned char Data_Command , unsigned char uc_Content )
{ 
#if PARALLEL == 1

	LCD_CheckBusy();
	LCD_DATA_OUT();

	if(Data_Command)
	{
		LCD_RS_HIGH();	//RS = 1;   //数据
		//LCD_RW_LOW();	//RW = 0;   //写模式
	}
	else 
	{
		LCD_RS_LOW();	//RS = 0;	//指令
		//LCD_RW_LOW();	//RW = 0;   //写模式
	}
	LCD_RW_LOW();		//RW = 0;   //写模式

  	LCD_DATA_PORT = uc_Content;//数据放到P1口上
  	LCD_E_HIGH();	//E = 1;
	_delay_us(1);	//延时
  	//_nop_();//很重要 
	//_nop_();
   	//_nop_();
    LCD_E_LOW();	//E = 0;		
#else
	unsigned char temp;

	LCD_CheckBusy();
	
	if(Data_Command)
	{
		temp = 0xFA;	//RS = 1,数据; RW = 0,写模式
	}
	else 
	{
		temp = 0xF8;	//RS = 0,指令; RW = 0,写模式
	}
	LCD_SendByte(temp);

	temp = uc_Content&0xF0;
	LCD_SendByte(temp);

	temp = (uc_Content<<4)&0xF0;
	LCD_SendByte(temp);
#endif	//#if PARALLEL == 1												
}
Esempio n. 10
0
/*******************************************************************************
 LCD_SET_WINDOW: 设置LCD模块上指定的窗口位置。 输入: x0、x1、y0、y1
*******************************************************************************/
void LCD_SET_WINDOW(short x1, short x2,short y1, short y2) 
{
  __LCD_WR_REG(0x0050, y1);
  __LCD_WR_REG(0x0051, y2);
  __LCD_WR_REG(0x0052, x1);
  __LCD_WR_REG(0x0053, x2);
  
  __LCD_WR_REG(0x0020, y1);
  __LCD_WR_REG(0x0021, x1);
  
  LDC_DATA_OUT=0x0022;      //Reg. Addr.
  LCD_RS_LOW();             //RS=0,Piont to Index Reg.
  LCD_nWR_ACT();            //WR Cycle from 1 -> 0 -> 1
  LCD_nWR_ACT();            //WR Cycle from 1 -> 0 -> 1
  LCD_RS_HIGH();            //RS=1,Piont to object Reg.
}
Esempio n. 11
0
//********************************************
//*函数名称:LCD_ReadData		 *
//*函数功能:并行读LCD数据					 *
//*形式参数:无								 *
//*形参说明:无								 *
//*返回参数:读回的数据						 *
//*使用说明:无								 *
//********************************************
unsigned char LCD_ReadData(void)
{
#if PARALLEL == 1
 	unsigned char uc_Content;
	LCD_CheckBusy();
	//_delay_us(2);

	LCD_DATA_IN();	//P1 = 0xff;//输入前置1
    LCD_RS_HIGH();	//RS = 1;   //数据
    LCD_RW_HIGH();	//RW = 1;	//读模式

  	LCD_E_HIGH();	//E = 1;	//使能
	_delay_us(1);	//延时很重要 
  	uc_Content = LCD_DATA_GET();	//uc_Content = P1;    //P1口的内容放到变量中
  	LCD_E_LOW();	//E = 0;

	_delay_us(1);	//延时很重要 

	return uc_Content;
#endif	//#if PARALLEL == 1
}
Esempio n. 12
0
static void LCD_DATA(uint8_t data)
{
    LCD_RS_HIGH();
    spi_write(&device, &data, 1, true);
}
Esempio n. 13
0
/*******************************************************************************
 LCD  initializtion 
*******************************************************************************/
void LCD_Initial(void)
{   
  //------------------------- Reset LCD Driver ---------------------//
  LCD_DATA_BUS_OUT();   //Set LCD Data Bus as Output Mode
  LCD_nWR_HIGH();
  LCD_nRD_HIGH();       
  LCD_RS_HIGH();        //RS=1        
  LCD_nRST_HIGH(); 
  Delayms(1);           //RST=1£¬Delay 1ms      
  LCD_nRST_LOW(); 
  Delayms(1);          //RST=0 Reset LCD£¬Delay 1ms      
  LCD_nRST_HIGH(); 
  Delayms(5);          //RST=1£¬Delay 5 ms  
 //----------------ST7781 Internal Register Initial------------//         
  LCD_WR_REG(0x00FF, 0x0001);  
  LCD_WR_REG(0x00F3, 0x0008);  
  LDC_DATA_OUT=0x00F3;     
  LCD_RS_LOW();         
  LCD_nWR_ACT();       //Read Parameter      
  LCD_RS_HIGH();        
 //-------------------Display Control Setting-----------------//
  LCD_WR_REG(0x0001, 0x0100);    //Output Direct 
  LCD_WR_REG(0x0002, 0x0700);    //Line Inversion
  LCD_WR_REG(0x0003, 0x0030);    //BGR=0,ID=11
  LCD_WR_REG(0x0008, 0x0302);    //Porch Setting
  LCD_WR_REG(0x0009, 0x0000);    //Scan Cycle
  LCD_WR_REG(0x000A, 0x0000);    //FMARK off
 //----------------power Control Register Initial------------//
  LCD_WR_REG(0x0010, 0x0790);    //Power Control1
  LCD_WR_REG(0x0011, 0x0005);    //Power Control2
  LCD_WR_REG(0x0012, 0x0000);    //Power Control3
  LCD_WR_REG(0x0013, 0x0000);    //Power Control4
  Delayms(100);                  //Delay 100ms   
  LCD_WR_REG(0x0010, 0x12B0);    //Power Control1
  Delayms(50);                   //delay 50ms
  LCD_WR_REG(0x0011, 0x0007);    //Power Control2
  Delayms(50);                   //delay 50ms
  LCD_WR_REG(0x0012, 0x008C);    //Power Control3
  LCD_WR_REG(0x0013, 0x1700);    //Power Control4
  LCD_WR_REG(0x0029, 0x001A);    //VCOMH Setting
  Delayms(50);                   //delay 50ms
 //------------------GAMMA Cluster Setting-------------------//
  LCD_WR_REG(0x0030, 0x0000);
  LCD_WR_REG(0x0031, 0x0507);
  LCD_WR_REG(0x0032, 0x0003);
  LCD_WR_REG(0x0035, 0x0200);
  LCD_WR_REG(0x0036, 0x0106);
  LCD_WR_REG(0x0037, 0x0000);
  LCD_WR_REG(0x0038, 0x0507);
  LCD_WR_REG(0x0039, 0x0104);
  LCD_WR_REG(0x003C, 0x0200);
  LCD_WR_REG(0x003D, 0x0005);
 //------------------Display Windows 240*320-----------------//
  LCD_WR_REG(0x0050, 0x0000);
  LCD_WR_REG(0x0051, 0x00EF);
  LCD_WR_REG(0x0052, 0x0000);
  LCD_WR_REG(0x0053, 0x013F);
 //--------------------Frame Rate Setting--------------------//
  LCD_WR_REG(0x0060, 0xA700);
  LCD_WR_REG(0x0061, 0x0001);
  LCD_WR_REG(0x0090, 0x0033);
  LCD_WR_REG(0x0007, 0x0133);
  Delayms(50);                   //delay 50ms
}