mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 18:13:49 +01:00
tests/driver_ir_nec: add test application for ir_nec driver
This commit is contained in:
parent
18f8a476e6
commit
ec75d2f33c
18
tests/driver_ir_nec/Makefile
Normal file
18
tests/driver_ir_nec/Makefile
Normal 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
|
||||||
10
tests/driver_ir_nec/README.md
Normal file
10
tests/driver_ir_nec/README.md
Normal 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.
|
||||||
39
tests/driver_ir_nec/main.c
Normal file
39
tests/driver_ir_nec/main.c
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user