/*! * \brief Send half byte to LCD controller. * * \param nib The four least significant bits are sent. */ static void LcdWriteNibble(unsigned int nib) { #ifdef LCD_DATA_LSB nib <<= LCD_DATA_LSB; #else { unsigned int val = 0; if (nib & 0x01) { val |= LCD_D0; } if (nib & 0x02) { val |= LCD_D1; } if (nib & 0x04) { val |= LCD_D2; } if (nib & 0x08) { val |= LCD_D3; } nib = val; } #endif LcdSetBits(nib & LCD_DATA); LcdClrBits(~nib & LCD_DATA); /* Create Enable Pulse: * For HD44780 Displays we need: * Vcc = 5.0V -> PWeh >= 230ns * Vcc = 3.3V -> PWeh >= 500ns */ LCD_EN_SET(); NutMicroDelay(LCD_SHORT_DELAY); LCD_EN_CLR(); }
/*! * \brief Send byte to LCD controller. * * \param data Byte to send. */ static void LcdWriteByte(unsigned int data) { /* If configured set RW low */ #ifdef LCD_RW_BIT LCD_RW_CLR(); #endif /* If using 4-bit access, write two nibbles now */ #ifdef LCD_IF_4BIT LcdWriteNibble(data >> 4); LcdNanoDelay(LCD_PW_EH); LcdWriteNibble(data); #else /* else write one byte */ data <<= LCD_DATA_LSB; LcdSetBits(data & LCD_DATA); LcdClrBits(~data & LCD_DATA); #endif /* If configured, let the task sleep before next character */ #if defined(LCD_SLEEP_DLY) NutSleep(1); #else /* or add a fixed delay and immediately process next char */ NutMicroDelay(LCD_E2E_DLY); #endif }