1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-22 21:13:52 +01:00

tests/drivers: add dedicated hd44780_i2c test

This commit is contained in:
crasbe 2025-07-30 15:36:27 +02:00
parent cfaa76bad4
commit 59f9b5c46a
7 changed files with 93 additions and 1 deletions

View File

@ -13,7 +13,8 @@
* @ingroup drivers_display * @ingroup drivers_display
* @brief Driver for the Hitachi HD44780 LCD driver * @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
* *
* @{ * @{
* *

View File

@ -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 many Arduino starter kits under the name of LCM1602C, and typically has 16x2
columns and rows. 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 # Details
This test application will initialize the HD44780 driver with the configuration This test application will initialize the HD44780 driver with the configuration

View File

@ -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

View File

@ -0,0 +1,3 @@
BOARD_INSUFFICIENT_MEMORY := \
atmega8 \
#

View File

@ -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.

View File

@ -0,0 +1 @@
../hd44780/main.c

View File

@ -0,0 +1,20 @@
#!/usr/bin/env python3
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
# 2017 Sebastian Meiling <s@mlng.net>
#
# 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))