mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #16761 from benpicco/pkg/lwip/init_devs
pkg/lwip: add auto-init for DOSE & at86rf215, cc2538_rf
This commit is contained in:
commit
16f7c94875
72
pkg/lwip/init_devs/auto_init_at86rf215.c
Normal file
72
pkg/lwip/init_devs/auto_init_at86rf215.c
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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_lwip_netif
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Auto initialization for at86rf215 network interfaces
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
* @author Erik Ekman <eekman@google.com>
|
||||
*/
|
||||
|
||||
#include "at86rf215.h"
|
||||
#include "at86rf215_params.h"
|
||||
|
||||
#include "lwip_init_devs.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#define USED_BANDS (IS_USED(MODULE_AT86RF215_SUBGHZ) + IS_USED(MODULE_AT86RF215_24GHZ))
|
||||
#define NETIF_AT86RF215_NUMOF ARRAY_SIZE(at86rf215_params)
|
||||
|
||||
static struct netif netif[NETIF_AT86RF215_NUMOF * USED_BANDS];
|
||||
static at86rf215_t at86rf215_devs[NETIF_AT86RF215_NUMOF * USED_BANDS];
|
||||
|
||||
static void auto_init_at86rf215(void)
|
||||
{
|
||||
unsigned i = 0;
|
||||
for (unsigned j = 0; j < NETIF_AT86RF215_NUMOF;j++) {
|
||||
|
||||
at86rf215_t *dev_09 = NULL;
|
||||
at86rf215_t *dev_24 = NULL;
|
||||
struct netif *netif_09 = NULL;
|
||||
struct netif *netif_24 = NULL;
|
||||
|
||||
if (IS_USED(MODULE_AT86RF215_SUBGHZ)) {
|
||||
dev_09 = &at86rf215_devs[i];
|
||||
netif_09 = &netif[i];
|
||||
++i;
|
||||
}
|
||||
|
||||
if (IS_USED(MODULE_AT86RF215_24GHZ)) {
|
||||
dev_24 = &at86rf215_devs[i];
|
||||
netif_24 = &netif[i];
|
||||
++i;
|
||||
}
|
||||
|
||||
at86rf215_setup(dev_09, dev_24, &at86rf215_params[j], j);
|
||||
|
||||
if (dev_09) {
|
||||
if (lwip_add_6lowpan(netif_09, &dev_09->netdev.netdev) == NULL) {
|
||||
DEBUG("Could not add sub-GHz at86rf215 device #%u\n", j);
|
||||
}
|
||||
}
|
||||
if (dev_24) {
|
||||
if (lwip_add_6lowpan(netif_24, &dev_24->netdev.netdev) == NULL) {
|
||||
DEBUG("Could not add 2.4-GHz at86rf215 device #%u\n", j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LWIP_INIT_6LOWPAN_NETIF(auto_init_at86rf215);
|
||||
/** @} */
|
45
pkg/lwip/init_devs/auto_init_cc2538_rf.c
Normal file
45
pkg/lwip/init_devs/auto_init_cc2538_rf.c
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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_lwip_netif
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Auto initialization for cc2538 network interfaces
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
* @author Erik Ekman <eekman@google.com>
|
||||
*/
|
||||
|
||||
#include "cc2538_rf.h"
|
||||
#include "net/netdev/ieee802154_submac.h"
|
||||
|
||||
#include "lwip_init_devs.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
static struct netif netif;
|
||||
static netdev_ieee802154_submac_t cc2538_rf_netdev;
|
||||
|
||||
static void auto_init_cc2538_rf(void)
|
||||
{
|
||||
netdev_register(&cc2538_rf_netdev.dev.netdev, NETDEV_CC2538, 0);
|
||||
netdev_ieee802154_submac_init(&cc2538_rf_netdev);
|
||||
cc2538_rf_hal_setup(&cc2538_rf_netdev.submac.dev);
|
||||
|
||||
cc2538_init();
|
||||
|
||||
if (lwip_add_6lowpan(&netif, &cc2538_rf_netdev.dev.netdev) == NULL) {
|
||||
DEBUG("Could not add CC2538 device\n");
|
||||
}
|
||||
}
|
||||
|
||||
LWIP_INIT_6LOWPAN_NETIF(auto_init_cc2538_rf);
|
||||
/** @} */
|
44
pkg/lwip/init_devs/auto_init_dose.c
Normal file
44
pkg/lwip/init_devs/auto_init_dose.c
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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_lwip_netif
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Auto initialization for DOSE network interfaces
|
||||
*
|
||||
* @author Benjamin Valentin <benjamin.valentin@ml-pa.com>
|
||||
* @author Erik Ekman <eekman@google.com>
|
||||
*/
|
||||
|
||||
#include "dose.h"
|
||||
#include "dose_params.h"
|
||||
|
||||
#include "lwip_init_devs.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
#define NETIF_DOSE_NUMOF ARRAY_SIZE(dose_params)
|
||||
|
||||
static struct netif netif[NETIF_DOSE_NUMOF];
|
||||
static dose_t dose_devs[NETIF_DOSE_NUMOF];
|
||||
|
||||
static void auto_init_dose(void)
|
||||
{
|
||||
for (unsigned i = 0; i < NETIF_DOSE_NUMOF; i++) {
|
||||
dose_setup(&dose_devs[i], &dose_params[i], i);
|
||||
if (lwip_add_ethernet(&netif[i], &dose_devs[i].netdev) == NULL) {
|
||||
DEBUG("Could not add DOSE device #%u\n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LWIP_INIT_ETH_NETIF(auto_init_dose);
|
||||
/** @} */
|
Loading…
Reference in New Issue
Block a user