1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/driver_at86rf215: remove gnrc_netif_get_by_type dependency

This commit is contained in:
Jose Alamos 2021-09-30 16:53:23 +02:00
parent 503f5a9ddb
commit e1870dc861
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9
2 changed files with 17 additions and 27 deletions

View File

@ -5,4 +5,6 @@ USEMODULE += at86rf215
USEMODULE += at86rf215_batmon
USEMODULE += at86rf215_timestamp
CFLAGS += -DCONFIG_NETDEV_REGISTER_SIGNAL
include ../driver_netdev_common/Makefile.netdev.mk

View File

@ -32,6 +32,18 @@
#include "od.h"
static char batmon_stack[THREAD_STACKSIZE_MAIN];
static at86rf215_t *dev;
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);
}
}
void *batmon_thread(void *arg)
{
@ -91,19 +103,11 @@ static int cmd_set_trim(int argc, char **argv)
return 1;
}
gnrc_netif_t *netif = gnrc_netif_get_by_type(NETDEV_AT86RF215, 0);
if (netif == NULL) {
if (dev == NULL) {
puts("No at86rf215 radio found");
return 1;
}
netdev_t *netdev = netif->dev;
netdev_ieee802154_t *netdev_ieee802154 = container_of(netdev,
netdev_ieee802154_t,
netdev);
at86rf215_t* dev = container_of(netdev_ieee802154, at86rf215_t, netdev);
printf("setting trim to %u fF\n", 300U * trim);
at86rf215_set_trim(dev, trim);
@ -147,19 +151,11 @@ static int cmd_set_clock_out(int argc, char **argv)
freq = tmp;
}
gnrc_netif_t *netif = gnrc_netif_get_by_type(NETDEV_AT86RF215, 0);
if (netif == NULL) {
if (dev == NULL) {
puts("No at86rf215 radio found");
return 1;
}
netdev_t *netdev = netif->dev;
netdev_ieee802154_t *netdev_ieee802154 = container_of(netdev,
netdev_ieee802154_t,
netdev);
at86rf215_t* dev = container_of(netdev_ieee802154, at86rf215_t, netdev);
printf("Clock output set to %s %s\n", keys[freq], freq ? "MHz" : "");
at86rf215_set_clock_output(dev, AT86RF215_CLKO_4mA, freq);
@ -183,19 +179,11 @@ static int cmd_get_random(int argc, char **argv)
return 1;
}
gnrc_netif_t *netif = gnrc_netif_get_by_type(NETDEV_AT86RF215, 0);
if (netif == NULL) {
if (dev == NULL) {
puts("No at86rf215 radio found");
return 1;
}
netdev_t *netdev = netif->dev;
netdev_ieee802154_t *netdev_ieee802154 = container_of(netdev,
netdev_ieee802154_t,
netdev);
at86rf215_t* dev = container_of(netdev_ieee802154, at86rf215_t, netdev);
at86rf215_get_random(dev, buffer, values);
od_hex_dump(buffer, values, 0);