Ejemplo n.º 1
0
Archivo: lcd.c Proyecto: epffpe/Atmel
static inline unsigned short rd_dat (void) {
  unsigned short val = 0;

  LCD_RS(1)
  LCD_WR(1)
  //LCD_RD(0);
  val = lcd_read();
  //LCD_RD(1);
  return val;
}
Ejemplo n.º 2
0
/**
 * Waits until busy flag of LCD is cleared
 */
static void lcdBusyWait() {
	LCD_RW(1);
    LCD_RS(0);
    LCD_DATA_DDR = 0x00;			/* input */
	delay_us(LCD_DELAY_SHORT);		/* RS, RW Setup Time (Minimum: 60ns) */
	lcdToggleEn();

    loop_until_bit_is_clear(LCD_DATA_PIN,LCD_BUSY_FLAG);
    lcdToggleEn();
}
Ejemplo n.º 3
0
/**
 * Writes instructions to the LCD
 * 
 * Inputs: 	db		LCD instruction
 *		    	rs		for commands, rs = 0
 *			    		for sending data, rs = 1
 */
static void lcdWrite(BYTE db, BYTE rs) {
    lcdBusyWait();

	LCD_RW(0);
    LCD_RS(rs);
    LCD_DATA_DDR = 0xFF;		/* output */
   	LCD_DATA_PORT = db;
	delay_us(LCD_DELAY_EN);	    /* RS, RW Setup Time (Minimum: 60ns) */
	lcdToggleEn();
}
Ejemplo n.º 4
0
static void SendStartByte( unsigned char RW, unsigned char RS)
{
#define LCD_DEV_ID(v) (v<<2)
#define LCD_RS(v)     (v<<1)
#define LCD_RW(v)     (v<<0)

    unsigned char StartByte = 0x70;
    StartByte |= (LCD_DEV_ID(0) | LCD_RS(RS) | LCD_RW(RW)); 
    SendByte( StartByte);
    
}
Ejemplo n.º 5
0
//写指令
void WriteCommandLCD(unsigned char WCLCD) //BuysC为0时忽略忙检测
{
 ReadStatusLCD(); //根据需要检测忙 
 LCD_RS(0);
 LCD_RW(0);
 LCD_EN(0);
 Delay_us(1);
 LCD_WriteData(WCLCD);
 LCD_EN(1);
 Delay_us(1);
 LCD_EN(0); 
}
Ejemplo n.º 6
0
//写数据
void WriteDataLCD(unsigned char WDLCD)
{
	ReadStatusLCD(); //检测忙 
	LCD_RS(1);
	LCD_RW(0);
	LCD_EN(0);
	Delay_us(1);
	LCD_WriteData(WDLCD);
	LCD_EN(1);
	Delay_us(1);
	LCD_EN(0);
}
Ejemplo n.º 7
0
uint8_t
LCD_read(uint8_t RS)
{
    volatile uint8_t buf = 0;
    LCD_DATA_PORT->DIR &= ~(0xF0);
    LCD_RS(RS);
    LCD_RW(1);    
    LCD_EN(1);
    LCD_EN(0);
    buf = LCD_DATA_PORT->DATA & 0xF0;
    LCD_EN(1);
    LCD_EN(0);
    buf |= LCD_DATA_PORT->DATA >> 4;
    return buf;
}
Ejemplo n.º 8
0
void
__LCD_write(uint8_t RS,uint8_t data,uint8_t wait){
    LCD_DATA_PORT->DIR |= 0xF0;
    LCD_RS(RS);
    LCD_RW(0);    
    LCD_DATA_PORT->DATA = (LCD_CONTROL_PORT->DATA & ~(0xF0))|(data&0xF0);
    LCD_EN(1);
    LCD_EN(0);
    data <<=4;   
    LCD_DATA_PORT->DATA = (LCD_CONTROL_PORT->DATA & ~(0xF0))|(data&0xF0);
    LCD_EN(1);
    LCD_EN(0);
    if(wait){
        while(LCD_read(0) & 0x80);
    }
}
Ejemplo n.º 9
0
//读状态
void ReadStatusLCD(void)
{ 
 unsigned char  lcd_status;
 
 LCD_RS(0);
 LCD_RW(1); 
 LCD_Data_In();
 do
 {
  LCD_EN(1);
  Delay_us(1);
  lcd_status=GPIO_ReadInputData( LCD12864_GPIO);
  LCD_EN(0);
  }
  while (lcd_status&Busy); //检测忙信号
  LCD_Data_Out(); 
}
Ejemplo n.º 10
0
Archivo: lcd.c Proyecto: epffpe/Atmel
static inline void wr_dat (unsigned short c) {

  LCD_RS(1)
  LCD_RD(1)
  lcd_send(c);
}
Ejemplo n.º 11
0
Archivo: lcd.c Proyecto: epffpe/Atmel
static inline void wr_cmd (unsigned char c) {

  LCD_RS(0)
  LCD_RD(1)
  lcd_send(c);
}
Ejemplo n.º 12
0
Archivo: lcd.c Proyecto: epffpe/Atmel
  LCD_WR(1)
  //LCD_RD(0);
  val = lcd_read();
  //LCD_RD(1);
  return val;
}

