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

Merge pull request #17979 from maribu/drivers/netdev_ieee802154

drivers/netdev_ieee802154: drop duplicate struct member
This commit is contained in:
benpicco 2022-06-02 00:47:56 +02:00 committed by GitHub
commit cb5e19beb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 80 additions and 14 deletions

View File

@ -6,9 +6,7 @@
menu "Drivers"
config MODULE_NETDEV_DEFAULT
bool "Enable default network devices on the platform"
rsource "netdev/Kconfig"
rsource "saul/Kconfig"
menu "Actuator Device Drivers"

View File

@ -244,3 +244,9 @@ ifneq (,$(filter-out netdev_default, $(filter netdev_%,$(USEMODULE))))
USEMODULE += netdev_register
endif
endif
ifneq (,$(filter gnrc_netif_timestamp,$(USEMODULE)))
ifneq (,$(filter netdev_ieee802154,$(USEMODULE)))
USEMODULE += netdev_ieee802154_rx_timestamp
endif
endif

View File

@ -33,7 +33,3 @@ endif
USEMODULE += xtimer
USEMODULE += ieee802154
USEMODULE += netdev_ieee802154
ifneq (,$(filter gnrc_netif_timestamp,$(USEMODULE)))
USEMODULE += at86rf215_timestamp
endif

View File

@ -1,5 +1,4 @@
PSEUDOMODULES += at86rf215_batmon
PSEUDOMODULES += at86rf215_timestamp
PSEUDOMODULES += at86rf215_subghz
PSEUDOMODULES += at86rf215_24ghz
PSEUDOMODULES += at86rf215_blocking_send

View File

@ -22,6 +22,7 @@
#include <assert.h>
#include <errno.h>
#include "byteorder.h"
#include "iolist.h"
#include "net/eui64.h"
@ -204,14 +205,14 @@ static int _recv(netdev_t *netdev, void *buf, size_t len, void *info)
netdev_ieee802154_rx_info_t *radio_info = info;
radio_info->rssi = (int8_t) at86rf215_reg_read(dev, dev->RF->RG_EDV);
if (IS_USED(MODULE_AT86RF215_TIMESTAMP)) {
if (IS_USED(MODULE_NETDEV_IEEE802154_RX_TIMESTAMP)) {
uint32_t rx_timestamp;
at86rf215_reg_read_bytes(dev, dev->BBC->RG_CNT0, &rx_timestamp,
sizeof(rx_timestamp));
/* convert counter value to ns */
radio_info->timestamp = rx_timestamp * 1000ULL / 32;
radio_info->flags |= NETDEV_RX_IEEE802154_INFO_FLAG_TIMESTAMP;
uint64_t res = rx_timestamp * 1000ULL / 32;
netdev_ieee802154_rx_info_set_timestamp(radio_info, res);
}
}

View File

@ -136,15 +136,60 @@ typedef struct {
* @brief Received packet status information for IEEE 802.15.4 radios
*/
typedef struct netdev_ieee802154_rx_info {
uint64_t timestamp; /**< Timestamp value of a received frame in ns */
int16_t rssi; /**< RSSI of a received frame in dBm */
uint8_t lqi; /**< LQI of a received frame */
uint8_t flags; /**< Flags e.g. used to mark other fields as valid */
#if IS_USED(MODULE_SOCK_AUX_TIMESTAP)
#if IS_USED(MODULE_NETDEV_IEEE802154_RX_TIMESTAMP)
uint64_t timestamp; /**< Timestamp value of a received frame in ns */
#endif
} netdev_ieee802154_rx_info_t;
/**
* @brief Write the given timestamp to the given RX info struct.
*
* @details This function is safe to call even when module
* `netdev_ieee802154_rx_timestamp` is not used. It will become a
* no-op then.
*/
static inline void netdev_ieee802154_rx_info_set_timestamp(
netdev_ieee802154_rx_info_t *dest,
uint64_t timestamp)
{
(void)dest;
(void)timestamp;
#if IS_USED(MODULE_NETDEV_IEEE802154_RX_TIMESTAMP)
dest->timestamp = timestamp;
dest->flags |= NETDEV_RX_IEEE802154_INFO_FLAG_TIMESTAMP;
#endif
}
/**
* @brief Get the timestamp to from the RX info.
*
* @details This function is safe to call even when module
* `netdev_ieee802154_rx_timestamp` is not used. It will become a
* no-op then.
*
* @retval 0 Success
* @retval -1 No timestamp present or module `netdev_ieee802154_rx_timestamp`
* not used
*/
static inline int netdev_ieee802154_rx_info_get_timestamp(
const netdev_ieee802154_rx_info_t *info,
uint64_t *dest)
{
(void)info;
(void)dest;
#if IS_USED(MODULE_NETDEV_IEEE802154_RX_TIMESTAMP)
if (info->flags & NETDEV_RX_IEEE802154_INFO_FLAG_TIMESTAMP) {
*dest = info->timestamp;
return 0;
}
#endif
return -1;
}
/**
* @brief Reset function for ieee802154 common fields
*

20
drivers/netdev/Kconfig Normal file
View File

@ -0,0 +1,20 @@
# Copyright (c) 2022 Otto-von-Guericke-Universität Magdeburg
#
# 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.
menu "Network Device Drivers"
config MODULE_NETDEV_DEFAULT
bool "Enable default network devices on the platform"
menu "IEEE 802.15.4 Device Drivers"
visible if MODULE_NETDEV_IEEE802154
config MODULE_NETDEV_IEEE802154_RX_TIMESTAMP
bool "Timestamp received frames"
endmenu # IEEE 802.15.4 Device Drivers
endmenu # Network Device Drivers

View File

@ -145,6 +145,7 @@ PSEUDOMODULES += mtd_write_page
PSEUDOMODULES += nanocoap_%
PSEUDOMODULES += netdev_default
PSEUDOMODULES += netdev_ieee802154_%
PSEUDOMODULES += netdev_ieee802154_rx_timestamp
PSEUDOMODULES += netdev_ieee802154
PSEUDOMODULES += netdev_eth
PSEUDOMODULES += netdev_layer

View File

@ -3,7 +3,7 @@ BOARD ?= openmote-b
# the radio driver to test
USEMODULE += at86rf215
USEMODULE += at86rf215_batmon
USEMODULE += at86rf215_timestamp
USEMODULE += netdev_ieee802154_rx_timestamp
CFLAGS += -DCONFIG_NETDEV_REGISTER_SIGNAL