static void lcd_Write ( uint8_t reg, /* b0:command(0)/data(1), b2-b1:E1(2)/E2(1)/both(0)(don't care on single controller), b3:write high nibble only(don't care on 8-bit I/F) */ uint8_t data /* Byte to be written */ ) { if (reg & 1) /* Select register */ RS_HIGH(); else RS_LOW(); IF_DLY60nS(); #if IF_BUS == 4 if (!(reg & 8)) { // write both nibbles OUT_DATA(data); #if LCD_IF_DUAL if (!(reg & 2)) E1_HIGH(); if (!(reg & 4)) E2_HIGH(); IF_DLY450nS(); E1_LOW(); E2_LOW(); #else E1_HIGH(); IF_DLY450nS(); E1_LOW(); #endif data <<= 4; } #endif OUT_DATA(data); #if LCD_IF_DUAL if (!(reg & 2)) E1_HIGH(); if (!(reg & 4)) E2_HIGH(); IF_DLY450nS(); E1_LOW(); E2_LOW(); #else E1_HIGH(); IF_DLY450nS(); E1_LOW(); #endif _delay_us(LCD_DT2); /* Always use timer */ OUT_DATA(0xF0); }
static void lcd_write ( uint8_t reg, /* b0:command(0)/data(1), b2..1:E1(2)/E2(1)/both(0)(don't care on single controller), b3:write high nibble only(don't care on 8-bit bus) */ uint8_t dat /* Byte to be written */ ) { if (reg & 1) /* Select register */ RS_HIGH(); else RS_LOW(); IF_DLY60(); #if IF_BUS == 4 if (!(reg & 8)) { OUT_DATA(dat); #if LCD_IF_DUAL if (!(reg & 2)) E1_HIGH(); if (!(reg & 4)) E2_HIGH(); IF_DLY450(); E1_LOW(); E2_LOW(); #else E1_HIGH(); IF_DLY450(); E1_LOW(); #endif IF_DLY450(); dat <<= 4; } #endif OUT_DATA(dat); #if LCD_IF_DUAL if (!(reg & 2)) E1_HIGH(); if (!(reg & 4)) E2_HIGH(); IF_DLY450(); E1_LOW(); E2_LOW(); #else E1_HIGH(); IF_DLY450(); E1_LOW(); #endif DELAY_US(LCD_DT2); /* Always use timer */ }