1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00
RIOT/sys/net/gnrc/netif/init_devs/auto_init_at86rf215.c
Benjamin Valentin d35511bee7 drivers/at86rf215: Add basic driver for the AT86RF215 radio
This adds a driver for the SPI based AT86RF215 transceiver.
The chip supports the IEEE Std 802.15.4-2015 and IEEE Std 802.15.4g-2012 standard.

This driver supports two versions of the chip:
    - AT86RF215:  dual sub-GHz & 2.4 GHz radio & baseband
    - AT86RF215M: sub-GHz radio & baseband only

Both radios support the following PHY modes:
    - MR-FSK
    - MR-OFDM
    - MR-O-QPKS
    - O-QPSK (legacy)

The driver currently only implements support for legacy O-QPSK.

To use both interfaces, add

    GNRC_NETIF_NUMOF := 2

to your Makefile.

The transceiver is able to send frames of up to 2047 bytes according to
IEEE 802.15.4g-2012 when operating in non-legacy mode.

Known issues:

 - [ ] dBm setting values are bogus
 - [ ] Channel spacing for sub-GHz MR-O-QPSK might be wrong
 - [ ] TX/RX stress test will lock up the driver on openmote-b
2020-03-19 14:39:18 +01:00

123 lines
3.2 KiB
C

/*
* Copyright (C) 2019 ML!PA Consulting 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 sys_auto_init_gnrc_netif
* @{
*
* @file
* @brief Auto initialization for at86rf215 network interfaces
*
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
*/
#ifdef MODULE_AT86RF215
#define USED_BANDS (IS_USED(MODULE_AT86RF215_SUBGHZ) + IS_USED(MODULE_AT86RF215_24GHZ))
#include "log.h"
#include "board.h"
#include "net/gnrc/netif/ieee802154.h"
#ifdef MODULE_GNRC_LWMAC
#include "net/gnrc/lwmac/lwmac.h"
#endif
#ifdef MODULE_GNRC_GOMACH
#include "net/gnrc/gomach/gomach.h"
#endif
#include "net/gnrc.h"
#include "at86rf215.h"
#include "at86rf215_params.h"
/* If we don't have enough NETIFs configured, disable the sub-GHz band */
#if (GNRC_NETIF_NUMOF == 1) && IS_USED(MODULE_AT86RF215_SUBGHZ) && IS_USED(MODULE_AT86RF215_24GHZ)
#undef MODULE_AT86RF215_SUBGHZ
#undef USED_BANDS
#define USED_BANDS 1
#endif
/**
* @brief Define stack parameters for the MAC layer thread
* @{
*/
#define AT86RF215_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
#ifndef AT86RF215_MAC_PRIO
#define AT86RF215_MAC_PRIO (GNRC_NETIF_PRIO)
#endif
#ifndef AT86RF215_MAC_PRIO_SUBGHZ
#define AT86RF215_MAC_PRIO_SUBGHZ (AT86RF215_MAC_PRIO)
#endif
#define AT86RF215_NUM ARRAY_SIZE(at86rf215_params)
static at86rf215_t at86rf215_devs[AT86RF215_NUM * USED_BANDS];
static char _at86rf215_stacks[AT86RF215_NUM * USED_BANDS][AT86RF215_MAC_STACKSIZE];
static inline void _setup_netif(void* netdev, void* stack, int prio) {
if (netdev == NULL) {
return;
}
#if defined(MODULE_GNRC_GOMACH)
gnrc_netif_gomach_create(stack,
AT86RF215_MAC_STACKSIZE,
prio, "at86rf215-gomach",
netdev);
#elif defined(MODULE_GNRC_LWMAC)
gnrc_netif_lwmac_create(stack,
AT86RF215_MAC_STACKSIZE,
prio, "at86rf215-lwmac",
netdev);
#else
gnrc_netif_ieee802154_create(stack,
AT86RF215_MAC_STACKSIZE,
prio, "at86rf215",
netdev);
#endif
}
void auto_init_at86rf215(void)
{
unsigned i = 0;
unsigned j = 0;
while (j < AT86RF215_NUM) {
at86rf215_t *dev_09 = NULL;
at86rf215_t *dev_24 = NULL;
void *stack_09 = NULL;
void *stack_24 = NULL;
if (IS_USED(MODULE_AT86RF215_SUBGHZ)) {
dev_09 = &at86rf215_devs[i];
stack_09 = &_at86rf215_stacks[i];
++i;
}
if (IS_USED(MODULE_AT86RF215_24GHZ)) {
dev_24 = &at86rf215_devs[i];
stack_24 = &_at86rf215_stacks[i];
++i;
}
at86rf215_setup(dev_09, dev_24, &at86rf215_params[j++]);
/* setup sub-GHz interface */
_setup_netif(dev_09, stack_09, AT86RF215_MAC_PRIO_SUBGHZ);
/* setup 2.4-GHz interface */
_setup_netif(dev_24, stack_24, AT86RF215_MAC_PRIO);
}
}
#else
typedef int dont_be_pedantic;
#endif /* MODULE_AT86RF215 */
/** @} */