diff --git a/drivers/include/hd44780.h b/drivers/include/hd44780.h index ac67238b3c..e8e4179c5f 100644 --- a/drivers/include/hd44780.h +++ b/drivers/include/hd44780.h @@ -13,7 +13,8 @@ * @ingroup drivers_display * @brief Driver for the Hitachi HD44780 LCD driver * - * @note The driver currently supports direct addressing, no I2C + * @note The driver currently supports both direct addressing + * and I2C if the [PCF857X module](@ref drivers_pcf857x) is used * * @{ * diff --git a/tests/drivers/hd44780/README.md b/tests/drivers/hd44780/README.md index 30d57a0d43..8ec850ada4 100644 --- a/tests/drivers/hd44780/README.md +++ b/tests/drivers/hd44780/README.md @@ -4,6 +4,9 @@ This is a test application for the HD44780 LCD driver. This display comes with many Arduino starter kits under the name of LCM1602C, and typically has 16x2 columns and rows. +This examples covers the parallel mode of the HD44780 driver. For the I2C mode, +please refer to `tests/drivers/hd44780_i2c`. + # Details This test application will initialize the HD44780 driver with the configuration diff --git a/tests/drivers/hd44780_i2c/Makefile b/tests/drivers/hd44780_i2c/Makefile new file mode 100644 index 0000000000..688e254ae5 --- /dev/null +++ b/tests/drivers/hd44780_i2c/Makefile @@ -0,0 +1,28 @@ +include ../Makefile.drivers_common + +USEMODULE += hd44780 + +# The I2C versions of this display usually use an I2C port expander +# such as the PCF8574, PCF8574A or PCF8575. Depending on the +# board variant, the port expander can also have different +# I2C addresses. Typical ranges are: +# PCF8574 - 0x20 to 0x27 +# PCF8574A - 0x38 to 0x3F +# PCF8475 - 0x20 to 0x27 +DRIVER ?= pcf8574 +ADDRESS ?= 0x20 + +# select the right module and calculate the I2C address offset +ifeq (pcf8574,$(DRIVER)) + CFLAGS += -D"PCF857X_PARAM_ADDR=($(ADDRESS)-PCF8574_BASE_ADDR)" +else ifeq (pcf8574a,$(DRIVER)) + CFLAGS += -D"PCF857X_PARAM_ADDR=($(ADDRESS)-PCF8574A_BASE_ADDR)" +else ifeq (pcf8575,$(DRIVER)) + CFLAGS += -D"PCF857X_PARAM_ADDR=($(ADDRESS)-PCF8575_BASE_ADDR)" +else + $(error Invalid I2C port expander selected: $(DRIVER)) +endif + +USEMODULE += $(DRIVER) + +include $(RIOTBASE)/Makefile.include diff --git a/tests/drivers/hd44780_i2c/Makefile.ci b/tests/drivers/hd44780_i2c/Makefile.ci new file mode 100644 index 0000000000..72db76ccb5 --- /dev/null +++ b/tests/drivers/hd44780_i2c/Makefile.ci @@ -0,0 +1,3 @@ +BOARD_INSUFFICIENT_MEMORY := \ + atmega8 \ + # diff --git a/tests/drivers/hd44780_i2c/README.md b/tests/drivers/hd44780_i2c/README.md new file mode 100644 index 0000000000..2d5bbf8b8c --- /dev/null +++ b/tests/drivers/hd44780_i2c/README.md @@ -0,0 +1,36 @@ +# About + +This is a test application for the HD44780 LCD driver. This display comes with +many Arduino starter kits under the name of LCM1602C, and typically has 16x2 +columns and rows. + +This examples covers the I2C mode of the HD44780 driver. For the parallel mode, +please refer to `tests/drivers/hd44780`. + +# Details + +This test application will initialize the HD44780 driver with the configuration +as specified in the default `hd44780_params.h` file. + +The HD44780 compatible displays are often available with an I2C interface, +which is realized with an I2C port expander connected to the parallel +interface. Typically these I2C add-on boards feature a PCF8574(A) or PCF8575 +chip with selectable I2C addresses. + - PCF8574: Address Range from 0x20 to 0x27 + - PCF8574A: Address Range from 0x38 to 0x3F + - PCF8575: Address Range from 0x20 to 0x27 + +Please specify the chip present on your board and the according I2C address +with a command such as this: + +```sh +DRIVER=pcf8575 ADDRESS=0x27 BOARD=... make ... +``` + +This would select the PCF8575 IO expander with the I2C address 0x27. +If no chip is selected, the build system sets the PCF8574 with address 0x20 as +default. + +If you don't know which base address the board has, you can use the +`tests/periph/i2c` test program and perform an I2C bus scan. This scan reveals +all devices connected to the I2C bus and their respective addresses. diff --git a/tests/drivers/hd44780_i2c/main.c b/tests/drivers/hd44780_i2c/main.c new file mode 120000 index 0000000000..35b86d3ee4 --- /dev/null +++ b/tests/drivers/hd44780_i2c/main.c @@ -0,0 +1 @@ +../hd44780/main.c \ No newline at end of file diff --git a/tests/drivers/hd44780_i2c/tests-with-config/01-run.py b/tests/drivers/hd44780_i2c/tests-with-config/01-run.py new file mode 100755 index 0000000000..8f6a837f3e --- /dev/null +++ b/tests/drivers/hd44780_i2c/tests-with-config/01-run.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +# Copyright (C) 2016 Kaspar Schleiser +# 2017 Sebastian Meiling +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. + +import sys +from testrunner import run + + +def testfunc(child): + child.expect_exact("[START]") + child.expect_exact("[SUCCESS]") + + +if __name__ == "__main__": + sys.exit(run(testfunc))