From 37bdc32e30a542bc8276045cc3b2bb643e672b8c Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Tue, 28 Jun 2022 18:21:04 +0200 Subject: [PATCH] tests/driver_nrf802154: Initial driver test --- tests/driver_nrf802154/Makefile | 15 +++++++ tests/driver_nrf802154/README.md | 6 +++ tests/driver_nrf802154/init_dev.h | 33 ++++++++++++++ tests/driver_nrf802154/main.c | 72 +++++++++++++++++++++++++++++++ 4 files changed, 126 insertions(+) create mode 100644 tests/driver_nrf802154/Makefile create mode 100644 tests/driver_nrf802154/README.md create mode 100644 tests/driver_nrf802154/init_dev.h create mode 100644 tests/driver_nrf802154/main.c diff --git a/tests/driver_nrf802154/Makefile b/tests/driver_nrf802154/Makefile new file mode 100644 index 0000000000..f5cdebecbc --- /dev/null +++ b/tests/driver_nrf802154/Makefile @@ -0,0 +1,15 @@ +INCLUDES += -I$(APPDIR) +BOARD ?= nrf52dk + +include ../Makefile.tests_common + +USEMODULE += test_utils_netdev_ieee802154_minimal + +# select the driver to test +USEMODULE += nrf802154 + +FEATURES_REQUIRED += cpu_nrf52 + +CFLAGS += -DEVENT_THREAD_STACKSIZE_DEFAULT=1024 + +include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_nrf802154/README.md b/tests/driver_nrf802154/README.md new file mode 100644 index 0000000000..6d0620ccac --- /dev/null +++ b/tests/driver_nrf802154/README.md @@ -0,0 +1,6 @@ +# About +This is a manual test application for the NRF802154 radio driver. + +# 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_nrf802154/init_dev.h b/tests/driver_nrf802154/init_dev.h new file mode 100644 index 0000000000..14b3ca0689 --- /dev/null +++ b/tests/driver_nrf802154/init_dev.h @@ -0,0 +1,33 @@ +/* + * 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 NRF802154 IEEE 802.15.4 device driver + * + * @author Kevin Weiss + */ +#ifndef INIT_DEV_H +#define INIT_DEV_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define NRF802154_NUM 1 +#define NETDEV_IEEE802154_MINIMAL_NUMOF NRF802154_NUM + +#ifdef __cplusplus +} +#endif + +#endif /* INIT_DEV_H */ +/** @} */ diff --git a/tests/driver_nrf802154/main.c b/tests/driver_nrf802154/main.c new file mode 100644 index 0000000000..9c0bc7555a --- /dev/null +++ b/tests/driver_nrf802154/main.c @@ -0,0 +1,72 @@ +/* + * 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 NRF802154 IEEE 802.15.4 device driver + * + * @author Leandro Lanzieri + * + * @} + */ + +#include + +#include "nrf802154.h" +#include "init_dev.h" +#include "net/netdev/ieee802154_submac.h" +#include "shell.h" +#include "test_utils/netdev_ieee802154_minimal.h" + +static netdev_ieee802154_submac_t nrf802154; + +int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) { + netdev_t *netdev = &nrf802154.dev.netdev; + + puts("Initializing NRF802154 device"); + + netdev_register(netdev, NETDEV_CC2538, 0); + netdev_ieee802154_submac_init(&nrf802154); + + /* setup and initialize the specific driver */ + nrf802154_hal_setup(&nrf802154.submac.dev); + nrf802154_init(); + + /* set the application-provided callback */ + netdev->event_callback = cb; + + /* initialize the device driver */ + int res = netdev->driver->init(netdev); + if (res != 0) { + return -1; + } + + return 0; +} + +int main(void) +{ + puts("Test application for NRF802154 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; +}