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

tests/driver_ir_nec: add test application for ir_nec driver

This commit is contained in:
Dario Petrillo 2022-05-24 18:26:44 +02:00
parent 18f8a476e6
commit ec75d2f33c
No known key found for this signature in database
GPG Key ID: 3A137B00436E37AB
3 changed files with 67 additions and 0 deletions

View File

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

View File

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

View File

@ -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 <dario.pk1@gmail.com>
*
* @}
*/
#include <stdio.h>
#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);
}
}