Skip to content

Commit

Permalink
tests: add PCF957X driver test application
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Dec 10, 2018
1 parent fc42799 commit 2a4472f
Show file tree
Hide file tree
Showing 4 changed files with 517 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/driver_pcf857x/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include ../Makefile.tests_common

ifeq (,$(filter pcf857%,$(USEMODULE)))
# default expander module
USEMODULE += pcf8575
endif

USEMODULE += shell
USEMODULE += benchmark

include $(RIOTBASE)/Makefile.include
32 changes: 32 additions & 0 deletions tests/driver_pcf857x/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Texas Instruments PCF857X I2C I/O expanders test application

## Overview

This test appliation demonstrates the usage of the PCF857X driver interface
and can be used to test each PCF857X expander I/O pin with shell commands.

The application bases on the test application for GPIO peripheral drivers
which is under following copyright:

Copyright (C) 2014,2017 Freie Universität Berlin
@author Hauke Petersen <hauke.petersen@fu-berlin.de>

## Usage

To use the test application, compile it with one or more of the pseudomodules
`pcf8574`, `pcf8574a` or `pcf8575` to enable the driver for your
expander modules. Please check the default configuration parameters in
`$(RIOTBASE)/drivers/pcf857x/include/pcf857x_params.h` and adopt them
if necessary.

USEMODULE=pcf8575 make -C tests/driver_pcf857x BOARD=...

**Please note:** When no pseudomodule is given, `pcf8575` is used by default.

The usage of the PCF857X low-active open-drain interrupt signal is
recommended to be able to use external interrupts with the expander I/O
pins. Add module `periph_gpio_irq` for this purpose and define the
MCU interrupt pin by parameter `PCF857X_PARAM_INT_PIN`, e.g.

CFLAGS="-DPCF857X_PARAM_INT_PIN=\(GPIO\(0,6\)\)" \
USEMODULE="pcf8575 periph_gpio_irq" make -C tests/driver_pcf857x BOARD=...
59 changes: 59 additions & 0 deletions tests/driver_pcf857x/include/gpio_ext_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2018 Gunar Schorcht
*
* 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.
*/

/**
* @ingroup tests
* @brief GPIO extension for Texas Instruments PCF857X I2C I/O expanders
* @author Gunar Schorcht <gunar@schorcht.net>
* @file
*/

#ifndef GPIO_EXT_CONF_H
#define GPIO_EXT_CONF_H

#if MODULE_EXTEND_GPIO

#include <stddef.h>

#include "extend/gpio.h"
#include "pcf857x_params.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief Reference to PCF857X device driver struct
*/
extern const gpio_ext_driver_t pcf857x_extend_gpio_driver;
/** @} */

/**
* @brief References to the PCF857X devices
*/
extern pcf857x_t pcf857x_dev[];

/**
* @brief GPIO extension list of PCF857X expanders
*/
static const gpio_ext_t gpio_ext_list[] =
{
{
.driver = &pcf857x_extend_gpio_driver,
.dev = (void *)&pcf857x_dev[0],
},
};

#ifdef __cplusplus
}
#endif

#endif /* MODULE_EXTEND_GPIO */

#endif /* GPIO_EXT_CONF_H */
/** @} */
Loading

0 comments on commit 2a4472f

Please sign in to comment.