From f1d6b25c6242574f8234fd0ff19b3976ce8fad1d Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Tue, 22 Mar 2022 10:09:53 +0100 Subject: [PATCH] tests: add cc2420 driver test --- tests/driver_cc2420/Makefile | 13 +++++++ tests/driver_cc2420/Makefile.ci | 11 ++++++ tests/driver_cc2420/README.md | 19 +++++++++ tests/driver_cc2420/init_dev.h | 36 +++++++++++++++++ tests/driver_cc2420/main.c | 69 +++++++++++++++++++++++++++++++++ 5 files changed, 148 insertions(+) create mode 100644 tests/driver_cc2420/Makefile create mode 100644 tests/driver_cc2420/Makefile.ci create mode 100644 tests/driver_cc2420/README.md create mode 100644 tests/driver_cc2420/init_dev.h create mode 100644 tests/driver_cc2420/main.c diff --git a/tests/driver_cc2420/Makefile b/tests/driver_cc2420/Makefile new file mode 100644 index 0000000000..924080e564 --- /dev/null +++ b/tests/driver_cc2420/Makefile @@ -0,0 +1,13 @@ +INCLUDES += -I$(APPDIR) +BOARD ?= z1 + +include ../Makefile.tests_common + +USEMODULE += test_utils_netdev_ieee802154_minimal + +# select the driver to test +USEMODULE += cc2420 + +CFLAGS += -DEVENT_THREAD_STACKSIZE_DEFAULT=1024 + +include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_cc2420/Makefile.ci b/tests/driver_cc2420/Makefile.ci new file mode 100644 index 0000000000..fa21afb84b --- /dev/null +++ b/tests/driver_cc2420/Makefile.ci @@ -0,0 +1,11 @@ +BOARD_INSUFFICIENT_MEMORY := \ + arduino-duemilanove \ + arduino-leonardo \ + arduino-nano \ + arduino-uno \ + atmega328p-xplained-mini \ + atmega328p \ + nucleo-l011k4 \ + samd10-xmini \ + stm32f030f4-demo \ + # diff --git a/tests/driver_cc2420/README.md b/tests/driver_cc2420/README.md new file mode 100644 index 0000000000..7f9e1b9afc --- /dev/null +++ b/tests/driver_cc2420/README.md @@ -0,0 +1,19 @@ +# About +This is a manual test application for the CC2420 radio driver. + +For running this test, you need to connect/configure the following pins of your +radio device: +- SPI MISO +- SPI MOSI +- SPI CLK +- CS (chip select) +- FIFO +- FIFOP +- CCA +- SFD +- VREFEN +- RESET + +# Usage +For testing the radio driver you can use the ifconfig and txtsnd shell commands +that are included in this application. diff --git a/tests/driver_cc2420/init_dev.h b/tests/driver_cc2420/init_dev.h new file mode 100644 index 0000000000..cf412b85f7 --- /dev/null +++ b/tests/driver_cc2420/init_dev.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2022 HAW Hamburg + * + * 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 Device-specific test header file CC2420 IEEE 802.15.4 device driver + * + * @author Leandro Lanzieri + */ +#ifndef INIT_DEV_H +#define INIT_DEV_H + +#include "cc2420_params.h" +#include "kernel_defines.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define CC2420_NUM ARRAY_SIZE(cc2420_params) +#define NETDEV_IEEE802154_MINIMAL_NUMOF CC2420_NUM + +#ifdef __cplusplus +} +#endif + +#endif /* INIT_DEV_H */ +/** @} */ diff --git a/tests/driver_cc2420/main.c b/tests/driver_cc2420/main.c new file mode 100644 index 0000000000..8ec9fcb014 --- /dev/null +++ b/tests/driver_cc2420/main.c @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2022 HAW Hamburg + * + * 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 CC2420 IEEE 802.15.4 device driver + * + * @author Leandro Lanzieri + * + * @} + */ + +#include + +#include "cc2420.h" +#include "init_dev.h" +#include "shell.h" +#include "test_utils/netdev_ieee802154_minimal.h" + +static cc2420_t cc2420[CC2420_NUM]; + +int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) { + puts("Initializing CC2420 devices"); + + for (unsigned i = 0; i < CC2420_NUM; i++) { + printf("%d out of %d\n", i + 1, CC2420_NUM); + netdev_t *netdev = &cc2420[i].netdev.netdev; + + /* setup the specific driver */ + cc2420_setup(&cc2420[i], &cc2420_params[i], i); + + /* set the application-provided callback */ + netdev->event_callback = cb; + + /* initialize the device driver */ + int res = netdev->driver->init(netdev); + if (res) { + return res; + } + } + return 0; +} + +int main(void) +{ + puts("Test application for CC2420 IEEE 802.15.4 device driver"); + + int res = netdev_ieee802154_minimal_init(); + if (res) { + puts("Error initializing devices"); + return 1; + } + + /* start the shell */ + puts("Initialization successful - starting the shell now"); + + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); + + return 0; +}