mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #17838 from MrKevinWeiss/pr/tests/154_drivers_rework
tests: rework ieee802154 drivers
This commit is contained in:
commit
1ba2ef8977
@ -20,6 +20,7 @@
|
||||
#ifndef AT86RF215_PARAMS_H
|
||||
#define AT86RF215_PARAMS_H
|
||||
|
||||
#include "at86rf215.h"
|
||||
#include "board.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -20,6 +20,7 @@
|
||||
#ifndef AT86RF2XX_PARAMS_H
|
||||
#define AT86RF2XX_PARAMS_H
|
||||
|
||||
#include "at86rf2xx.h"
|
||||
#include "board.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define CC2420_PARAMS_H
|
||||
|
||||
#include "board.h"
|
||||
#include "cc2420.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -138,8 +138,10 @@ typedef struct {
|
||||
*
|
||||
* @param[out] dev device descriptor
|
||||
* @param[in] params parameters for device initialization
|
||||
* @param[in] index index of @p params in a global parameter struct array.
|
||||
* If initialized manually, pass a unique identifier instead.
|
||||
*/
|
||||
void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params);
|
||||
void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params, uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief Initialize the given KW2XRF device
|
||||
|
@ -328,6 +328,7 @@ typedef enum {
|
||||
NETDEV_W5100,
|
||||
NETDEV_ENCX24J600,
|
||||
NETDEV_ATWINC15X0,
|
||||
NETDEV_KW2XRF,
|
||||
/* add more if needed */
|
||||
} netdev_type_t;
|
||||
/** @} */
|
||||
|
@ -1 +1,5 @@
|
||||
SUBMODULES := 1
|
||||
|
||||
SRC := kw2xrf.c kw2xrf_getset.c kw2xrf_intern.c kw2xrf_netdev.c kw2xrf_spi.c
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define KW2XRF_PARAMS_H
|
||||
|
||||
#include "board.h"
|
||||
#include "kw2xrf.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -120,8 +120,6 @@ void kw2xrf_read_iregs(kw2xrf_t *dev, uint8_t addr, uint8_t *buf, uint8_t length
|
||||
* @param[in] dev device descriptor
|
||||
* @param[in] data A buffer with the value to write to the fifo.
|
||||
* @param[in] data_length The count of bytes which should be written.
|
||||
*
|
||||
* @return number of bytes written.
|
||||
*/
|
||||
void kw2xrf_write_fifo(kw2xrf_t *dev, uint8_t *data, uint8_t data_length);
|
||||
|
||||
@ -131,8 +129,6 @@ void kw2xrf_write_fifo(kw2xrf_t *dev, uint8_t *data, uint8_t data_length);
|
||||
* @param[in] dev device descriptor
|
||||
* @param[out] data A buffer to store the value of the fifo.
|
||||
* @param[in] data_length The count of bytes which should be read.
|
||||
*
|
||||
* @return number of bytes read.
|
||||
*/
|
||||
void kw2xrf_read_fifo(kw2xrf_t *dev, uint8_t *data, uint8_t data_length);
|
||||
|
||||
|
@ -23,13 +23,14 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef KW2XRF_TESTMODE
|
||||
|
||||
#include "kw2xrf.h"
|
||||
#include "kw2xrf_reg.h"
|
||||
#include "kw2xrf_getset.h"
|
||||
#include "net/netopt.h"
|
||||
|
||||
/**
|
||||
* @brief Valid test modes to be used with @ref kw2xrf_set_test_mode.
|
||||
*/
|
||||
enum mkw2xrf_testmode {
|
||||
KW2XRF_TM_CTX_PREAMBLE = NETOPT_RF_TESTMODE_CTX_PRBS9 + 1,
|
||||
KW2XRF_TM_CTX_2MHZ,
|
||||
@ -40,10 +41,17 @@ enum mkw2xrf_testmode {
|
||||
KW2XRF_TM_CTX_NM1,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Set the test mode for the kw2xrf device.
|
||||
*
|
||||
* @param[in] dev Device descriptor
|
||||
* @param[in] mode Test mode (must be one of @ref mkw2xrf_testmode)
|
||||
*
|
||||
* @retval 1 on success
|
||||
* @retval != 1 otherwise
|
||||
*/
|
||||
int kw2xrf_set_test_mode(kw2xrf_t *dev, uint8_t mode);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ static void kw2xrf_set_address(kw2xrf_t *dev)
|
||||
kw2xrf_set_addr_short(dev, ntohs(addr_long.uint16[0].u16));
|
||||
}
|
||||
|
||||
void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params)
|
||||
void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params, uint8_t index)
|
||||
{
|
||||
netdev_t *netdev = &dev->netdev.netdev;
|
||||
|
||||
@ -71,6 +71,9 @@ void kw2xrf_setup(kw2xrf_t *dev, const kw2xrf_params_t *params)
|
||||
kw2xrf_clear_dreg_bit(dev, MKW2XDM_PHY_CTRL2, MKW2XDM_PHY_CTRL2_RXMSK);
|
||||
kw2xrf_clear_dreg_bit(dev, MKW2XDM_PHY_CTRL2, MKW2XDM_PHY_CTRL2_TXMSK);
|
||||
DEBUG("[kw2xrf] setup finished\n");
|
||||
|
||||
/* register with netdev */
|
||||
netdev_register(netdev, NETDEV_KW2XRF, index);
|
||||
}
|
||||
|
||||
int kw2xrf_init(kw2xrf_t *dev, gpio_cb_t cb)
|
||||
|
@ -512,7 +512,7 @@ static int _set(netdev_t *netdev, netopt_t opt, const void *value, size_t len)
|
||||
break;
|
||||
|
||||
case NETOPT_RF_TESTMODE:
|
||||
#ifdef KW2XRF_TESTMODE
|
||||
#ifdef MODULE_KW2XRF_TESTMODE
|
||||
if (len < sizeof(uint8_t)) {
|
||||
res = -EOVERFLOW;
|
||||
}
|
||||
|
@ -21,8 +21,6 @@
|
||||
#include "kw2xrf_reg.h"
|
||||
#include "kw2xrf_tm.h"
|
||||
|
||||
#ifdef KW2XRF_TESTMODE
|
||||
|
||||
static inline void enable_xcvr_test_mode(kw2xrf_t *dev)
|
||||
{
|
||||
uint8_t reg;
|
||||
@ -58,7 +56,7 @@ int kw2xrf_set_test_mode(kw2xrf_t *dev, uint8_t mode)
|
||||
disable_xcvr_test_mode(dev);
|
||||
kw2xrf_set_channel(dev, dev->netdev.chan);
|
||||
|
||||
switch(mode) {
|
||||
switch (mode) {
|
||||
case NETOPT_RF_TESTMODE_IDLE:
|
||||
reg = 0;
|
||||
kw2xrf_write_iregs(dev, MKW2XDMI_TX_MODE_CTRL, ®, 1);
|
||||
@ -177,5 +175,4 @@ int kw2xrf_set_test_mode(kw2xrf_t *dev, uint8_t mode)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
/** @} */
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define MRF24J40_PARAMS_H
|
||||
|
||||
#include "board.h"
|
||||
#include "mrf24j40.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -194,6 +194,9 @@ endif
|
||||
ifneq (,$(filter test_utils_netdev_eth_minimal,$(USEMODULE)))
|
||||
DIRS += test_utils/netdev_eth_minimal
|
||||
endif
|
||||
ifneq (,$(filter test_utils_netdev_ieee802154_minimal,$(USEMODULE)))
|
||||
DIRS += test_utils/netdev_ieee802154_minimal
|
||||
endif
|
||||
ifneq (,$(filter test_utils_print_stack_usage,$(USEMODULE)))
|
||||
DIRS += test_utils/print_stack_usage
|
||||
endif
|
||||
|
@ -139,6 +139,10 @@ ifneq (,$(filter test_utils_result_output,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/test_utils/result_output/Makefile.include
|
||||
endif
|
||||
|
||||
ifneq (,$(filter test_utils_netdev_ieee802154_minimal,$(USEMODULE)))
|
||||
CFLAGS += -DCONFIG_NETDEV_REGISTER_SIGNAL
|
||||
endif
|
||||
|
||||
ifneq (,$(filter ztimer,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/ztimer/Makefile.include
|
||||
endif
|
||||
|
116
sys/include/test_utils/netdev_ieee802154_minimal.h
Normal file
116
sys/include/test_utils/netdev_ieee802154_minimal.h
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup test_utils_netdev_ieee802154_minimal Minimal netdev IEEE 802.15.4 device processing
|
||||
* @ingroup sys
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
* @brief Provides basic functionalities to interact with an
|
||||
* IEEE 802.15.4 networking device which implements the
|
||||
* @ref drivers_netdev_api.
|
||||
*
|
||||
* To use the functionalities, include the module
|
||||
* `USEMODULE += test_utils_netdev_ieee802154_minimal`.
|
||||
* The test application should provide:
|
||||
* - device initialization, via the implementation of @ref netdev_ieee802154_minimal_init_devs
|
||||
* - number of devices to test, via the definition of @ref NETDEV_IEEE802154_MINIMAL_NUMOF
|
||||
* in `init_dev.h`
|
||||
*
|
||||
* @author Kevin Weiss <kevin.weiss@haw-hamburg.de>
|
||||
*/
|
||||
|
||||
#ifndef TEST_UTILS_NETDEV_IEEE802154_MINIMAL_H
|
||||
#define TEST_UTILS_NETDEV_IEEE802154_MINIMAL_H
|
||||
|
||||
#include "net/netdev.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef DOXYGEN
|
||||
/**
|
||||
* @brief Maximum number of devices to handle.
|
||||
* @note Should be provided by the application via `init_dev.h`.
|
||||
*/
|
||||
#define NETDEV_IEEE802154_MINIMAL_NUMOF
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Device-under-test initialization function.
|
||||
* @note Should be implemented by the test application
|
||||
*
|
||||
* @param[in] cb Callback to be set to @ref netdev::event_callback
|
||||
*
|
||||
* @retval 0 on success
|
||||
* @retval != 0 on error
|
||||
*/
|
||||
int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Initialize the module.
|
||||
*
|
||||
* @retval 0 on success
|
||||
* @retval != 0 on error
|
||||
*/
|
||||
int netdev_ieee802154_minimal_init(void);
|
||||
|
||||
/**
|
||||
* @brief Send a IEEE 802.15.4 frame
|
||||
* This is wrapper for the internal netdev send function, that ensures
|
||||
* all netdev functions are called from the same thread. It is safe
|
||||
* to call this function from anywhere.
|
||||
*
|
||||
* @param[in] dev Pointer to the netdev descriptor.
|
||||
* @param[in] pkt Packet to be sent.
|
||||
*
|
||||
* @retval 0 on success
|
||||
* @retval != 0 on error
|
||||
*/
|
||||
int netdev_ieee802154_minimal_send(struct netdev *dev, iolist_t *pkt);
|
||||
|
||||
/**
|
||||
* @brief Get an option from netdev minimal.
|
||||
* This is wrapper for the internal netdev get function, that ensures
|
||||
* all netdev functions are called from the same thread. It is safe
|
||||
* to call this function from anywhere.
|
||||
*
|
||||
* @param[in] dev Pointer to the netdev descriptor.
|
||||
* @param[in] opt The netopt option
|
||||
* @param[out] data Buffer to store the option
|
||||
* @param[in] max_len Maximum length of the buffer
|
||||
*
|
||||
* @retval 0 on success
|
||||
* @retval != 0 on error
|
||||
*/
|
||||
int netdev_ieee802154_minimal_get(struct netdev *dev, netopt_t opt, void *data, size_t max_len);
|
||||
|
||||
/**
|
||||
* @brief Set an option to netdev minimal.
|
||||
* This is wrapper for the internal netdev set function, that ensures
|
||||
* all netdev functions are called from the same thread. It is safe
|
||||
* to call this function from anywhere.
|
||||
*
|
||||
* @param[in] dev Pointer to the netdev descriptor.
|
||||
* @param[in] opt The netopt option
|
||||
* @param[in] data Pointer to the data to be set
|
||||
* @param[in] len Length of the data
|
||||
*
|
||||
* @retval 0 on success
|
||||
* @retval != 0 on error
|
||||
*/
|
||||
int netdev_ieee802154_minimal_set(struct netdev *dev, netopt_t opt, void *data, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* TEST_UTILS_NETDEV_IEEE802154_MINIMAL_H */
|
||||
/** @} */
|
@ -51,7 +51,7 @@ void auto_init_kw2xrf(void)
|
||||
const kw2xrf_params_t *p = &kw2xrf_params[i];
|
||||
|
||||
LOG_DEBUG("[auto_init_netif] initializing kw2xrf #%u\n", i);
|
||||
kw2xrf_setup(&kw2xrf_devs[i], (kw2xrf_params_t*) p);
|
||||
kw2xrf_setup(&kw2xrf_devs[i], (kw2xrf_params_t*) p, i);
|
||||
gnrc_netif_ieee802154_create(&_netif[i], _kw2xrf_stacks[i], KW2XRF_MAC_STACKSIZE,
|
||||
KW2XRF_MAC_PRIO, "kw2xrf",
|
||||
&kw2xrf_devs[i].netdev.netdev);
|
||||
|
@ -1,6 +1,9 @@
|
||||
ifneq (,$(filter test_utils_result_output,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/test_utils/result_output/Makefile.dep
|
||||
endif
|
||||
ifneq (,$(filter test_utils_netdev_ieee802154_minimal,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/test_utils/netdev_ieee802154_minimal/Makefile.dep
|
||||
endif
|
||||
ifneq (,$(filter test_utils_interactive_sync,$(USEMODULE)))
|
||||
USEMODULE += stdin
|
||||
endif
|
||||
|
3
sys/test_utils/netdev_ieee802154_minimal/Makefile
Normal file
3
sys/test_utils/netdev_ieee802154_minimal/Makefile
Normal file
@ -0,0 +1,3 @@
|
||||
MODULE = test_utils_netdev_ieee802154_minimal
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
7
sys/test_utils/netdev_ieee802154_minimal/Makefile.dep
Normal file
7
sys/test_utils/netdev_ieee802154_minimal/Makefile.dep
Normal file
@ -0,0 +1,7 @@
|
||||
USEMODULE += event
|
||||
USEMODULE += event_thread
|
||||
USEMODULE += l2util
|
||||
USEMODULE += od
|
||||
USEMODULE += od_string
|
||||
USEMODULE += shell
|
||||
USEMODULE += netdev
|
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* 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 test_utils_netdev_ieee802154_minimal
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Implementation of netdev IEEE 802.15.4 minimal test utility
|
||||
* module
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "event.h"
|
||||
#include "event/thread.h"
|
||||
#include "od.h"
|
||||
#include "net/ieee802154.h"
|
||||
#include "net/l2util.h"
|
||||
#include "net/netdev.h"
|
||||
#include "net/netdev/ieee802154.h"
|
||||
#include "test_utils/netdev_ieee802154_minimal.h"
|
||||
#include "netdev_ieee802154_minimal_internal.h"
|
||||
|
||||
/* provided by the test application */
|
||||
#include "init_dev.h"
|
||||
|
||||
device_reg_entry_t _devices[NETDEV_IEEE802154_MINIMAL_NUMOF];
|
||||
static uint8_t _buffer[IEEE802154_FRAME_LEN_MAX];
|
||||
static char _addr_str[IEEE802154_LONG_ADDRESS_LEN * 3];
|
||||
|
||||
struct event_pkt_desc {
|
||||
event_t event;
|
||||
struct netdev *dev;
|
||||
iolist_t *pkt;
|
||||
int res;
|
||||
};
|
||||
|
||||
struct event_getset_desc {
|
||||
event_t event;
|
||||
struct netdev *dev;
|
||||
netopt_t opt;
|
||||
void *data;
|
||||
size_t len;
|
||||
int res;
|
||||
};
|
||||
|
||||
static void _post_send_event(event_t *event)
|
||||
{
|
||||
struct event_pkt_desc *desc = (struct event_pkt_desc*) event;
|
||||
struct netdev *dev = desc->dev;
|
||||
|
||||
int res = dev->driver->send(dev, desc->pkt);
|
||||
desc->res = res;
|
||||
}
|
||||
|
||||
static void _post_get_event(event_t *event)
|
||||
{
|
||||
struct event_getset_desc *desc = (struct event_getset_desc*) event;
|
||||
struct netdev *dev = desc->dev;
|
||||
netopt_t opt = desc->opt;
|
||||
void *data = desc->data;
|
||||
size_t max_len = desc->len;
|
||||
|
||||
int res = dev->driver->get(dev, opt, data, max_len);
|
||||
desc->res = res;
|
||||
}
|
||||
|
||||
static void _post_set_event(event_t *event)
|
||||
{
|
||||
struct event_getset_desc *desc = (struct event_getset_desc*) event;
|
||||
struct netdev *dev = desc->dev;
|
||||
netopt_t opt = desc->opt;
|
||||
void *data = desc->data;
|
||||
size_t len = desc->len;
|
||||
|
||||
int res = dev->driver->set(dev, opt, data, len);
|
||||
desc->res = res;
|
||||
}
|
||||
|
||||
void _recv(netdev_t *dev)
|
||||
{
|
||||
uint8_t src[IEEE802154_LONG_ADDRESS_LEN], dst[IEEE802154_LONG_ADDRESS_LEN];
|
||||
int data_len, src_len, dst_len;
|
||||
size_t mhr_len;
|
||||
netdev_ieee802154_rx_info_t rx_info;
|
||||
le_uint16_t src_pan, dst_pan;
|
||||
|
||||
putchar('\n');
|
||||
/* receive the frame */
|
||||
data_len = dev->driver->recv(dev, _buffer, sizeof(_buffer), &rx_info);
|
||||
mhr_len = ieee802154_get_frame_hdr_len(_buffer);
|
||||
if (mhr_len == 0) {
|
||||
puts("Unexpected MHR for incoming packet");
|
||||
return;
|
||||
}
|
||||
|
||||
/* get and print addresses */
|
||||
dst_len = ieee802154_get_dst(_buffer, dst, &dst_pan);
|
||||
src_len = ieee802154_get_src(_buffer, src, &src_pan);
|
||||
|
||||
l2util_addr_to_str(dst, dst_len, _addr_str);
|
||||
printf("Dest. PAN: 0x%04x\n", byteorder_ltohs(dst_pan));
|
||||
printf("Dest. addr.: %s\n", _addr_str);
|
||||
|
||||
l2util_addr_to_str(src, src_len, _addr_str);
|
||||
printf("Src. PAN: 0x%04x\n", byteorder_ltohs(src_pan));
|
||||
printf("Src. addr.: %s\n", _addr_str);
|
||||
|
||||
/* check frame type */
|
||||
switch (_buffer[0] & IEEE802154_FCF_TYPE_MASK) {
|
||||
case IEEE802154_FCF_TYPE_BEACON:
|
||||
puts("BEACON");
|
||||
break;
|
||||
case IEEE802154_FCF_TYPE_DATA:
|
||||
puts("DATA");
|
||||
break;
|
||||
case IEEE802154_FCF_TYPE_ACK:
|
||||
puts("ACK");
|
||||
break;
|
||||
case IEEE802154_FCF_TYPE_MACCMD:
|
||||
puts("MACCMD");
|
||||
break;
|
||||
default:
|
||||
puts("UNKNOWN");
|
||||
break;
|
||||
}
|
||||
|
||||
/* print flag information */
|
||||
printf("\nSecurity: %s", _buffer[0] & IEEE802154_FCF_SECURITY_EN ? "1, " : "0, ");
|
||||
|
||||
printf("Frame pend.: %s", _buffer[0] & IEEE802154_FCF_FRAME_PEND ? "1, " : "0, ");
|
||||
|
||||
printf("ACK req.: %s", _buffer[0] & IEEE802154_FCF_ACK_REQ ? "1, " : "0, ");
|
||||
|
||||
printf("PAN comp.:%s", _buffer[0] & IEEE802154_FCF_PAN_COMP ? "1, " : "0, ");
|
||||
|
||||
printf("Version: ");
|
||||
printf("%u, ", (unsigned)((_buffer[1] & IEEE802154_FCF_VERS_MASK) >> 4));
|
||||
|
||||
printf("Seq.: %u\n", (unsigned)ieee802154_get_seq(_buffer));
|
||||
|
||||
printf("RSSI: %i, LQI: %u\n\n", rx_info.rssi, rx_info.lqi);
|
||||
|
||||
/* dump the payload */
|
||||
od_hex_dump(_buffer + mhr_len, data_len - mhr_len, 0);
|
||||
}
|
||||
|
||||
static void _isr_event_handler(event_t *event)
|
||||
{
|
||||
/* recover the netdev from the event */
|
||||
device_reg_entry_t *netdev_event = container_of(event, device_reg_entry_t, event);
|
||||
netdev_t *netdev = netdev_event->dev;
|
||||
netdev->driver->isr(netdev);
|
||||
}
|
||||
|
||||
static void _event_cb(netdev_t *dev, netdev_event_t event)
|
||||
{
|
||||
device_reg_entry_t *device = dev->context;
|
||||
|
||||
switch (event) {
|
||||
case NETDEV_EVENT_ISR:
|
||||
event_post(EVENT_PRIO_HIGHEST, &device->event);
|
||||
break;
|
||||
|
||||
case NETDEV_EVENT_RX_COMPLETE:
|
||||
_recv(dev);
|
||||
break;
|
||||
|
||||
case NETDEV_EVENT_TX_COMPLETE:
|
||||
puts("Tx complete");
|
||||
break;
|
||||
|
||||
case NETDEV_EVENT_TX_COMPLETE_DATA_PENDING:
|
||||
puts("Tx complete (with pending data)");
|
||||
break;
|
||||
|
||||
case NETDEV_EVENT_TX_MEDIUM_BUSY:
|
||||
puts("Medium busy");
|
||||
break;
|
||||
|
||||
case NETDEV_EVENT_TX_NOACK:
|
||||
puts("No ACK");
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Event: %d\n", event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Implement netdev_register_signal hook to associate registered devices to specific event
|
||||
* structures.
|
||||
*/
|
||||
void netdev_register_signal(struct netdev *dev, netdev_type_t type, uint8_t index)
|
||||
{
|
||||
(void) type;
|
||||
|
||||
if (index > NETDEV_IEEE802154_MINIMAL_NUMOF) {
|
||||
return;
|
||||
}
|
||||
printf("Device %d registered (type: %d)\n", index, type);
|
||||
dev->context = &_devices[index];
|
||||
_devices[index].dev = dev;
|
||||
_devices[index].event.handler = _isr_event_handler;
|
||||
}
|
||||
|
||||
int netdev_ieee802154_minimal_init(void)
|
||||
{
|
||||
return netdev_ieee802154_minimal_init_devs(_event_cb);
|
||||
}
|
||||
|
||||
int netdev_ieee802154_minimal_send(struct netdev *dev, iolist_t *pkt)
|
||||
{
|
||||
struct event_pkt_desc desc = {.event.handler=_post_send_event, .pkt = pkt,
|
||||
.dev = dev};
|
||||
event_post(EVENT_PRIO_HIGHEST, (event_t*) &desc);
|
||||
return desc.res;
|
||||
}
|
||||
|
||||
int netdev_ieee802154_minimal_get(struct netdev *dev, netopt_t opt, void *data, size_t max_len)
|
||||
{
|
||||
struct event_getset_desc desc = {.event.handler = _post_get_event, .opt = opt,
|
||||
.data = data, .len = max_len, .dev = dev};
|
||||
event_post(EVENT_PRIO_HIGHEST, (event_t*) &desc);
|
||||
return desc.res;
|
||||
}
|
||||
|
||||
int netdev_ieee802154_minimal_set(struct netdev *dev, netopt_t opt, void *data, size_t len)
|
||||
{
|
||||
struct event_getset_desc desc = {.event.handler = _post_set_event, .opt = opt,
|
||||
.data = data, .len = len, .dev = dev};
|
||||
event_post(EVENT_PRIO_HIGHEST, (event_t*) &desc);
|
||||
return desc.res;
|
||||
}
|
||||
|
||||
/** @} */
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 test_utils_netdev_ieee802154_minimal
|
||||
*
|
||||
* @{
|
||||
* @file
|
||||
* @brief Internal definitions for the netdev_ieee802154_minimal module
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*/
|
||||
|
||||
#ifndef NETDEV_IEEE802154_MINIMAL_INTERNAL_H
|
||||
#define NETDEV_IEEE802154_MINIMAL_INTERNAL_H
|
||||
|
||||
#include "net/netdev.h"
|
||||
#include "event.h"
|
||||
#include "init_dev.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef DOXYGEN
|
||||
|
||||
typedef struct {
|
||||
event_t event; /**< event to serve ISR */
|
||||
netdev_t *dev; /**< pointer to the device */
|
||||
} device_reg_entry_t;
|
||||
|
||||
extern device_reg_entry_t _devices[NETDEV_IEEE802154_MINIMAL_NUMOF];
|
||||
|
||||
#endif /* DOXYGEN */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NETDEV_IEEE802154_MINIMAL_INTERNAL_H */
|
||||
|
||||
/** @} */
|
284
sys/test_utils/netdev_ieee802154_minimal/shell_commands.c
Normal file
284
sys/test_utils/netdev_ieee802154_minimal/shell_commands.c
Normal file
@ -0,0 +1,284 @@
|
||||
/*
|
||||
* 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 test_utils_netdev_ieee802154_minimal
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Shell commands for netdev Eth minimal test utility module
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "iolist.h"
|
||||
#include "kernel_defines.h"
|
||||
#include "net/netdev/ieee802154.h"
|
||||
#include "net/ieee802154.h"
|
||||
#include "net/l2util.h"
|
||||
#include "od.h"
|
||||
#include "shell.h"
|
||||
|
||||
#include "netdev_ieee802154_minimal_internal.h"
|
||||
#include "test_utils/netdev_ieee802154_minimal.h"
|
||||
#include "init_dev.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
static char _addr_str[IEEE802154_LONG_ADDRESS_LEN * 3];
|
||||
|
||||
static int send(int iface, le_uint16_t dst_pan, uint8_t *dst_addr,
|
||||
size_t dst_len, char *data);
|
||||
|
||||
int ifconfig_list(int idx)
|
||||
{
|
||||
int res;
|
||||
uint8_t tmp[IEEE802154_LONG_ADDRESS_LEN];
|
||||
netdev_t *netdev = _devices[idx].dev;
|
||||
netdev_ieee802154_t *dev = container_of(netdev, netdev_ieee802154_t, netdev);
|
||||
|
||||
netopt_enable_t enable_val;
|
||||
uint16_t u16_val;
|
||||
|
||||
printf("Iface %3d HWaddr: ", idx);
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_ADDRESS, tmp, IEEE802154_SHORT_ADDRESS_LEN);
|
||||
l2util_addr_to_str(tmp, IEEE802154_SHORT_ADDRESS_LEN, _addr_str);
|
||||
printf("%s", _addr_str);
|
||||
|
||||
printf(", Long HWaddr: ");
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_ADDRESS_LONG, tmp, IEEE802154_LONG_ADDRESS_LEN);
|
||||
l2util_addr_to_str(tmp, IEEE802154_LONG_ADDRESS_LEN, _addr_str);
|
||||
printf("%s", _addr_str);
|
||||
|
||||
printf(", PAN: 0x%04x", dev->pan);
|
||||
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_ADDR_LEN, &u16_val, sizeof(u16_val));
|
||||
if (res == -ENOTSUP) {
|
||||
puts("\n Address length: ENOTSUP");
|
||||
}
|
||||
else if (res < 0) {
|
||||
printf("\n Address length: %i", (int)res);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf("\n Address length: %u", (unsigned)u16_val);
|
||||
}
|
||||
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_SRC_LEN, &u16_val, sizeof(u16_val));
|
||||
if (res == -ENOTSUP) {
|
||||
puts(", Source address length: ENOTSUP");
|
||||
}
|
||||
else if (res < 0) {
|
||||
printf(", Source address length: %i", (int)res);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf(", Source address length: %u", (unsigned)u16_val);
|
||||
}
|
||||
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_MAX_PDU_SIZE, &u16_val, sizeof(u16_val));
|
||||
if (res == -ENOTSUP) {
|
||||
puts(", Max.Payload: ENOTSUP");
|
||||
}
|
||||
else if (res < 0) {
|
||||
printf(", Max.Payload: %i", (int)res);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf(", Max.Payload: %u", (unsigned)u16_val);
|
||||
}
|
||||
printf("\n Channel: %u", dev->chan);
|
||||
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_CHANNEL_PAGE, &u16_val, sizeof(u16_val));
|
||||
if (res == -ENOTSUP) {
|
||||
puts(", Ch.page: ENOTSUP");
|
||||
}
|
||||
else if (res < 0) {
|
||||
printf(", Ch.page: %i", (int)res);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf(", Ch.page: %u", (unsigned)u16_val);
|
||||
}
|
||||
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_TX_POWER, &u16_val, sizeof(u16_val));
|
||||
if (res == -ENOTSUP) {
|
||||
puts(", TXPower: ENOTSUP");
|
||||
}
|
||||
else if (res < 0) {
|
||||
printf(", TXPower: %i", (int)res);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf(", TXPower: %u", (unsigned)u16_val);
|
||||
}
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_IS_WIRED, &u16_val, sizeof(u16_val));
|
||||
if (res < 0) {
|
||||
puts(", wireless");
|
||||
}
|
||||
else {
|
||||
puts(", wired");
|
||||
}
|
||||
|
||||
printf(" ");
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_PRELOADING, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" PRELOAD");
|
||||
}
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_AUTOACK, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" AUTOACK");
|
||||
}
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_RAWMODE, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" RAW");
|
||||
}
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_AUTOCCA, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" AUTOCCA");
|
||||
}
|
||||
res = netdev_ieee802154_minimal_get(netdev, NETOPT_CSMA, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" CSMA");
|
||||
}
|
||||
puts("");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_ifconfig(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
for (unsigned int i = 0; i < NETDEV_IEEE802154_MINIMAL_NUMOF; i++) {
|
||||
ifconfig_list(i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void txtsnd_usage(char *cmd_name)
|
||||
{
|
||||
printf("usage: %s <iface> [<pan>] <addr> <text>\n", cmd_name);
|
||||
}
|
||||
|
||||
static int cmd_txtsnd(int argc, char **argv)
|
||||
{
|
||||
char *text;
|
||||
uint8_t addr[IEEE802154_LONG_ADDRESS_LEN];
|
||||
int iface, idx = 2;
|
||||
size_t res;
|
||||
le_uint16_t pan = { 0 };
|
||||
|
||||
switch (argc) {
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
res = l2util_addr_from_str(argv[idx++], pan.u8);
|
||||
if ((res == 0) || (res > sizeof(pan))) {
|
||||
txtsnd_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
pan.u16 = byteorder_swaps(pan.u16);
|
||||
break;
|
||||
default:
|
||||
txtsnd_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
iface = atoi(argv[1]);
|
||||
res = l2util_addr_from_str(argv[idx++], addr);
|
||||
if (res == 0) {
|
||||
txtsnd_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
text = argv[idx++];
|
||||
return send(iface, pan, addr, res, text);
|
||||
}
|
||||
|
||||
static int send(int iface, le_uint16_t dst_pan, uint8_t *dst, size_t dst_len,
|
||||
char *data)
|
||||
{
|
||||
int res;
|
||||
netdev_ieee802154_t *dev;
|
||||
uint8_t *src;
|
||||
size_t src_len;
|
||||
uint8_t mhr[IEEE802154_MAX_HDR_LEN];
|
||||
uint8_t flags;
|
||||
le_uint16_t src_pan;
|
||||
|
||||
if (((unsigned)iface) > (NETDEV_IEEE802154_MINIMAL_NUMOF - 1)) {
|
||||
printf("txtsnd: %d is not an interface\n", iface);
|
||||
return 1;
|
||||
}
|
||||
|
||||
iolist_t iol_data = {
|
||||
.iol_base = data,
|
||||
.iol_len = strlen(data)
|
||||
};
|
||||
|
||||
dev = container_of(_devices[iface].dev, netdev_ieee802154_t, netdev);
|
||||
flags = (uint8_t)(dev->flags & NETDEV_IEEE802154_SEND_MASK);
|
||||
flags |= IEEE802154_FCF_TYPE_DATA;
|
||||
src_pan = byteorder_btols(byteorder_htons(dev->pan));
|
||||
if (dst_pan.u16 == 0) {
|
||||
dst_pan = src_pan;
|
||||
}
|
||||
if (dev->flags & NETDEV_IEEE802154_SRC_MODE_LONG) {
|
||||
src_len = 8;
|
||||
src = dev->long_addr;
|
||||
}
|
||||
else {
|
||||
src_len = 2;
|
||||
src = dev->short_addr;
|
||||
}
|
||||
/* fill MAC header, seq should be set by device */
|
||||
if ((res = ieee802154_set_frame_hdr(mhr, src, src_len,
|
||||
dst, dst_len,
|
||||
src_pan, dst_pan,
|
||||
flags, dev->seq++)) < 0) {
|
||||
puts("txtsnd: Error preperaring frame");
|
||||
return 1;
|
||||
}
|
||||
|
||||
iolist_t iol_hdr = {
|
||||
.iol_next = &iol_data,
|
||||
.iol_base = mhr,
|
||||
.iol_len = (size_t)res
|
||||
};
|
||||
|
||||
be_uint16_t _dst_pan = byteorder_ltobs(dst_pan);
|
||||
l2util_addr_to_str(dst, dst_len, _addr_str);
|
||||
printf("txtsnd: sending %u bytes to %s", (unsigned)iol_data.iol_len, _addr_str);
|
||||
l2util_addr_to_str((uint8_t*) &_dst_pan, sizeof(dst_pan), _addr_str);
|
||||
printf(" (PAN: %s)\n", _addr_str);
|
||||
|
||||
res = netdev_ieee802154_minimal_send(&dev->netdev, &iol_hdr);
|
||||
|
||||
if (res < 0) {
|
||||
puts("txtsnd: Error on sending");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* declare shell commands */
|
||||
SHELL_COMMAND(ifconfig, "Configure the device", cmd_ifconfig);
|
||||
SHELL_COMMAND(txtsnd, "Send an IEEE 802.15.4 packet", cmd_txtsnd);
|
||||
|
||||
/** @} */
|
@ -1,10 +1,15 @@
|
||||
INCLUDES += -I$(APPDIR)
|
||||
BOARD ?= openmote-b
|
||||
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += test_utils_netdev_ieee802154_minimal
|
||||
|
||||
# the radio driver to test
|
||||
USEMODULE += at86rf215
|
||||
USEMODULE += at86rf215_batmon
|
||||
USEMODULE += netdev_ieee802154_rx_timestamp
|
||||
|
||||
CFLAGS += -DCONFIG_NETDEV_REGISTER_SIGNAL
|
||||
CFLAGS += -DEVENT_THREAD_STACKSIZE_DEFAULT=1024
|
||||
|
||||
include ../driver_netdev_common/Makefile.netdev.mk
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -1,35 +1,15 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega1284p \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
atxmega-a3bu-xplained \
|
||||
bluepill-stm32f030c8 \
|
||||
derfmega128 \
|
||||
i-nucleo-lrwan1 \
|
||||
mega-xplained \
|
||||
microduino-corerf \
|
||||
msb-430 \
|
||||
msb-430h \
|
||||
atmega328p \
|
||||
nucleo-f031k6 \
|
||||
nucleo-f042k6 \
|
||||
nucleo-f303k8 \
|
||||
nucleo-f334r8 \
|
||||
nucleo-l011k4 \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
samd10-xmini \
|
||||
slstk3400a \
|
||||
stk3200 \
|
||||
stm32f030f4-demo \
|
||||
stm32f0discovery \
|
||||
stm32l0538-disco \
|
||||
telosb \
|
||||
waspmote-pro \
|
||||
zigduino \
|
||||
z1
|
||||
#
|
||||
|
16
tests/driver_at86rf215/README.md
Normal file
16
tests/driver_at86rf215/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
# About
|
||||
This is a manual test application for the AT86RF215 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)
|
||||
- RESET
|
||||
- SLEEP
|
||||
- INT (external interrupt)
|
||||
|
||||
# Usage
|
||||
For testing the radio driver you can use the ifconfig and txtsnd shell commands
|
||||
that are included in this application.
|
37
tests/driver_at86rf215/init_dev.h
Normal file
37
tests/driver_at86rf215/init_dev.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 AT86RF215 IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*/
|
||||
#ifndef INIT_DEV_H
|
||||
#define INIT_DEV_H
|
||||
|
||||
#include "at86rf215_params.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AT86RF215_NUM ARRAY_SIZE(at86rf215_params)
|
||||
/* AT86RF215 contains one sub-GHz and one 2.4 GHz driver */
|
||||
#define NETDEV_IEEE802154_MINIMAL_NUMOF (2 * AT86RF215_NUM)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* INIT_DEV_H */
|
||||
/** @} */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 ML!PA Consulting GmbH
|
||||
* 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
|
||||
@ -11,9 +11,10 @@
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Test application for at86rf215 driver
|
||||
* @brief Test application for AT86RF215 IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
@ -21,28 +22,20 @@
|
||||
|
||||
#include "at86rf215.h"
|
||||
#include "at86rf215_internal.h"
|
||||
#include "thread.h"
|
||||
#include "at86rf215_params.h"
|
||||
#include "init_dev.h"
|
||||
#include "shell.h"
|
||||
#include "sys/bus.h"
|
||||
#include "test_utils/netdev_ieee802154_minimal.h"
|
||||
|
||||
#include "net/gnrc/pktdump.h"
|
||||
#include "net/gnrc/netif.h"
|
||||
#include "net/gnrc.h"
|
||||
#include "thread.h"
|
||||
#include "event.h"
|
||||
#include "event/thread.h"
|
||||
#include "sys/bus.h"
|
||||
#include "od.h"
|
||||
|
||||
static char batmon_stack[THREAD_STACKSIZE_MAIN];
|
||||
static at86rf215_t *dev;
|
||||
static at86rf215_t at86rf215[NETDEV_IEEE802154_MINIMAL_NUMOF];
|
||||
|
||||
void netdev_register_signal(netdev_t *netdev, netdev_type_t type, uint8_t index)
|
||||
{
|
||||
(void) index;
|
||||
netdev_ieee802154_t *netdev_ieee802154 = container_of(netdev,
|
||||
netdev_ieee802154_t,
|
||||
netdev);
|
||||
if (type == NETDEV_AT86RF215 && !dev) {
|
||||
dev = container_of(netdev_ieee802154, at86rf215_t, netdev);
|
||||
}
|
||||
}
|
||||
static char batmon_stack[THREAD_STACKSIZE_MAIN];
|
||||
|
||||
void *batmon_thread(void *arg)
|
||||
{
|
||||
@ -65,21 +58,15 @@ static int cmd_enable_batmon(int argc, char **argv)
|
||||
{
|
||||
int res;
|
||||
uint16_t voltage;
|
||||
gnrc_netif_t* netif = gnrc_netif_iter(NULL);
|
||||
netdev_t *netdev = &(at86rf215[0].netdev.netdev);
|
||||
|
||||
if (argc < 2) {
|
||||
printf("usage: %s <treshold_mV>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (netif == NULL) {
|
||||
puts("no netif found");
|
||||
return -1;
|
||||
}
|
||||
|
||||
voltage = atoi(argv[1]);
|
||||
res = gnrc_netapi_set(netif->pid, NETOPT_BATMON, 0,
|
||||
&voltage, sizeof(voltage));
|
||||
res = netdev->driver->set(netdev, NETOPT_BATMON, &voltage, sizeof(voltage));
|
||||
|
||||
if (res != sizeof(voltage)) {
|
||||
puts("value out of range");
|
||||
@ -96,17 +83,13 @@ static int cmd_set_trim(int argc, char **argv)
|
||||
}
|
||||
|
||||
uint8_t trim = atoi(argv[1]);
|
||||
at86rf215_t *dev = at86rf215;
|
||||
|
||||
if (trim > 0xF) {
|
||||
puts("Trim value out of range");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (dev == NULL) {
|
||||
puts("No at86rf215 radio found");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("setting trim to %u fF\n", 300U * trim);
|
||||
at86rf215_set_trim(dev, trim);
|
||||
|
||||
@ -127,6 +110,7 @@ static int cmd_set_clock_out(int argc, char **argv)
|
||||
};
|
||||
|
||||
at86rf215_clko_freq_t freq = AT86RF215_CLKO_26_MHz;
|
||||
at86rf215_t *dev = at86rf215;
|
||||
|
||||
if (argc > 1) {
|
||||
unsigned tmp = 0xFF;
|
||||
@ -150,11 +134,6 @@ static int cmd_set_clock_out(int argc, char **argv)
|
||||
freq = tmp;
|
||||
}
|
||||
|
||||
if (dev == NULL) {
|
||||
puts("No at86rf215 radio found");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Clock output set to %s %s\n", keys[freq], freq ? "MHz" : "");
|
||||
at86rf215_set_clock_output(dev, AT86RF215_CLKO_4mA, freq);
|
||||
|
||||
@ -165,6 +144,7 @@ static int cmd_get_random(int argc, char **argv)
|
||||
{
|
||||
uint8_t values;
|
||||
uint8_t buffer[256];
|
||||
at86rf215_t *dev = at86rf215;
|
||||
|
||||
if (argc > 1) {
|
||||
values = atoi(argv[1]);
|
||||
@ -178,11 +158,6 @@ static int cmd_get_random(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (dev == NULL) {
|
||||
puts("No at86rf215 radio found");
|
||||
return 1;
|
||||
}
|
||||
|
||||
at86rf215_get_random(dev, buffer, values);
|
||||
|
||||
od_hex_dump(buffer, values, 0);
|
||||
@ -190,6 +165,68 @@ static int cmd_get_random(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_init(void)
|
||||
{
|
||||
/* create battery monitor thread */
|
||||
thread_create(batmon_stack, sizeof(batmon_stack), THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST, batmon_thread, NULL, "batmon");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _init_driver(netdev_t *netdev, netdev_event_cb_t cb)
|
||||
{
|
||||
/* set the application-provided callback */
|
||||
netdev->event_callback = cb;
|
||||
|
||||
/* initialize the device driver */
|
||||
return netdev->driver->init(netdev);
|
||||
}
|
||||
|
||||
int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) {
|
||||
unsigned idx = 0;
|
||||
|
||||
puts("Initializing AT86RF215 at86rf215");
|
||||
|
||||
for (unsigned i = 0; i < AT86RF215_NUM; i++) {
|
||||
at86rf215_t *at86rf215_subghz = NULL;
|
||||
at86rf215_t *at86rf215_24ghz = NULL;
|
||||
|
||||
printf("%d out of %d\n", i + 1, AT86RF215_NUM);
|
||||
|
||||
if (IS_USED(MODULE_AT86RF215_SUBGHZ)) {
|
||||
puts("Sub-GHz");
|
||||
at86rf215_subghz = &at86rf215[idx];
|
||||
idx++;
|
||||
}
|
||||
|
||||
if (IS_USED(MODULE_AT86RF215_24GHZ)) {
|
||||
puts("2.4 GHz");
|
||||
at86rf215_24ghz = &at86rf215[idx];
|
||||
idx++;
|
||||
}
|
||||
|
||||
/* setup the specific driver */
|
||||
at86rf215_setup(at86rf215_subghz, at86rf215_24ghz, &at86rf215_params[i], i);
|
||||
|
||||
int res = 0;
|
||||
if (at86rf215_subghz) {
|
||||
res = _init_driver(&at86rf215_subghz->netdev.netdev, cb);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
if (at86rf215_24ghz) {
|
||||
res = _init_driver(&at86rf215_24ghz->netdev.netdev, cb);
|
||||
if (res) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "batmon", "Enable the battery monitor", cmd_enable_batmon },
|
||||
{ "set_trim", "at86rf215: Set the trim value of the crystal oscillator", cmd_set_trim },
|
||||
@ -200,16 +237,21 @@ static const shell_command_t shell_commands[] = {
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* enable pktdump output */
|
||||
gnrc_netreg_entry_t dump = GNRC_NETREG_ENTRY_INIT_PID(GNRC_NETREG_DEMUX_CTX_ALL,
|
||||
gnrc_pktdump_pid);
|
||||
gnrc_netreg_register(GNRC_NETTYPE_UNDEF, &dump);
|
||||
puts("Test application for AT86RF215 IEEE 802.15.4 device driver");
|
||||
|
||||
int res = netdev_ieee802154_minimal_init();
|
||||
if (res) {
|
||||
puts("Error initializing at86rf215");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* create battery monitor thread */
|
||||
thread_create(batmon_stack, sizeof(batmon_stack), THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST, batmon_thread, NULL, "batmon");
|
||||
|
||||
/* start the shell */
|
||||
puts("Initialization successful - starting the shell now");
|
||||
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
INCLUDES += -I$(APPDIR)
|
||||
BOARD ?= samr21-xpro
|
||||
|
||||
include ../Makefile.tests_common
|
||||
|
||||
DISABLE_MODULE += auto_init_at86rf2xx
|
||||
|
||||
USEMODULE += od
|
||||
USEMODULE += shell
|
||||
USEMODULE += shell_commands
|
||||
USEMODULE += ps
|
||||
USEMODULE += test_utils_netdev_ieee802154_minimal
|
||||
|
||||
# define the driver to be used for selected boards
|
||||
ifneq (,$(filter samr21-xpro,$(BOARD)))
|
||||
@ -24,4 +22,6 @@ DRIVER ?= at86rf231
|
||||
# include the selected driver
|
||||
USEMODULE += $(DRIVER)
|
||||
|
||||
CFLAGS += -DEVENT_THREAD_STACKSIZE_DEFAULT=1024
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -3,9 +3,8 @@ BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-leonardo \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
nucleo-f031k6 \
|
||||
atmega328p \
|
||||
nucleo-l011k4 \
|
||||
samd10-xmini \
|
||||
stm32f030f4-demo \
|
||||
|
@ -1,16 +1,16 @@
|
||||
# About
|
||||
This is a manual test application for the AT86RF2xx radio driver
|
||||
This is a manual test application for the AT86RF2xx 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 (ship select)
|
||||
- CS (chip select)
|
||||
- RESET
|
||||
- SLEEP
|
||||
- INT (external interrupt)
|
||||
|
||||
# Usage
|
||||
For testing the radio driver you can use the netif and txtsnd shell commands
|
||||
For testing the radio driver you can use the ifconfig and txtsnd shell commands
|
||||
that are included in this application.
|
||||
|
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Freie Universität Berlin
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
void print_addr(uint8_t *addr, size_t addr_len)
|
||||
{
|
||||
for (size_t i = 0; i < addr_len; i++) {
|
||||
if (i != 0) {
|
||||
printf(":");
|
||||
}
|
||||
printf("%02x", (unsigned)addr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/** @} */
|
@ -1,335 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Freie Universität Berlin
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "at86rf2xx_internal.h"
|
||||
#include "common.h"
|
||||
#include "net/ieee802154.h"
|
||||
#include "net/netdev/ieee802154.h"
|
||||
#include "od.h"
|
||||
#include "test_utils/expect.h"
|
||||
|
||||
#define _MAX_ADDR_LEN (8)
|
||||
#define MAC_VECTOR_SIZE (2) /* mhr + payload */
|
||||
|
||||
static size_t _parse_addr(uint8_t *out, size_t out_len, const char *in);
|
||||
static int send(int iface, le_uint16_t dst_pan, uint8_t *dst_addr,
|
||||
size_t dst_len, char *data);
|
||||
|
||||
int ifconfig_list(int idx)
|
||||
{
|
||||
int res;
|
||||
netdev_ieee802154_t *dev = &devs[idx].netdev;
|
||||
|
||||
int (*get)(netdev_t *, netopt_t, void *, size_t) = dev->netdev.driver->get;
|
||||
netopt_enable_t enable_val;
|
||||
uint16_t u16_val;
|
||||
|
||||
printf("Iface %3d HWaddr: ", idx);
|
||||
print_addr(dev->short_addr, IEEE802154_SHORT_ADDRESS_LEN);
|
||||
printf(", Long HWaddr: ");
|
||||
print_addr(dev->long_addr, IEEE802154_LONG_ADDRESS_LEN);
|
||||
printf(", PAN: 0x%04x", dev->pan);
|
||||
|
||||
res = get(&dev->netdev, NETOPT_ADDR_LEN, &u16_val, sizeof(u16_val));
|
||||
if (res < 0) {
|
||||
puts("(err)");
|
||||
return 1;
|
||||
}
|
||||
printf("\n Address length: %u", (unsigned)u16_val);
|
||||
|
||||
res = get(&dev->netdev, NETOPT_SRC_LEN, &u16_val, sizeof(u16_val));
|
||||
if (res < 0) {
|
||||
puts("(err)");
|
||||
return 1;
|
||||
}
|
||||
printf(", Source address length: %u", (unsigned)u16_val);
|
||||
|
||||
res = get(&dev->netdev, NETOPT_MAX_PDU_SIZE, &u16_val,
|
||||
sizeof(u16_val));
|
||||
if (res < 0) {
|
||||
puts("(err)");
|
||||
return 1;
|
||||
}
|
||||
printf(", Max.Payload: %u", (unsigned)u16_val);
|
||||
printf("\n Channel: %u", dev->chan);
|
||||
|
||||
res = get(&dev->netdev, NETOPT_CHANNEL_PAGE, &u16_val, sizeof(u16_val));
|
||||
if (res < 0) {
|
||||
puts("(err)");
|
||||
return 1;
|
||||
}
|
||||
printf(", Ch.page: %u", (unsigned)u16_val);
|
||||
|
||||
res = get(&dev->netdev, NETOPT_TX_POWER, &u16_val, sizeof(u16_val));
|
||||
if (res < 0) {
|
||||
puts("(err)");
|
||||
return 1;
|
||||
}
|
||||
printf(", TXPower: %d dBm", (int)u16_val);
|
||||
res = get(&dev->netdev, NETOPT_IS_WIRED, &u16_val, sizeof(u16_val));
|
||||
if (res < 0) {
|
||||
puts(", wireless");
|
||||
}
|
||||
else {
|
||||
puts(", wired");
|
||||
}
|
||||
|
||||
printf(" ");
|
||||
res = get(&dev->netdev, NETOPT_PRELOADING, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" PRELOAD");
|
||||
}
|
||||
res = get(&dev->netdev, NETOPT_AUTOACK, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" AUTOACK");
|
||||
}
|
||||
res = get(&dev->netdev, NETOPT_RAWMODE, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" RAW");
|
||||
}
|
||||
res = get(&dev->netdev, NETOPT_AUTOCCA, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" AUTOCCA");
|
||||
}
|
||||
res = get(&dev->netdev, NETOPT_CSMA, &enable_val,
|
||||
sizeof(netopt_enable_t));
|
||||
if ((res > 0) && (enable_val == NETOPT_ENABLE)) {
|
||||
printf(" CSMA");
|
||||
}
|
||||
puts("");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ifconfig(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
for (unsigned int i = 0; i < AT86RF2XX_NUM; i++) {
|
||||
ifconfig_list(i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void txtsnd_usage(char *cmd_name)
|
||||
{
|
||||
printf("usage: %s <iface> [<pan>] <addr> <text>\n", cmd_name);
|
||||
}
|
||||
|
||||
int txtsnd(int argc, char **argv)
|
||||
{
|
||||
char *text;
|
||||
uint8_t addr[_MAX_ADDR_LEN];
|
||||
int iface, idx = 2;
|
||||
size_t res;
|
||||
le_uint16_t pan = { 0 };
|
||||
|
||||
switch (argc) {
|
||||
case 4:
|
||||
break;
|
||||
case 5:
|
||||
res = _parse_addr((uint8_t *)&pan, sizeof(pan), argv[idx++]);
|
||||
if ((res == 0) || (res > sizeof(pan))) {
|
||||
txtsnd_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
pan.u16 = byteorder_swaps(pan.u16);
|
||||
break;
|
||||
default:
|
||||
txtsnd_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
iface = atoi(argv[1]);
|
||||
res = _parse_addr(addr, sizeof(addr), argv[idx++]);
|
||||
if (res == 0) {
|
||||
txtsnd_usage(argv[0]);
|
||||
return 1;
|
||||
}
|
||||
text = argv[idx++];
|
||||
return send(iface, pan, addr, res, text);
|
||||
}
|
||||
|
||||
static inline int _dehex(char c, int default_)
|
||||
{
|
||||
if ('0' <= c && c <= '9') {
|
||||
return c - '0';
|
||||
}
|
||||
else if ('A' <= c && c <= 'F') {
|
||||
return c - 'A' + 10;
|
||||
}
|
||||
else if ('a' <= c && c <= 'f') {
|
||||
return c - 'a' + 10;
|
||||
}
|
||||
else {
|
||||
return default_;
|
||||
}
|
||||
}
|
||||
|
||||
static size_t _parse_addr(uint8_t *out, size_t out_len, const char *in)
|
||||
{
|
||||
const char *end_str = in;
|
||||
uint8_t *out_end = out;
|
||||
size_t count = 0;
|
||||
int assert_cell = 1;
|
||||
|
||||
if (!in || !*in) {
|
||||
return 0;
|
||||
}
|
||||
while (end_str[1]) {
|
||||
++end_str;
|
||||
}
|
||||
|
||||
while (end_str >= in) {
|
||||
int a = 0, b = _dehex(*end_str--, -1);
|
||||
if (b < 0) {
|
||||
if (assert_cell) {
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
assert_cell = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
assert_cell = 0;
|
||||
|
||||
if (end_str >= in) {
|
||||
a = _dehex(*end_str--, 0);
|
||||
}
|
||||
|
||||
if (++count > out_len) {
|
||||
return 0;
|
||||
}
|
||||
*out_end++ = (a << 4) | b;
|
||||
}
|
||||
if (assert_cell) {
|
||||
return 0;
|
||||
}
|
||||
/* out is reversed */
|
||||
|
||||
while (out < --out_end) {
|
||||
uint8_t tmp = *out_end;
|
||||
*out_end = *out;
|
||||
*out++ = tmp;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int send(int iface, le_uint16_t dst_pan, uint8_t *dst, size_t dst_len,
|
||||
char *data)
|
||||
{
|
||||
int res;
|
||||
netdev_ieee802154_t *dev;
|
||||
uint8_t *src;
|
||||
size_t src_len;
|
||||
uint8_t mhr[IEEE802154_MAX_HDR_LEN];
|
||||
uint8_t flags;
|
||||
le_uint16_t src_pan;
|
||||
|
||||
if (((unsigned)iface) > (AT86RF2XX_NUM - 1)) {
|
||||
printf("txtsnd: %d is not an interface\n", iface);
|
||||
return 1;
|
||||
}
|
||||
|
||||
iolist_t iol_data = {
|
||||
.iol_base = data,
|
||||
.iol_len = strlen(data)
|
||||
};
|
||||
|
||||
dev = &devs[iface].netdev;
|
||||
flags = (uint8_t)(dev->flags & NETDEV_IEEE802154_SEND_MASK);
|
||||
flags |= IEEE802154_FCF_TYPE_DATA;
|
||||
src_pan = byteorder_btols(byteorder_htons(dev->pan));
|
||||
if (dst_pan.u16 == 0) {
|
||||
dst_pan = src_pan;
|
||||
}
|
||||
if (dev->flags & NETDEV_IEEE802154_SRC_MODE_LONG) {
|
||||
src_len = 8;
|
||||
src = dev->long_addr;
|
||||
}
|
||||
else {
|
||||
src_len = 2;
|
||||
src = dev->short_addr;
|
||||
}
|
||||
/* fill MAC header, seq should be set by device */
|
||||
if ((res = ieee802154_set_frame_hdr(mhr, src, src_len,
|
||||
dst, dst_len,
|
||||
src_pan, dst_pan,
|
||||
flags, dev->seq++)) < 0) {
|
||||
puts("txtsnd: Error preperaring frame");
|
||||
return 1;
|
||||
}
|
||||
|
||||
iolist_t iol_hdr = {
|
||||
.iol_next = &iol_data,
|
||||
.iol_base = mhr,
|
||||
.iol_len = (size_t)res
|
||||
};
|
||||
|
||||
res = dev->netdev.driver->send(&dev->netdev, &iol_hdr);
|
||||
if (res < 0) {
|
||||
puts("txtsnd: Error on sending");
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
printf("txtsnd: send %u bytes to ", (unsigned)iol_data.iol_len);
|
||||
print_addr(dst, dst_len);
|
||||
printf(" (PAN: ");
|
||||
print_addr((uint8_t *)&dst_pan, sizeof(dst_pan));
|
||||
puts(")");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if AT86RF2XX_RANDOM_NUMBER_GENERATOR
|
||||
void random_net_api(uint8_t idx, uint32_t *value)
|
||||
{
|
||||
netdev_ieee802154_t *dev = &devs[idx].netdev;
|
||||
int retval = dev->netdev.driver->get(&dev->netdev, NETOPT_RANDOM,
|
||||
value, sizeof(uint32_t));
|
||||
if (retval < 0) {
|
||||
printf("get(NETOPT_RANDOM) failed: %s\n", strerror(-retval));
|
||||
}
|
||||
else {
|
||||
expect(retval == sizeof(*value));
|
||||
}
|
||||
}
|
||||
|
||||
int random_by_at86rf2xx(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
for (unsigned int i = 0; i < AT86RF2XX_NUM; i++) {
|
||||
uint32_t test = 0;
|
||||
at86rf2xx_get_random(&devs[i], (uint8_t *)&test, sizeof(test));
|
||||
printf("Random number for device %u via native API: %" PRIx32 "\n", i, test);
|
||||
test = 0;
|
||||
random_net_api(i, &test);
|
||||
printf("Random number for device %u via netopt: %" PRIx32 "\n", i, test);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
/** @} */
|
@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2016 Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*
|
||||
* 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 Common header for at86rf2xx tests
|
||||
*
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "at86rf2xx.h"
|
||||
#include "at86rf2xx_params.h"
|
||||
#include "net/netdev.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Application-internal functions and variables for at86rf2xx tests
|
||||
* @internal
|
||||
* @{
|
||||
*/
|
||||
#define AT86RF2XX_NUM ARRAY_SIZE(at86rf2xx_params)
|
||||
|
||||
extern at86rf2xx_t devs[AT86RF2XX_NUM];
|
||||
|
||||
void recv(netdev_t *dev);
|
||||
int ifconfig(int argc, char **argv);
|
||||
int txtsnd(int argc, char **argv);
|
||||
#if AT86RF2XX_RANDOM_NUMBER_GENERATOR
|
||||
int random_by_at86rf2xx(int argc, char **argv);
|
||||
#endif
|
||||
void print_addr(uint8_t *addr, size_t addr_len);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COMMON_H */
|
||||
/** @} */
|
36
tests/driver_at86rf2xx/init_dev.h
Normal file
36
tests/driver_at86rf2xx/init_dev.h
Normal file
@ -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 AT86RF2XX IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*/
|
||||
#ifndef INIT_DEV_H
|
||||
#define INIT_DEV_H
|
||||
|
||||
#include "at86rf2xx_params.h"
|
||||
#include "kernel_defines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AT86RF2XX_NUM ARRAY_SIZE(at86rf2xx_params)
|
||||
#define NETDEV_IEEE802154_MINIMAL_NUMOF AT86RF2XX_NUM
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* INIT_DEV_H */
|
||||
/** @} */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Freie Universität Berlin
|
||||
* 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
|
||||
@ -11,110 +11,92 @@
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Test application for AT86RF2xx network device driver
|
||||
* @brief Test application for AT86RF2XX IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "net/netdev.h"
|
||||
#include "at86rf2xx.h"
|
||||
#include "at86rf2xx_params.h"
|
||||
#include "at86rf2xx_internal.h"
|
||||
#include "init_dev.h"
|
||||
#include "net/ieee802154.h"
|
||||
#include "net/netdev/ieee802154.h"
|
||||
#include "shell.h"
|
||||
#include "thread.h"
|
||||
#include "xtimer.h"
|
||||
#include "test_utils/netdev_ieee802154_minimal.h"
|
||||
#include "test_utils/expect.h"
|
||||
|
||||
#include "common.h"
|
||||
static at86rf2xx_t at86rf2xx[AT86RF2XX_NUM];
|
||||
|
||||
#define _STACKSIZE (THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF)
|
||||
#define MSG_TYPE_ISR (0x3456)
|
||||
|
||||
static char stack[_STACKSIZE];
|
||||
static kernel_pid_t _recv_pid;
|
||||
|
||||
at86rf2xx_t devs[AT86RF2XX_NUM];
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "ifconfig", "Configure netdev", ifconfig },
|
||||
{ "txtsnd", "Send IEEE 802.15.4 packet", txtsnd },
|
||||
#if AT86RF2XX_RANDOM_NUMBER_GENERATOR
|
||||
{ "random", "Get a value from Random Number Generator", random_by_at86rf2xx },
|
||||
#endif
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static void _event_cb(netdev_t *dev, netdev_event_t event)
|
||||
void random_net_api(uint8_t idx, uint32_t *value)
|
||||
{
|
||||
if (event == NETDEV_EVENT_ISR) {
|
||||
msg_t msg;
|
||||
|
||||
msg.type = MSG_TYPE_ISR;
|
||||
msg.content.ptr = dev;
|
||||
|
||||
if (msg_send(&msg, _recv_pid) <= 0) {
|
||||
puts("gnrc_netdev: possibly lost interrupt.");
|
||||
}
|
||||
netdev_ieee802154_t *dev = &at86rf2xx[idx].netdev;
|
||||
dev->netdev.driver->get(&dev->netdev, NETOPT_RANDOM, value, sizeof(uint32_t));
|
||||
int retval = dev->netdev.driver->get(&dev->netdev, NETOPT_RANDOM,
|
||||
value, sizeof(uint32_t));
|
||||
if (retval < 0) {
|
||||
printf("get(NETOPT_RANDOM) failed: %s\n", strerror(-retval));
|
||||
}
|
||||
else {
|
||||
switch (event) {
|
||||
case NETDEV_EVENT_RX_COMPLETE:
|
||||
{
|
||||
recv(dev);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
puts("Unexpected event received");
|
||||
break;
|
||||
}
|
||||
expect(retval == sizeof(*value));
|
||||
}
|
||||
}
|
||||
|
||||
void *_recv_thread(void *arg)
|
||||
int random_by_at86rf2xx(int argc, char **argv)
|
||||
{
|
||||
(void)arg;
|
||||
while (1) {
|
||||
msg_t msg;
|
||||
msg_receive(&msg);
|
||||
if (msg.type == MSG_TYPE_ISR) {
|
||||
netdev_t *dev = msg.content.ptr;
|
||||
dev->driver->isr(dev);
|
||||
}
|
||||
else {
|
||||
puts("unexpected message type");
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
for (unsigned int i = 0; i < AT86RF2XX_NUM; i++) {
|
||||
uint32_t test = 0;
|
||||
at86rf2xx_get_random(&at86rf2xx[i], (uint8_t *)&test, sizeof(test));
|
||||
printf("Random number for device %u via native API: %" PRIx32 "\n", i, test);
|
||||
test = 0;
|
||||
random_net_api(i, &test);
|
||||
printf("Random number for device %u via netopt: %" PRIx32 "\n", i, test);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
{ "random", "Get a value from Random Number Generator", random_by_at86rf2xx },
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
#endif
|
||||
|
||||
int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) {
|
||||
|
||||
puts("Initializing AT86RF2XX devices");
|
||||
|
||||
for (unsigned i = 0; i < AT86RF2XX_NUM; i++) {
|
||||
printf("%d out of %d\n", i + 1, AT86RF2XX_NUM);
|
||||
/* setup the specific driver */
|
||||
at86rf2xx_setup(&at86rf2xx[i], &at86rf2xx_params[i], i);
|
||||
|
||||
/* set the application-provided callback */
|
||||
at86rf2xx[i].netdev.netdev.event_callback = cb;
|
||||
|
||||
/* initialize the device driver */
|
||||
int res = at86rf2xx[i].netdev.netdev.driver->init(&at86rf2xx[i].netdev.netdev);
|
||||
if (res != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
puts("AT86RF2xx device driver test");
|
||||
unsigned dev_success = 0;
|
||||
for (unsigned i = 0; i < AT86RF2XX_NUM; i++) {
|
||||
const at86rf2xx_params_t *p = &at86rf2xx_params[i];
|
||||
netdev_t *dev = &devs[i].netdev.netdev;
|
||||
puts("Test application for AT86RF2XX IEEE 802.15.4 device driver");
|
||||
|
||||
printf("Initializing AT86RF2xx radio at SPI_%d\n", p->spi);
|
||||
at86rf2xx_setup(&devs[i], p, i);
|
||||
dev->event_callback = _event_cb;
|
||||
if (dev->driver->init(dev) < 0) {
|
||||
continue;
|
||||
}
|
||||
dev_success++;
|
||||
}
|
||||
|
||||
if (!dev_success) {
|
||||
puts("No device could be initialized");
|
||||
return 1;
|
||||
}
|
||||
|
||||
_recv_pid = thread_create(stack, sizeof(stack), THREAD_PRIORITY_MAIN - 1,
|
||||
THREAD_CREATE_STACKTEST, _recv_thread, NULL,
|
||||
"recv_thread");
|
||||
|
||||
if (_recv_pid <= KERNEL_PID_UNDEF) {
|
||||
puts("Creation of receiver thread failed");
|
||||
int res = netdev_ieee802154_minimal_init();
|
||||
if (res) {
|
||||
puts("Error initializing devices");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -122,7 +104,11 @@ int main(void)
|
||||
puts("Initialization successful - starting the shell now");
|
||||
|
||||
char line_buf[SHELL_DEFAULT_BUFSIZE];
|
||||
#if AT86RF2XX_RANDOM_NUMBER_GENERATOR
|
||||
shell_run(shell_commands, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
#else
|
||||
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Freie Universität Berlin
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "at86rf2xx.h"
|
||||
#include "od.h"
|
||||
#include "net/ieee802154.h"
|
||||
#include "net/netdev.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define MAX_LINE (80)
|
||||
|
||||
static uint8_t buffer[AT86RF2XX_MAX_PKT_LENGTH];
|
||||
|
||||
void recv(netdev_t *dev)
|
||||
{
|
||||
uint8_t src[IEEE802154_LONG_ADDRESS_LEN], dst[IEEE802154_LONG_ADDRESS_LEN];
|
||||
size_t mhr_len, data_len, src_len, dst_len;
|
||||
netdev_ieee802154_rx_info_t rx_info;
|
||||
le_uint16_t src_pan, dst_pan;
|
||||
|
||||
putchar('\n');
|
||||
data_len = dev->driver->recv(dev, buffer, sizeof(buffer), &rx_info);
|
||||
mhr_len = ieee802154_get_frame_hdr_len(buffer);
|
||||
if (mhr_len == 0) {
|
||||
puts("Unexpected MHR for incoming packet");
|
||||
return;
|
||||
}
|
||||
dst_len = ieee802154_get_dst(buffer, dst, &dst_pan);
|
||||
src_len = ieee802154_get_src(buffer, src, &src_pan);
|
||||
switch (buffer[0] & IEEE802154_FCF_TYPE_MASK) {
|
||||
case IEEE802154_FCF_TYPE_BEACON:
|
||||
puts("BEACON");
|
||||
break;
|
||||
case IEEE802154_FCF_TYPE_DATA:
|
||||
puts("DATA");
|
||||
break;
|
||||
case IEEE802154_FCF_TYPE_ACK:
|
||||
puts("ACK");
|
||||
break;
|
||||
case IEEE802154_FCF_TYPE_MACCMD:
|
||||
puts("MACCMD");
|
||||
break;
|
||||
default:
|
||||
puts("UNKNOWN");
|
||||
break;
|
||||
}
|
||||
printf("Dest. PAN: 0x%04x, Dest. addr.: ",
|
||||
byteorder_ltohs(dst_pan));
|
||||
print_addr(dst, dst_len);
|
||||
printf("\nSrc. PAN: 0x%04x, Src. addr.: ",
|
||||
byteorder_ltohs(src_pan));
|
||||
print_addr(src, src_len);
|
||||
printf("\nSecurity: ");
|
||||
if (buffer[0] & IEEE802154_FCF_SECURITY_EN) {
|
||||
printf("1, ");
|
||||
}
|
||||
else {
|
||||
printf("0, ");
|
||||
}
|
||||
printf("Frame pend.: ");
|
||||
if (buffer[0] & IEEE802154_FCF_FRAME_PEND) {
|
||||
printf("1, ");
|
||||
}
|
||||
else {
|
||||
printf("0, ");
|
||||
}
|
||||
printf("ACK req.: ");
|
||||
if (buffer[0] & IEEE802154_FCF_ACK_REQ) {
|
||||
printf("1, ");
|
||||
}
|
||||
else {
|
||||
printf("0, ");
|
||||
}
|
||||
printf("PAN comp.: ");
|
||||
if (buffer[0] & IEEE802154_FCF_PAN_COMP) {
|
||||
puts("1");
|
||||
}
|
||||
else {
|
||||
puts("0");
|
||||
}
|
||||
printf("Version: ");
|
||||
printf("%u, ", (unsigned)((buffer[1] & IEEE802154_FCF_VERS_MASK) >> 4));
|
||||
printf("Seq.: %u\n", (unsigned)ieee802154_get_seq(buffer));
|
||||
od_hex_dump(buffer + mhr_len, data_len - mhr_len, 0);
|
||||
printf("txt: ");
|
||||
for (size_t i = mhr_len; i < data_len; i++) {
|
||||
if ((buffer[i] > 0x1F) && (buffer[i] < 0x80)) {
|
||||
putchar((char)buffer[i]);
|
||||
}
|
||||
else {
|
||||
putchar('?');
|
||||
}
|
||||
if (((((i - mhr_len) + 1) % (MAX_LINE - sizeof("txt: "))) == 1) &&
|
||||
(i - mhr_len) != 0) {
|
||||
printf("\n ");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
printf("RSSI: %i, LQI: %u\n\n", rx_info.rssi, rx_info.lqi);
|
||||
}
|
||||
|
||||
/** @} */
|
13
tests/driver_cc2420/Makefile
Normal file
13
tests/driver_cc2420/Makefile
Normal file
@ -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
|
11
tests/driver_cc2420/Makefile.ci
Normal file
11
tests/driver_cc2420/Makefile.ci
Normal file
@ -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 \
|
||||
#
|
19
tests/driver_cc2420/README.md
Normal file
19
tests/driver_cc2420/README.md
Normal file
@ -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.
|
36
tests/driver_cc2420/init_dev.h
Normal file
36
tests/driver_cc2420/init_dev.h
Normal file
@ -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 <leandro.lanzieri@haw-hamburg.de>
|
||||
*/
|
||||
#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 */
|
||||
/** @} */
|
69
tests/driver_cc2420/main.c
Normal file
69
tests/driver_cc2420/main.c
Normal file
@ -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 <leandro.lanzieri@haw-hamburg.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#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;
|
||||
}
|
15
tests/driver_cc2538_rf/Makefile
Normal file
15
tests/driver_cc2538_rf/Makefile
Normal file
@ -0,0 +1,15 @@
|
||||
INCLUDES += -I$(APPDIR)
|
||||
BOARD ?= remote-revb
|
||||
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += test_utils_netdev_ieee802154_minimal
|
||||
|
||||
# select the driver to test
|
||||
USEMODULE += cc2538_rf
|
||||
|
||||
FEATURES_REQUIRED += cpu_cc2538
|
||||
|
||||
CFLAGS += -DEVENT_THREAD_STACKSIZE_DEFAULT=1024
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
6
tests/driver_cc2538_rf/README.md
Normal file
6
tests/driver_cc2538_rf/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
# About
|
||||
This is a manual test application for the CC2538_RF radio driver.
|
||||
|
||||
# Usage
|
||||
For testing the radio driver you can use the ifconfig and txtsnd shell commands
|
||||
that are included in this application.
|
33
tests/driver_cc2538_rf/init_dev.h
Normal file
33
tests/driver_cc2538_rf/init_dev.h
Normal file
@ -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 CC2538_RF IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*/
|
||||
#ifndef INIT_DEV_H
|
||||
#define INIT_DEV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CC2538_RF_NUM 1
|
||||
#define NETDEV_IEEE802154_MINIMAL_NUMOF CC2538_RF_NUM
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* INIT_DEV_H */
|
||||
/** @} */
|
72
tests/driver_cc2538_rf/main.c
Normal file
72
tests/driver_cc2538_rf/main.c
Normal file
@ -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 CC2538_RF IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "cc2538_rf.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 cc2538_rf;
|
||||
|
||||
int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) {
|
||||
netdev_t *netdev = &cc2538_rf.dev.netdev;
|
||||
|
||||
puts("Initializing CC2538_RF device");
|
||||
|
||||
netdev_register(netdev, NETDEV_CC2538, 0);
|
||||
netdev_ieee802154_submac_init(&cc2538_rf);
|
||||
|
||||
/* setup and initialize the specific driver */
|
||||
cc2538_rf_hal_setup(&cc2538_rf.submac.dev);
|
||||
cc2538_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 CC2538_RF 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;
|
||||
}
|
@ -1,15 +1,13 @@
|
||||
INCLUDES += -I$(APPDIR)
|
||||
BOARD ?= pba-d-01-kw2x
|
||||
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += auto_init_gnrc_netif
|
||||
USEMODULE += gnrc
|
||||
USEMODULE += fmt
|
||||
USEMODULE += shell
|
||||
USEMODULE += shell_commands
|
||||
USEMODULE += ps
|
||||
USEMODULE += test_utils_netdev_ieee802154_minimal
|
||||
|
||||
DRIVER ?= kw2xrf
|
||||
# the radio driver to test
|
||||
USEMODULE += kw2xrf
|
||||
|
||||
# finally include the actual chosen driver
|
||||
USEMODULE += $(DRIVER)
|
||||
CFLAGS += -DEVENT_THREAD_STACKSIZE_DEFAULT=1024
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -1,24 +1,11 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
bluepill-stm32f030c8 \
|
||||
i-nucleo-lrwan1 \
|
||||
nucleo-f031k6 \
|
||||
nucleo-f042k6 \
|
||||
nucleo-f334r8 \
|
||||
atmega328p \
|
||||
nucleo-l011k4 \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
samd10-xmini \
|
||||
slstk3400a \
|
||||
stk3200 \
|
||||
stm32f030f4-demo \
|
||||
stm32f0discovery \
|
||||
stm32l0538-disco \
|
||||
waspmote-pro \
|
||||
#
|
||||
|
@ -1,8 +1,15 @@
|
||||
# About
|
||||
This is a manual test application for testing the KW2XRF device driver. It enables several shell commands, allowing for special test modes of that device. Without deeper knowledge about the hardware, this application might be useless except for compile tests. If you want an example to use this radio, check the [examples](../../examples) folder.
|
||||
This is a manual test application for testing the KW2XRF device driver.
|
||||
It enables several shell commands, allowing for special test modes of that
|
||||
device.
|
||||
Without deeper knowledge about the hardware, this application might be useless
|
||||
except for compile tests.
|
||||
If you want an example to use this radio, check the
|
||||
[examples](../../examples) folder.
|
||||
|
||||
For running this test, you need to connect/configure the following pins of your
|
||||
radio device. If you are running on a phyNODE, this is already the on-board default.
|
||||
radio device. If you are running on a phyNODE, this is already the on-board
|
||||
default.
|
||||
|
||||
- SPI DEV
|
||||
- CS (chip select)
|
||||
|
40
tests/driver_kw2xrf/init_dev.h
Normal file
40
tests/driver_kw2xrf/init_dev.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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 KW2XRF IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*/
|
||||
#ifndef INIT_DEV_H
|
||||
#define INIT_DEV_H
|
||||
|
||||
#include "kernel_defines.h"
|
||||
#include "kw2xrf_params.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define KW2XRF_NUM ARRAY_SIZE(kw2xrf_params)
|
||||
#define NETDEV_IEEE802154_MINIMAL_NUMOF KW2XRF_NUM
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* INIT_DEV_H */
|
||||
/** @} */
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* Copyright (C) 2014 PHYTEC Messtechnik GmbH
|
||||
*
|
||||
* 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
|
||||
* @brief generic kw2xrf pin config
|
||||
*
|
||||
* Copyright (C) 2014 PHYTEC Messtechnik GmbH
|
||||
* @{
|
||||
* @file
|
||||
*
|
||||
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||
* @author Jonas Remmert <j.remmert@phytec.de>
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef KW2XRF_PARAMS_H
|
||||
#define KW2XRF_PARAMS_H
|
||||
|
||||
/**
|
||||
* @brief make sure the SPI port and the needed GPIO pins are defined
|
||||
* @{
|
||||
*/
|
||||
#ifndef KWRF_SPI
|
||||
#error "SPI not defined"
|
||||
#endif
|
||||
#ifndef KWRF_CS
|
||||
#error "Chip select pin not defined"
|
||||
#endif
|
||||
#ifndef KWRF_INT
|
||||
#error "Interrupt pin not defined"
|
||||
#endif
|
||||
#ifndef KWRF_SPI_CLK
|
||||
#define KWRF_SPI_CLK (SPI_CLK_10MHZ)
|
||||
#endif
|
||||
/**@}*/
|
||||
|
||||
/**
|
||||
* @name KW2XRF configuration
|
||||
*/
|
||||
static const kw2xrf_params_t kw2xrf_params[] = {
|
||||
{
|
||||
.spi = KWRF_SPI,
|
||||
.spi_clk = KWRF_SPI_CLK,
|
||||
.cs_pin = KWRF_CS,
|
||||
.int_pin = KWRF_INT,
|
||||
},
|
||||
};
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* KW2XRF_PARAMS_H */
|
||||
/** @} */
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2015 PHYTEC Messtechnik GmbH
|
||||
* 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
|
||||
@ -7,41 +7,43 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @{
|
||||
* @ingroup tests
|
||||
* @file
|
||||
* @brief Test application for KW2x network device driver
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Test application for KW2XRF IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*
|
||||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
||||
* @author Jonas Remmert <j.remmert@phytec.de>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "fmt.h"
|
||||
#include "shell.h"
|
||||
#include "init_dev.h"
|
||||
#include "kw2xrf.h"
|
||||
#include "net/gnrc.h"
|
||||
#include "net/gnrc/netapi.h"
|
||||
#include "net/netopt.h"
|
||||
|
||||
#define KW2XRF_TESTMODE (1)
|
||||
|
||||
#ifdef KW2XRF_TESTMODE
|
||||
#include "kw2xrf_tm.h"
|
||||
#include "kw2xrf_params.h"
|
||||
#include "shell.h"
|
||||
#include "test_utils/netdev_ieee802154_minimal.h"
|
||||
|
||||
static kw2xrf_t kw2xrf[KW2XRF_NUM];
|
||||
|
||||
/* utility functions */
|
||||
static void _set_test_mode(int argc, char **argv, uint8_t mode)
|
||||
{
|
||||
(void) argc;
|
||||
if (fmt_is_number(argv[1])) {
|
||||
kernel_pid_t dev = atoi(argv[1]);
|
||||
|
||||
if (gnrc_netif_get_by_pid(dev)) {
|
||||
gnrc_netapi_set(dev, NETOPT_RF_TESTMODE, 0, (void *)&mode, sizeof(mode));
|
||||
int idx = atoi(argv[1]);
|
||||
if (idx >= (int)KW2XRF_NUM) {
|
||||
puts("invalid interface ID");
|
||||
return;
|
||||
}
|
||||
|
||||
netdev_t *dev = &(kw2xrf[idx].netdev.netdev);
|
||||
dev->driver->set(dev, NETOPT_RF_TESTMODE, &mode, sizeof(mode));
|
||||
return;
|
||||
}
|
||||
printf("usage: %s <if_id>\n", argv[0]);
|
||||
return;
|
||||
@ -113,10 +115,28 @@ static int _tm_ctx_nm1(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) {
|
||||
puts("Initializing KW2XRF devices");
|
||||
|
||||
for (unsigned i = 0; i < KW2XRF_NUM; i++) {
|
||||
printf("%d out of %d\n", i + 1, KW2XRF_NUM);
|
||||
/* setup the specific driver */
|
||||
kw2xrf_setup(&kw2xrf[i], &kw2xrf_params[i], i);
|
||||
|
||||
/* set the application-provided callback */
|
||||
kw2xrf[i].netdev.netdev.event_callback = cb;
|
||||
|
||||
/* initialize the device driver */
|
||||
int res = kw2xrf[i].netdev.netdev.driver->init(&kw2xrf[i].netdev.netdev);
|
||||
if (res != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const shell_command_t shell_commands[] = {
|
||||
#ifdef KW2XRF_TESTMODE
|
||||
{ "idle", "xcvr idle mode", _tm_idle },
|
||||
{ "ctx_prbs9", "continues transmit the prbs9 pattern", _tm_ctx_prbs9 },
|
||||
{ "crx", "continues receive mode, useful for current measuring", _tm_crx },
|
||||
@ -128,14 +148,18 @@ static const shell_command_t shell_commands[] = {
|
||||
{ "ctx_ext", "continues transmit modulated carrier", _tm_ctx_ext },
|
||||
{ "ctx_nm0", "continues transmit modulated carrier", _tm_ctx_nm0 },
|
||||
{ "ctx_nm1", "continues transmit modulated carrier", _tm_ctx_nm1 },
|
||||
#endif
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
int main(void)
|
||||
{
|
||||
puts("Test application for KW2XRF IEEE 802.15.4 device driver");
|
||||
|
||||
puts("KW2XRF device driver test");
|
||||
int res = netdev_ieee802154_minimal_init();
|
||||
if (res) {
|
||||
puts("Error initializing devices");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* start the shell */
|
||||
puts("Initialization successful - starting the shell now");
|
||||
|
@ -1,4 +1,12 @@
|
||||
# the radio driver to test
|
||||
USEMODULE = mrf24j40md
|
||||
INCLUDES += -I$(APPDIR)
|
||||
|
||||
include ../driver_netdev_common/Makefile.netdev.mk
|
||||
include ../Makefile.tests_common
|
||||
|
||||
USEMODULE += test_utils_netdev_ieee802154_minimal
|
||||
|
||||
# select the driver to test
|
||||
USEMODULE += mrf24j40ma
|
||||
|
||||
CFLAGS += -DEVENT_THREAD_STACKSIZE_DEFAULT=1024
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -1,23 +1,11 @@
|
||||
BOARD_INSUFFICIENT_MEMORY := \
|
||||
arduino-duemilanove \
|
||||
arduino-leonardo \
|
||||
arduino-mega2560 \
|
||||
arduino-nano \
|
||||
arduino-uno \
|
||||
atmega328p \
|
||||
atmega328p-xplained-mini \
|
||||
bluepill-stm32f030c8 \
|
||||
i-nucleo-lrwan1 \
|
||||
nucleo-f031k6 \
|
||||
nucleo-f042k6 \
|
||||
atmega328p \
|
||||
nucleo-l011k4 \
|
||||
nucleo-l031k6 \
|
||||
nucleo-l053r8 \
|
||||
samd10-xmini \
|
||||
slstk3400a \
|
||||
stk3200 \
|
||||
stm32f030f4-demo \
|
||||
stm32f0discovery \
|
||||
stm32l0538-disco \
|
||||
waspmote-pro \
|
||||
#
|
||||
|
15
tests/driver_mrf24j40/README.md
Normal file
15
tests/driver_mrf24j40/README.md
Normal file
@ -0,0 +1,15 @@
|
||||
# About
|
||||
This is a manual test application for the MRF24J40 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)
|
||||
- RESET
|
||||
- INT (external interrupt)
|
||||
|
||||
# Usage
|
||||
For testing the radio driver you can use the ifconfig and txtsnd shell commands
|
||||
that are included in this application.
|
36
tests/driver_mrf24j40/init_dev.h
Normal file
36
tests/driver_mrf24j40/init_dev.h
Normal file
@ -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 MRF24J40 IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*/
|
||||
#ifndef INIT_DEV_H
|
||||
#define INIT_DEV_H
|
||||
|
||||
#include "kernel_defines.h"
|
||||
#include "mrf24j40_params.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MRF24J40_NUM ARRAY_SIZE(mrf24j40_params)
|
||||
#define NETDEV_IEEE802154_MINIMAL_NUMOF MRF24J40_NUM
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* INIT_DEV_H */
|
||||
/** @} */
|
@ -1 +0,0 @@
|
||||
../driver_netdev_common/main.c
|
69
tests/driver_mrf24j40/main.c
Normal file
69
tests/driver_mrf24j40/main.c
Normal file
@ -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 MRF24J40 IEEE 802.15.4 device driver
|
||||
*
|
||||
* @author Leandro Lanzieri <leandro.lanzieri@haw-hamburg.de>
|
||||
*
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "init_dev.h"
|
||||
#include "mrf24j40.h"
|
||||
#include "mrf24j40_params.h"
|
||||
#include "shell.h"
|
||||
#include "test_utils/netdev_ieee802154_minimal.h"
|
||||
|
||||
static mrf24j40_t mrf24j40[MRF24J40_NUM];
|
||||
|
||||
int netdev_ieee802154_minimal_init_devs(netdev_event_cb_t cb) {
|
||||
puts("Initializing MRF24J40 devices");
|
||||
|
||||
for (unsigned i = 0; i < MRF24J40_NUM; i++) {
|
||||
printf("%d out of %d\n", i + 1, MRF24J40_NUM);
|
||||
/* setup the specific driver */
|
||||
mrf24j40_setup(&mrf24j40[i], &mrf24j40_params[i], i);
|
||||
|
||||
/* set the application-provided callback */
|
||||
mrf24j40[i].netdev.netdev.event_callback = cb;
|
||||
|
||||
/* initialize the device driver */
|
||||
int res = mrf24j40[i].netdev.netdev.driver->init(&mrf24j40[i].netdev.netdev);
|
||||
if (res != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
puts("Test application for MRF24J40 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;
|
||||
}
|
15
tests/driver_nrf802154/Makefile
Normal file
15
tests/driver_nrf802154/Makefile
Normal file
@ -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
tests/driver_nrf802154/README.md
Normal file
6
tests/driver_nrf802154/README.md
Normal file
@ -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
tests/driver_nrf802154/init_dev.h
Normal file
33
tests/driver_nrf802154/init_dev.h
Normal file
@ -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
tests/driver_nrf802154/main.c
Normal file
72
tests/driver_nrf802154/main.c
Normal file
@ -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,0 +1,6 @@
|
||||
# This must be a different name than 'board' as it is implemented by 'nrf52840dk'
|
||||
MODULE = board_nrf52840_ci_ieee802154
|
||||
|
||||
DIRS += $(RIOTBOARD)/nrf52840dk
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
@ -0,0 +1,7 @@
|
||||
USEMODULE += board_nrf52840_ci_ieee802154
|
||||
|
||||
ifneq (,$(filter netdev_default,$(USEMODULE)))
|
||||
USEMODULE += mrf24j40
|
||||
endif
|
||||
|
||||
include $(RIOTBOARD)/nrf52840dk/Makefile.dep
|
@ -0,0 +1 @@
|
||||
include $(RIOTBOARD)/nrf52840dk/Makefile.features
|
@ -0,0 +1,5 @@
|
||||
# We must duplicate the include done by $(RIOTBASE)/Makefile.include
|
||||
# to also include the main board header
|
||||
INCLUDES += $(addprefix -I,$(wildcard $(RIOTBOARD)/nrf52840dk/include))
|
||||
|
||||
include $(RIOTBOARD)/nrf52840dk/Makefile.include
|
Loading…
Reference in New Issue
Block a user