Skip to content

Commit

Permalink
tests/periph/selftest_shield: add test application
Browse files Browse the repository at this point in the history
This test application makes use of the RIOT Peripheral Selftest Shield,
which connects e.g. PWM to ADC or SPI MOSI to SPI MISO, UART TXD to RXD,
etc. This provides quick and fully automated self testing capabilities.

Please note that the simplicity and ease of use of the hardware comes
with a prices: There are whole classes of issues that cannot be detected
automatically. This test cannot replace other testing approaches
(such as manual testing or PHiLIP on the HiL), but only complement them.
  • Loading branch information
maribu committed Sep 18, 2023
1 parent 4b6c9e2 commit 6193c8c
Show file tree
Hide file tree
Showing 6 changed files with 1,133 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/periph/selftest_shield/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
BOARD ?= arduino-due

include ../Makefile.periph_common

FEATURES_REQUIRED += arduino_pins
FEATURES_REQUIRED += arduino_shield_uno

FEATURES_OPTIONAL += arduino_analog
FEATURES_OPTIONAL += arduino_i2c
FEATURES_OPTIONAL += arduino_pwm
FEATURES_OPTIONAL += arduino_shield_isp
FEATURES_OPTIONAL += arduino_spi
FEATURES_OPTIONAL += arduino_uart
FEATURES_OPTIONAL += periph_adc
FEATURES_OPTIONAL += periph_gpio
FEATURES_OPTIONAL += periph_gpio_irq
FEATURES_OPTIONAL += periph_i2c
FEATURES_OPTIONAL += periph_pwm
FEATURES_OPTIONAL += periph_spi
FEATURES_OPTIONAL += periph_timer
FEATURES_OPTIONAL += periph_uart

include $(RIOTBASE)/Makefile.include

ifneq ($(MCU),esp32)
# We only need 2 threads (+ the Idle thread on some platforms) and we really
# want this app working on as many boards as possible
CFLAGS += -DMAXTHREADS=3
else
# ESP32x SoCs uses an extra thread for esp_timer
CFLAGS += -DMAXTHREADS=4
endif
5 changes: 5 additions & 0 deletions tests/periph/selftest_shield/Makefile.board.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ifneq (,$(filter periph_i2c,$(FEATURES_USED)))
ifneq (,$(filter arduino_i2c,$(FEATURES_USED)))
USEMODULE += pcf8574
endif
endif
35 changes: 35 additions & 0 deletions tests/periph/selftest_shield/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Peripheral Test Battery using the Peripheral Selftest Shield

This test application does a full self test of any of the following peripheral
driver, if supported by the board and Arduino I/O mapping is available:

- `periph_adc` (1)
- `periph_gpio`
- `periph_gpio_irq`
- `periph_i2c` (2)
- `periph_pwm`
- `periph_spi` (3)
- `periph_uart` (4)

Notes:
1. The ADC input is generated via a 4-bit R-2R resistor ladder and the I2C
attached GPIO extender and/or PWM. If neither is available, no tests are
performed. If both are available, up to three ADC channels are tested:
Those muxed to pins A0, A1, and A2.
2. I2C is indirectly tested by operating the PCF8574 I2C GPIO extender and
observing the result using internal GPIOs connected to the external ones.
This test is only enabled if both `periph_i2c` and `periph_gpio` is
available
3. Correctness of the clock frequency, clock phase and clock polarity is not
checked due to the limitations of the selftest shield.
4. UART self testing is skipped when the D0/D1 UART interface is used for
stdio. In addition, correctness of the symbol rate (often incorrectly
referred to as "baudrate") cannot be tested, as bugs here would affect
both TX and RX in the same way and negate each other.

## Configuration

The test requires no configuration and will by default test all of the above
peripheral drivers for which Arduino I/O mappings exists. To disable a subset
of the tests (e.g. to safe RAM/ROM to trim down the test to a low end board), it
is possible to disable features (`FEATURES_BLACKLIST += periph_<foobar>`).
Loading

0 comments on commit 6193c8c

Please sign in to comment.