From ec75d2f33cb3c14f240048aea57212cd28cbf8dd Mon Sep 17 00:00:00 2001 From: Dario Petrillo Date: Tue, 24 May 2022 18:26:44 +0200 Subject: [PATCH] tests/driver_ir_nec: add test application for ir_nec driver --- tests/driver_ir_nec/Makefile | 18 ++++++++++++++++ tests/driver_ir_nec/README.md | 10 +++++++++ tests/driver_ir_nec/main.c | 39 +++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 tests/driver_ir_nec/Makefile create mode 100644 tests/driver_ir_nec/README.md create mode 100644 tests/driver_ir_nec/main.c diff --git a/tests/driver_ir_nec/Makefile b/tests/driver_ir_nec/Makefile new file mode 100644 index 0000000000..6cc62bcc93 --- /dev/null +++ b/tests/driver_ir_nec/Makefile @@ -0,0 +1,18 @@ +include ../Makefile.tests_common + +# required modules +USEMODULE += ir_nec + +# Setup pin for ir-receiver +# Any interrupt capable GPIO pin should work fine +ifneq (,$(filter b-l475e-iot01a,$(BOARD))) + # This is the pin marked D7 on b-l475e-iot01a + IR_PIN ?= GPIO_PIN(PORT_A,4) +endif + +# fallback: set some default for compile test +IR_PIN ?= GPIO_PIN(0,0) + +CFLAGS += -D'IR_NEC_PARAM_PIN=$(IR_PIN)' + +include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_ir_nec/README.md b/tests/driver_ir_nec/README.md new file mode 100644 index 0000000000..dffabd59cb --- /dev/null +++ b/tests/driver_ir_nec/README.md @@ -0,0 +1,10 @@ +driver_ir_nec +============= + +This is a manual test application for the ir_nec driver. + +Usage +===== + +The application continuously reads packets from the IR remote and prints them. +It should print one line for every keypress. diff --git a/tests/driver_ir_nec/main.c b/tests/driver_ir_nec/main.c new file mode 100644 index 0000000000..dc86aa6c76 --- /dev/null +++ b/tests/driver_ir_nec/main.c @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2022 Dario Petrillo + * + * 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 + * @{ + * + * @file + * @brief Test application for the ir_nec driver + * + * @author Dario Petrillo + * + * @} + */ + +#include +#include "ir_nec.h" +#include "ir_nec_params.h" + +ir_nec_t remote; +ir_nec_cmd_t cmd; + +int main(void) +{ + ir_nec_init(&remote, &ir_nec_params[0]); + + for (;;) { + if (ir_nec_read(&remote, &cmd)) { + puts("Error reading packet"); + return -1; + } + printf("Received packet with addr = 0x%X, cmd = 0x%X\n", cmd.addr, cmd.cmd); + } +}