2016-04-14 13:48:17 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Freie Universität Berlin
|
2016-07-01 15:41:31 +02:00
|
|
|
* 2016 Inria
|
2016-04-14 13:48:17 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2018-06-06 10:32:32 +02:00
|
|
|
* @ingroup sys_auto_init_gnrc_netif
|
2016-04-14 13:48:17 +02:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Auto initialization for CC2420 network devices
|
|
|
|
*
|
|
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
2016-07-01 15:41:31 +02:00
|
|
|
* @author Francisco Acosta <francisco.acosta@inria.fr>
|
2016-04-14 13:48:17 +02:00
|
|
|
*/
|
|
|
|
|
2017-01-18 14:48:23 +01:00
|
|
|
#include "log.h"
|
2016-04-14 13:48:17 +02:00
|
|
|
#include "board.h"
|
2017-11-16 18:06:46 +01:00
|
|
|
#include "net/gnrc/netif/ieee802154.h"
|
2016-04-14 13:48:17 +02:00
|
|
|
#include "net/gnrc.h"
|
2020-11-22 23:50:51 +01:00
|
|
|
#include "include/init_devs.h"
|
2016-04-14 13:48:17 +02:00
|
|
|
|
|
|
|
#include "cc2420.h"
|
|
|
|
#include "cc2420_params.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief MAC layer stack parameters
|
|
|
|
* @{
|
|
|
|
*/
|
2020-11-22 23:50:51 +01:00
|
|
|
#define CC2420_MAC_STACKSIZE (IEEE802154_STACKSIZE_DEFAULT)
|
2016-09-03 02:07:03 +02:00
|
|
|
#ifndef CC2420_MAC_PRIO
|
2017-11-16 18:06:46 +01:00
|
|
|
#define CC2420_MAC_PRIO (GNRC_NETIF_PRIO)
|
2017-07-25 20:28:13 +02:00
|
|
|
#endif
|
2016-04-14 13:48:17 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get the number of configured CC2420 devices
|
|
|
|
*/
|
2019-07-18 15:16:43 +02:00
|
|
|
#define CC2420_NUMOF ARRAY_SIZE(cc2420_params)
|
2016-04-14 13:48:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Allocate memory for dev descriptors, stacks, and 802.15.4 adaption
|
|
|
|
* @{
|
|
|
|
*/
|
2016-07-01 15:41:31 +02:00
|
|
|
static cc2420_t cc2420_devs[CC2420_NUMOF];
|
|
|
|
static char _cc2420_stacks[CC2420_NUMOF][CC2420_MAC_STACKSIZE];
|
2019-12-19 19:23:15 +01:00
|
|
|
static gnrc_netif_t _netif[CC2420_NUMOF];
|
2016-04-14 13:48:17 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
void auto_init_cc2420(void)
|
|
|
|
{
|
|
|
|
for (unsigned i = 0; i < CC2420_NUMOF; i++) {
|
2017-01-18 14:48:23 +01:00
|
|
|
LOG_DEBUG("[auto_init_netif] initializing cc2420 #%u\n", i);
|
2016-04-14 13:48:17 +02:00
|
|
|
|
2020-09-11 16:16:50 +02:00
|
|
|
cc2420_setup(&cc2420_devs[i], &cc2420_params[i], i);
|
2019-12-19 19:23:15 +01:00
|
|
|
gnrc_netif_ieee802154_create(&_netif[i], _cc2420_stacks[i], CC2420_MAC_STACKSIZE,
|
2017-11-16 18:06:46 +01:00
|
|
|
CC2420_MAC_PRIO, "cc2420",
|
|
|
|
(netdev_t *)&cc2420_devs[i]);
|
2016-04-14 13:48:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/** @} */
|