mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
drivers/hd44780: optimize detection of 4 and 8 bit modes
The driver can only be used with either 4 or 8 bit modes. Checking if the 5th pin is set in the configuration is enough the determine if 8bit mode should be used or not
This commit is contained in:
parent
6c56972dba
commit
62d299459f
@ -110,20 +110,13 @@ int hd44780_init(hd44780_t *dev, const hd44780_params_t *params)
|
||||
LOG_ERROR("hd44780_init: invalid LCD size!\n");
|
||||
return -1;
|
||||
}
|
||||
uint8_t count_pins = 0;
|
||||
/* check which pins are used */
|
||||
for (unsigned i = 0; i < HD44780_MAX_PINS; ++i) {
|
||||
if (dev->p.data[i] != GPIO_UNDEF) {
|
||||
++count_pins;
|
||||
}
|
||||
}
|
||||
/* set mode depending on configured pins */
|
||||
dev->flag = 0;
|
||||
if (count_pins < HD44780_MAX_PINS) {
|
||||
dev->flag |= HD44780_4BITMODE;
|
||||
/* set mode depending on configured pins */
|
||||
if (dev->p.data[4] != GPIO_UNDEF) {
|
||||
dev->flag |= HD44780_8BITMODE;
|
||||
}
|
||||
else {
|
||||
dev->flag |= HD44780_8BITMODE;
|
||||
dev->flag |= HD44780_4BITMODE;
|
||||
}
|
||||
/* set flag for 1 or 2 row mode, 4 rows are 2 rows split half */
|
||||
if (dev->p.rows > 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user