hd44780: fix DL ifdef macro
This commit is contained in:
parent
ff1b84f505
commit
0ce4dc6c76
|
@ -155,7 +155,6 @@ static uint8_t lcd_hd44780_i2c_output = 0xff;
|
|||
* @note pulled up by HD44780
|
||||
*/
|
||||
#define LCD_HD44780_GPIO_DB4 PB15
|
||||
#if LCD_HD44780_INTERFACE_DL
|
||||
/** data bit 3
|
||||
* @note pulled up by HD44780
|
||||
* @note leave undefined when only 4-bit mode is used
|
||||
|
@ -176,15 +175,18 @@ static uint8_t lcd_hd44780_i2c_output = 0xff;
|
|||
* @note leave undefined when only 4-bit mode is used
|
||||
*/
|
||||
//#define LCD_HD44780_GPIO_DB0 P
|
||||
#endif // LCD_HD44780_INTERFACE_DL
|
||||
/** @} */
|
||||
#endif // LCD_HD44780_I2C
|
||||
|
||||
/** set for 8-bit interface data
|
||||
* @note I²C implies 4-bit
|
||||
*/
|
||||
#if defined(LCD_HD44780_GPIO_DB3) && defined(LCD_HD44780_GPIO_DB2) && defined(LCD_HD44780_GPIO_DB1) && defined(LCD_HD44780_GPIO_DB0)
|
||||
#define LCD_HD44780_INTERFACE_DL
|
||||
#if defined(LCD_HD44780_I2C) && LCD_HD44780_I2C
|
||||
#define LCD_HD44780_INTERFACE_DL 0
|
||||
#elif defined(LCD_HD44780_GPIO_DB3) && defined(LCD_HD44780_GPIO_DB2) && defined(LCD_HD44780_GPIO_DB1) && defined(LCD_HD44780_GPIO_DB0)
|
||||
#define LCD_HD44780_INTERFACE_DL 1
|
||||
#else
|
||||
#define LCD_HD44780_INTERFACE_DL 0
|
||||
#endif
|
||||
|
||||
/** if the display is configured having 2 lines */
|
||||
|
@ -232,7 +234,7 @@ static void lcd_hd44780_set_signal(uint16_t signals)
|
|||
if (signals & LCD_HD44780_E) {
|
||||
gpio_set(GPIO_PORT(LCD_HD44780_GPIO_E), GPIO_PIN(LCD_HD44780_GPIO_E));
|
||||
}
|
||||
#if LCD_HD44780_INTERFACE_DL
|
||||
#if defined(LCD_HD44780_INTERFACE_DL) && LCD_HD44780_INTERFACE_DL
|
||||
if (signals & LCD_HD44780_DB0) {
|
||||
gpio_set(GPIO_PORT(LCD_HD44780_GPIO_DB0), GPIO_PIN(LCD_HD44780_GPIO_DB0));
|
||||
}
|
||||
|
@ -305,7 +307,7 @@ static void lcd_hd44780_clear_signal(uint16_t signals)
|
|||
if (signals & LCD_HD44780_E) {
|
||||
gpio_clear(GPIO_PORT(LCD_HD44780_GPIO_E), GPIO_PIN(LCD_HD44780_GPIO_E));
|
||||
}
|
||||
#if LCD_HD44780_INTERFACE_DL
|
||||
#if defined(LCD_HD44780_INTERFACE_DL) && LCD_HD44780_INTERFACE_DL
|
||||
if (signals & LCD_HD44780_DB0) {
|
||||
gpio_clear(GPIO_PORT(LCD_HD44780_GPIO_DB0), GPIO_PIN(LCD_HD44780_GPIO_DB0));
|
||||
}
|
||||
|
@ -399,7 +401,7 @@ static uint8_t lcd_hd44780_read(bool data)
|
|||
input |= 0x10;
|
||||
}
|
||||
#endif // LCD_HD44780_I2C
|
||||
#if defined(LCD_HD44780_INTERFACE_DL)
|
||||
#if defined(LCD_HD44780_INTERFACE_DL) && LCD_HD44780_INTERFACE_DL
|
||||
if (gpio_get(GPIO_PORT(LCD_HD44780_GPIO_DB3), GPIO_PIN(LCD_HD44780_GPIO_DB3))) {
|
||||
input |= 0x08;
|
||||
}
|
||||
|
@ -505,7 +507,7 @@ static void lcd_hd44780_write(bool command, uint8_t data, bool first_nibble_only
|
|||
} else {
|
||||
lcd_hd44780_clear_signal(LCD_HD44780_DB4);
|
||||
}
|
||||
#ifdef LCD_HD44780_INTERFACE_DL
|
||||
#if defined(LCD_HD44780_INTERFACE_DL) && LCD_HD44780_INTERFACE_DL
|
||||
if (data & 0x08) {
|
||||
lcd_hd44780_set_signal(LCD_HD44780_DB3);
|
||||
} else {
|
||||
|
@ -676,13 +678,11 @@ bool lcd_hd44780_setup(bool n_2lines, bool f_5x10)
|
|||
sleep_us(100 + 10); // wait 100 us
|
||||
lcd_hd44780_write(true, 0x30, true); // 3rd function write set to go to state 1 (8-bit) (BF cannot be checked)
|
||||
sleep_us(LCD_HD44780_BUSY_WAIT_SHORT); // wait 37 us
|
||||
#ifndef LCD_HD44780_INTERFACE_DL
|
||||
lcd_hd44780_write(true, 0x20, true); // switch to 4-bit mode
|
||||
sleep_us(LCD_HD44780_BUSY_WAIT_SHORT); // wait 37 us
|
||||
#endif // !LCD_HD44780_INTERFACE_DL
|
||||
#ifdef LCD_HD44780_INTERFACE_DL
|
||||
#if defined(LCD_HD44780_INTERFACE_DL) && LCD_HD44780_INTERFACE_DL
|
||||
lcd_hd44780_function_set(1, n_2lines, f_5x10); // function set
|
||||
#else
|
||||
lcd_hd44780_write(true, 0x20, true); // switch to 4-bit mode
|
||||
sleep_us(LCD_HD44780_BUSY_WAIT_SHORT); // wait 37 us
|
||||
lcd_hd44780_function_set(0, n_2lines, f_5x10); // function set
|
||||
#endif
|
||||
lcd_hd44780_n_2lines = n_2lines; // remember number of lines
|
||||
|
@ -707,7 +707,7 @@ void lcd_hd44780_release(void)
|
|||
gpio_set_mode(GPIO_PORT(LCD_HD44780_GPIO_DB6), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LCD_HD44780_GPIO_DB6));
|
||||
gpio_set_mode(GPIO_PORT(LCD_HD44780_GPIO_DB5), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LCD_HD44780_GPIO_DB5));
|
||||
gpio_set_mode(GPIO_PORT(LCD_HD44780_GPIO_DB4), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LCD_HD44780_GPIO_DB4));
|
||||
#ifdef LCD_HD44780_INTERFACE_DL
|
||||
#if defined(LCD_HD44780_INTERFACE_DL) && LCD_HD44780_INTERFACE_DL
|
||||
gpio_set_mode(GPIO_PORT(LCD_HD44780_GPIO_DB3), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LCD_HD44780_GPIO_DB3));
|
||||
gpio_set_mode(GPIO_PORT(LCD_HD44780_GPIO_DB2), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LCD_HD44780_GPIO_DB2));
|
||||
gpio_set_mode(GPIO_PORT(LCD_HD44780_GPIO_DB1), GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO_PIN(LCD_HD44780_GPIO_DB1));
|
||||
|
|
Loading…
Reference in New Issue