hd44780.c
/*************************************************************************
Low-level function to write byte to LCD controller
Input:    data   byte to write to LCD
          rs     1: write data
                 0: write instruction
Returns:  none
*************************************************************************/
Low-level function to write byte to LCD controller
Input:    data   byte to write to LCD
rs     1: write data
0: write instruction
Returns:  none
Low - level function to write byte to LCD controller Input : data byte to write to LCD rs 1 : write data 0 : write instruction Returns : none
static void lcd_write(uint8_t data,uint8_t rs)
  {
    #if (WAIT_MODE==1 && RW_LINE_IMPLEMENTED==1)
      lcd_waitbusy();
      if (PrevCmdInvolvedAddressCounter)
        {
          Delay_us(5);
          PrevCmdInvolvedAddressCounter=0;
        }
    #endif
    if (rs)
      {
        lcd_rs_port_high();                            
        #if (WAIT_MODE==1 && RW_LINE_IMPLEMENTED==1)
        PrevCmdInvolvedAddressCounter=1;
        #endif
      }
    else
      {
        lcd_rs_port_low();                          
        #if (WAIT_MODE==1 && RW_LINE_IMPLEMENTED==1)
        PrevCmdInvolvedAddressCounter=0;
        #endif
      }
    #if LCD_BITS==4
      lcd_db7_port_set(data&_BV(7));                  
      lcd_db6_port_set(data&_BV(6));
      lcd_db5_port_set(data&_BV(5));
      lcd_db4_port_set(data&_BV(4));
      Delay_ns(100);
      lcd_e_port_high();
      Delay_ns(500);
      lcd_e_port_low();
      lcd_db7_port_set(data&_BV(3));                  
      lcd_db6_port_set(data&_BV(2));
      lcd_db5_port_set(data&_BV(1));
      lcd_db4_port_set(data&_BV(0));
      Delay_ns(100);
      lcd_e_port_high();
      Delay_ns(500);
      lcd_e_port_low();
      lcd_db7_port_high();                            
      lcd_db6_port_high();
      lcd_db5_port_high();
      lcd_db4_port_high();
    #else 
      lcd_db7_port_set(data&_BV(7));                  
      lcd_db6_port_set(data&_BV(6));
      lcd_db5_port_set(data&_BV(5));
      lcd_db4_port_set(data&_BV(4));
      lcd_db3_port_set(data&_BV(3));                  
      lcd_db2_port_set(data&_BV(2));
      lcd_db1_port_set(data&_BV(1));
      lcd_db0_port_set(data&_BV(0));
      Delay_ns(100);
      lcd_e_port_high();
      Delay_ns(500);
      lcd_e_port_low();
      lcd_db7_port_high();                            
      lcd_db6_port_high();
      lcd_db5_port_high();
      lcd_db4_port_high();
      lcd_db3_port_high();
      lcd_db2_port_high();
      lcd_db1_port_high();
      lcd_db0_port_high();
    #endif
    #if (WAIT_MODE==0 || RW_LINE_IMPLEMENTED==0)
      if (!rs && data<=((1<<LCD_CLR) | (1<<LCD_HOME))) 
        Delay_us(1640);
      else Delay_us(40);
    #endif
  }
static void lcd_write ( uint8_t data , uint8_t rs ) { #if ( WAIT_MODE == 1 && RW_LINE_IMPLEMENTED == 1 ) lcd_waitbusy ( ) ; if ( PrevCmdInvolvedAddressCounter ) { Delay_us ( 5 ) ; PrevCmdInvolvedAddressCounter = 0 ; } #endif if ( rs ) { lcd_rs_port_high ( ) ; #if ( WAIT_MODE == 1 && RW_LINE_IMPLEMENTED == 1 ) PrevCmdInvolvedAddressCounter = 1 ; #endif } else { lcd_rs_port_low ( ) ; #if ( WAIT_MODE == 1 && RW_LINE_IMPLEMENTED == 1 ) PrevCmdInvolvedAddressCounter = 0 ; #endif } #if LCD_BITS == 4 lcd_db7_port_set ( data & _BV ( 7 ) ) ; lcd_db6_port_set ( data & _BV ( 6 ) ) ; lcd_db5_port_set ( data & _BV ( 5 ) ) ; lcd_db4_port_set ( data & _BV ( 4 ) ) ; Delay_ns ( 100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; lcd_db7_port_set ( data & _BV ( 3 ) ) ; lcd_db6_port_set ( data & _BV ( 2 ) ) ; lcd_db5_port_set ( data & _BV ( 1 ) ) ; lcd_db4_port_set ( data & _BV ( 0 ) ) ; Delay_ns ( 100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; lcd_db7_port_high ( ) ; lcd_db6_port_high ( ) ; lcd_db5_port_high ( ) ; lcd_db4_port_high ( ) ; #else lcd_db7_port_set ( data & _BV ( 7 ) ) ; lcd_db6_port_set ( data & _BV ( 6 ) ) ; lcd_db5_port_set ( data & _BV ( 5 ) ) ; lcd_db4_port_set ( data & _BV ( 4 ) ) ; lcd_db3_port_set ( data & _BV ( 3 ) ) ; lcd_db2_port_set ( data & _BV ( 2 ) ) ; lcd_db1_port_set ( data & _BV ( 1 ) ) ; lcd_db0_port_set ( data & _BV ( 0 ) ) ; Delay_ns ( 100 ) ; lcd_e_port_high ( ) ; Delay_ns ( 500 ) ; lcd_e_port_low ( ) ; lcd_db7_port_high ( ) ; lcd_db6_port_high ( ) ; lcd_db5_port_high ( ) ; lcd_db4_port_high ( ) ; lcd_db3_port_high ( ) ; lcd_db2_port_high ( ) ; lcd_db1_port_high ( ) ; lcd_db0_port_high ( ) ; #endif #if ( WAIT_MODE == 0 || RW_LINE_IMPLEMENTED == 0 ) if ( ! rs && data <= ( ( 1 << LCD_CLR ) | ( 1 << LCD_HOME ) ) ) Delay_us ( 1640 ) ; else Delay_us ( 40 ) ; #endif }
Low-level function to write byte to LCD controller
Input:    data   byte to write to LCD
rs     1: write data
0: write instruction
Returns:  none
Low - level function to write byte to LCD controller Input : data byte to write to LCD rs 1 : write data 0 : write instruction Returns : none
// RS=1: Write Character
 // RS=0: Write Command
 //Output High Nibble
 //Output High Nibble
 // All Data Pins High (Inactive)
 //using 8-Bit_Mode
 //Output High Nibble
 //Output High Nibble
 // All Data Pins High (Inactive)
 // Is command clrscr or home?
