static unsigned int LcdReadNibble(void)
{
    unsigned int rc;

    LCD_EN_SET();
    LcdDelay(LCD_SHORT_DELAY);
    rc = inr(LCD_DATA_PIO_ID+PIO_PDSR_OFF) & LCD_DATA;
    LCD_EN_CLR();
    LcdDelay(LCD_SHORT_DELAY);

#ifdef LCD_DATA_LSB
    rc >>= LCD_DATA_LSB
#else
    {
        unsigned int val = 0;

        if (rc & LCD_D0) {
            val |= 0x01;
        }
        if (rc & LCD_D1) {
            val |= 0x02;
        }
        if (rc & LCD_D2) {
            val |= 0x04;
        }
        if (rc & LCD_D3) {
            val |= 0x08;
        }
        rc = val;
    }
#endif
    return rc;
}
Ejemplo n.º 2
0
/*!
 * \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();
}
Ejemplo n.º 3
0
static inline void lcd_write_byte(char data)
{
    // Ensure ENABLE is off
    LCD_EN_CLR();

    PORT_WR(LCD_DATA_P, data << LCD_DATA_OFFSET);

    // Flash ENABLE to issue command. Requires at least 450ns, which is a bit less than this will take
    LCD_EN_SET();
    //task_delay(LCD_VERY_SHORT_DELAY);
    _nop();
    LCD_EN_CLR();
}