Skip to content

Commit

Permalink
tests/driver_nrf802154: Initial driver test
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevinWeiss committed Jul 11, 2022
1 parent a2ac1c8 commit 37bdc32
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/driver_nrf802154/Makefile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions tests/driver_nrf802154/README.md
Original file line number Diff line number Diff line change
@@ -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.
33 changes: 33 additions & 0 deletions tests/driver_nrf802154/init_dev.h
Original file line number Diff line number Diff line change
@@ -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 <kevin.weiss@haw-hamburg.de>
*/
#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 */
/** @} */
72 changes: 72 additions & 0 deletions tests/driver_nrf802154/main.c
Original file line number Diff line number Diff line change
@@ -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 <leandro.lanzieri@haw-hamburg.de>
*
* @}
*/

#include <stdio.h>

#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;
}

0 comments on commit 37bdc32

Please sign in to comment.