/* Present the data to the port */
gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], NULL, values);
hd44780_strobe_gpio(hd);
}
/* Send a command to the LCD panel in 8 bit GPIO mode */ staticvoid hd44780_write_cmd_gpio8(struct hd44780_common *hdc, int cmd)
{ struct hd44780 *hd = hdc->hd44780;
hd44780_write_gpio8(hd, cmd, 0);
/* The shortest command takes at least 120 us */
udelay(120);
}
/* Send data to the LCD panel in 8 bit GPIO mode */ staticvoid hd44780_write_data_gpio8(struct hd44780_common *hdc, int data)
{ struct hd44780 *hd = hdc->hd44780;
hd44780_write_gpio8(hd, data, 1);
/* The shortest data takes at least 45 us */
udelay(45);
}
/* Send a command to the LCD panel in 4 bit GPIO mode */ staticvoid hd44780_write_cmd_gpio4(struct hd44780_common *hdc, int cmd)
{ struct hd44780 *hd = hdc->hd44780;
hd44780_write_gpio4(hd, cmd, 0);
/* The shortest command takes at least 120 us */
udelay(120);
}
/* Send 4-bits of a command to the LCD panel in raw 4 bit GPIO mode */ staticvoid hd44780_write_cmd_raw_gpio4(struct hd44780_common *hdc, int cmd)
{
DECLARE_BITMAP(values, 6); /* for DATA[4-7], RS, RW */ struct hd44780 *hd = hdc->hd44780; unsignedint n;
/* Present the data to the port */
gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], NULL, values);
hd44780_strobe_gpio(hd);
}
/* Send data to the LCD panel in 4 bit GPIO mode */ staticvoid hd44780_write_data_gpio4(struct hd44780_common *hdc, int data)
{ struct hd44780 *hd = hdc->hd44780;
hd44780_write_gpio4(hd, data, 1);
/* The shortest data takes at least 45 us */
udelay(45);
}
switch (ifwidth) { case 4:
base = PIN_DATA4; break; case 8:
base = PIN_DATA0; break; default: return -EINVAL;
}
lcd = hd44780_common_alloc(); if (!lcd) return -ENOMEM;
hd = kzalloc(sizeof(*hd), GFP_KERNEL); if (!hd) goto fail2;
hdc = lcd->drvdata;
hdc->hd44780 = hd;
for (i = 0; i < ifwidth; i++) {
hd->pins[base + i] = devm_gpiod_get_index(dev, "data", i,
GPIOD_OUT_LOW); if (IS_ERR(hd->pins[base + i])) {
ret = PTR_ERR(hd->pins[base + i]); goto fail3;
}
}
hd->pins[PIN_CTRL_E] = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(hd->pins[PIN_CTRL_E])) {
ret = PTR_ERR(hd->pins[PIN_CTRL_E]); goto fail3;
}
hd->pins[PIN_CTRL_RS] = devm_gpiod_get(dev, "rs", GPIOD_OUT_HIGH); if (IS_ERR(hd->pins[PIN_CTRL_RS])) {
ret = PTR_ERR(hd->pins[PIN_CTRL_RS]); goto fail3;
}
/* Optional pins */
hd->pins[PIN_CTRL_RW] = devm_gpiod_get_optional(dev, "rw",
GPIOD_OUT_LOW); if (IS_ERR(hd->pins[PIN_CTRL_RW])) {
ret = PTR_ERR(hd->pins[PIN_CTRL_RW]); goto fail3;
}
hd->pins[PIN_CTRL_BL] = devm_gpiod_get_optional(dev, "backlight",
GPIOD_OUT_LOW); if (IS_ERR(hd->pins[PIN_CTRL_BL])) {
ret = PTR_ERR(hd->pins[PIN_CTRL_BL]); goto fail3;
}
/* Required properties */
ret = device_property_read_u32(dev, "display-height-chars",
&lcd->height); if (ret) goto fail3;
ret = device_property_read_u32(dev, "display-width-chars", &lcd->width); if (ret) goto fail3;
/* * On displays with more than two rows, the internal buffer width is * usually equal to the display width
*/ if (lcd->height > 2)
hdc->bwidth = lcd->width;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.