/*******************************************************************************
* Start of data writing to LCD controller                                      *
*   Parameter:                                                                 *
*   Return:                                                                    *
*******************************************************************************/

static inline void wr_dat_start (void) {

  LCD_RS(1)
}


/*******************************************************************************
* Stop of data writing to LCD controller                                       *
*   Parameter:                                                                 *
*   Return:                                                                    *
*******************************************************************************/

static inline void wr_dat_stop (void) {

  LCD_CS(1)
}

Ejemplo n.º 13
0
/**********************************************
Lcd初始化函数
Initial condition  (DB0-15,RS,CSB,WRD,RDB,RESETB="L") 
***********************************************/
void Lcd_Initialize(void)
{	
int i;
SPI_CS(1);

WriteComm(0x0001);
Delay(100);
SPI_CS(0);
WriteComm(0x0011);
Delay(20);
WriteComm(0x00D0);    
WriteData(0x0007); 
WriteData(0x0041); 
WriteData(0x001C); 
 
WriteComm(0x00D1);    
WriteData(0x0000); 
WriteData(0x0036); //30 vcm
WriteData(0x001B); //15 vdv

                                                                 
WriteComm(0x00D2);
WriteData(0x0001);   // AP0[2:0]
WriteData(0x0011);   // DC10[2:0],DC00[2:0]
  
WriteComm(0x00C0);     //****** *******
WriteData(0x0010);   // REV & SM & GS
WriteData(0x003B);   // NL[5:0]
WriteData(0x0000);   // SCN[6:0]
WriteData(0x0012);   //02  NDL , PTS[2:0]
WriteData(0x0001);   //11 PTG , ISC[3:0]  
  
WriteComm(0x00C5);    
WriteData(0x0003);


WriteComm(0x00C8);
WriteData(0x0000);
WriteData(0x0057);
WriteData(0x0033);
WriteData(0x0000);
WriteData(0x0000);
WriteData(0x0000);
WriteData(0x0044);
WriteData(0x0002);
WriteData(0x0077);
WriteData(0x0000);
WriteData(0x0000);
WriteData(0x0000);
 
  
WriteComm(0x00F8);
WriteData(0x0001);
  
WriteComm(0x00FE);
WriteData(0x0000);
WriteData(0x0002);
  
WriteComm(0x0036);   // Set_address_mode
WriteData(0x000A);  // Bit3: RGB/BGR
Delay(20);
WriteComm(0x003a);   // Set_address_mode
WriteData(0x0055);  //05---16BIT,06---18BIT  
Delay(20);  

WriteComm(0x0029); 

Delay(10);
	WriteComm(0x36); //Set_address_mode
 	WriteData(0x68); //横屏,从左下角开始,从左到右,从下到上

Lcd_Light_ON;

// while(1)
{
WriteComm(0x36);//竖屏
WriteData(0x48);//
// 	while(!(SPI1->SR&0x0002));
for(i=0;i<320*480;i++)
{
	LCD_RS(1);
	SPI_I2S_SendData(SPI1, COLOR_BLUE>>8);
	LCD_RS(1);
	SPI_I2S_SendData(SPI1, COLOR_BLUE);
}
for(i=0;i<320*480;i++)
{
	LCD_RS(1);
	SPI_I2S_SendData(SPI1, COLOR_YELLOW>>8);
	LCD_RS(1);
	SPI_I2S_SendData(SPI1, COLOR_YELLOW);
}

WriteComm(0x36);
WriteData(0x28);//
}

}
Ejemplo n.º 14
0
  WriteData(u16 tem_data)
{			
	LCD_RS(1);
	SPI_I2S_SendData(SPI1, tem_data);
}
Ejemplo n.º 15
0
 void WriteComm(u16 CMD)
{			
	LCD_RS(0);
	SPI_I2S_SendData(SPI1, CMD);
}