示例#1
0
//*******************************************
//*函数名称:void LCD_CheckBusy(void)	*
//*函数功能:并行方式查忙					*
//*形式参数:无								*
//*形参说明:无								*
//*返回参数:无								*
//*使用说明:无								*
//*******************************************
void LCD_CheckBusy(void)
{
#if PARALLEL == 1
	unsigned char temp;
	LCD_DATA_IN();	//P1 = 0xff;	//输入前置1
	LCD_RS_LOW();	//RS = 0;		//指令
	LCD_RW_HIGH();	//RW = 1;		//读模式
	_delay_us(5);	//延时
	LCD_E_HIGH();	//E  = 1;	 //使能
	do
	{	
		temp = LCD_DATA_GET();	//temp = BUSY;
	}
  	while( 0x80==(temp&0x80) );	//等待不忙,temp=0x00时不忙
	
	LCD_E_LOW();	//E  = 0;
	//_delay_ms(20);
#else
	unsigned char temp = 0xFC,temp2;
	do
	{
		LCD_SendByte(temp);
		temp = LCD_ReceiveByte();
		temp2 = LCD_ReceiveByte();
		temp &= 0x80;
	}while( temp==0x80 );
#endif	//#if PARALLEL == 1
}
示例#2
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_CMD(unsigned char data)
{
	LCD_E_LOW();
	LCD_RS_LOW();
	LCD_DATA(data);
	LCD_E_HIGH();
	tme_tempo(1);
	LCD_E_LOW();	
}
示例#4
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);
}
示例#5
0
文件: Lcd.c 项目: CobooGuo/DSO_Nano
/*******************************************************************************
 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
}
示例#6
0
文件: Lcd.c 项目: CobooGuo/DSO_Nano
/*******************************************************************************
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: HD44780WrComm
 * Parameters: Int8U Command
 * Return: none
 * Description: Send command to HD44780
 *
 *************************************************************************/
static void HD44780WrComm (Int8U Command)
{
  LCD_RS_LOW();
#if HD44780_BUS_WIDTH == 8
  HD44780WrIO(Command);
#else
  HD44780WrIO((Command >> 4) & 0xF);
  HD44780WrIO(Command & 0xF);
#endif
}
/*************************************************************************
 * Function Name: HD44780RdStatus
 * Parameters: none
 * Return: Int8U
 * Description: Read status of HD44780
 *
 *************************************************************************/
static Int8U HD44780RdStatus (void)
{
Int8U Data;
  LCD_RS_LOW();
#if HD44780_BUS_WIDTH == 8
  Data = HD44780RdIO();
#else
  Data = (HD44780RdIO() << 4) & 0xF0;
  Data |= HD44780RdIO()       & 0x0F;
#endif
  return Data;
}
示例#9
0
void lcd_write_cmd(unsigned char cmd)
{   
    OS_CPU_SR_ALLOC();
    

    OS_ENTER_CRITICAL();
    
    LCD_RS_LOW();
    LCD_CS_LOW();
    lcd_send_byte(cmd);
    LCD_CS_HIGH();

    OS_EXIT_CRITICAL();
}
示例#10
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												
}
示例#11
0
文件: Lcd1.c 项目: xjtuecho/MiniDSO
/*******************************************************************************
 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.
}
示例#12
0
static void LCD_COM(uint8_t cmd)
{
    LCD_RS_LOW();
    spi_write(&device, &cmd, 1, true);
}
示例#13
0
文件: Lcd.c 项目: CobooGuo/DSO_Nano
/*******************************************************************************
 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
}
/*************************************************************************
 * Function Name: HD44780_Init
 * Parameters: none
 * Return: HD44780_ERROR_CODE_DEF
 *         HD44780_OK  0: Pass
 *     HD44780_ERROR 1: Busy check Time Out
 * Description: Init HD44780 after power-up
 *
 *************************************************************************/
HD44780_ERROR_CODE_DEF HD44780_PowerUpInit (void)
{
Int8U Command;
  HD4478_Ctrl.DisplayPos = 0;
  /* Init MCU IO */
  HD44780SetPU();
  /* Power up init sequence */
  DelayResolution100us(HD44780_POWER_UP_DLY);
  LCD_RS_LOW();
  HD44780WrComm_High(HD44780_FUNCTION_SET+HD44780_FUNCTION_SET_8_BIT);
  DelayResolution100us(HD44780_FIRST_COMM_DLY);
  HD44780WrComm_High(HD44780_FUNCTION_SET+HD44780_FUNCTION_SET_8_BIT);
  DelayResolution100us(HD44780_SECOND_COMM_DLY);
  HD44780WrComm_High(HD44780_FUNCTION_SET+HD44780_FUNCTION_SET_8_BIT);
  DelayResolution100us(HD44780_SECOND_COMM_DLY);
  /* Display Function set */
#if HD44780_BUS_WIDTH == 8
  Command = HD44780_FUNCTION_SET + HD44780_FUNCTION_SET_8_BIT;
#else
  HD44780WrComm_High(HD44780_FUNCTION_SET + HD44780_FUNCTION_SET_4_BIT);
  DelayResolution100us(HD44780_SECOND_COMM_DLY);
  Command = HD44780_FUNCTION_SET + HD44780_FUNCTION_SET_4_BIT;
#endif
  if (HD4478_Ctrl.Line)
  {
    Command |= HD44780_FUNCTION_SET_2_LINE;
  }
  if (HD4478_Ctrl.DotMode)
  {
    Command |= HD44780_FUNCTION_SET_DOT_5_10;
  }
  HD44780WrComm(Command);
  if (HD44780_BusyCheck(NULL,HD44780_SECOND_COMM_DLY) != HD44780_OK)
  {
    return HD44780_ERROR;
  }
  /* Display off */
  HD44780WrComm(HD44780_DISPLAY_CTRL);
  if (HD44780_BusyCheck(NULL,HD44780_MAX_COMM_DLY) != HD44780_OK)
  {
    return HD44780_ERROR;
  }
  /* Display clear */
  if (HD44780_ClearDisplay() != HD44780_OK)
  {
    return HD44780_ERROR;
  }
#if HD4780_WR == 0
  DataRamAddHold = 0;
#endif
  /* Set entry mode */
  Command = HD44780_ENTRY_MODE;
  if (HD4478_Ctrl.AC_Direction)
  {
    Command |= HD44780_ENTRY_MODE_INC;
  }
  if (HD4478_Ctrl.DisplayShift)
  {
    Command |= HD44780_ENTRY_MODE_BOTH_S;
  }
  /* Set Display and cursor mode */
  if (HD44780_SetMode() != HD44780_OK)
  {
    return HD44780_ERROR;
  }
  return HD44780_OK;
}