2015-05-17 15:21:49 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
2016-05-20 17:13:31 +02:00
|
|
|
* Copyright (C) 2016 PHYTEC Messtechnik GmbH
|
2015-05-17 15:21:49 +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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2015-08-19 12:38:38 +02:00
|
|
|
* @ingroup auto_init_gnrc_netif
|
2015-05-17 15:21:49 +02:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Auto initialization for kw2xrf network interfaces
|
|
|
|
*
|
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
* @author Jonas Remmert <j.remmert@phytec.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef MODULE_KW2XRF
|
|
|
|
|
2017-01-18 14:48:23 +01:00
|
|
|
#include "log.h"
|
2015-05-17 15:21:49 +02:00
|
|
|
#include "board.h"
|
2016-09-03 02:07:03 +02:00
|
|
|
#include "net/gnrc/netdev2.h"
|
2016-05-20 17:13:31 +02:00
|
|
|
#include "net/gnrc/netdev2/ieee802154.h"
|
2015-08-10 02:41:08 +02:00
|
|
|
#include "net/gnrc.h"
|
2015-05-17 15:21:49 +02:00
|
|
|
|
|
|
|
#include "kw2xrf.h"
|
|
|
|
#include "kw2xrf_params.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Define stack parameters for the MAC layer thread
|
|
|
|
* @{
|
|
|
|
*/
|
2015-04-28 20:02:05 +02:00
|
|
|
#define KW2XRF_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT)
|
2016-09-03 02:07:03 +02:00
|
|
|
#ifndef KW2XRF_MAC_PRIO
|
|
|
|
#define KW2XRF_MAC_PRIO (GNRC_NETDEV2_MAC_PRIO)
|
|
|
|
#endif
|
2015-05-17 15:21:49 +02:00
|
|
|
|
|
|
|
#define KW2XRF_NUM (sizeof(kw2xrf_params)/sizeof(kw2xrf_params[0]))
|
|
|
|
|
|
|
|
static kw2xrf_t kw2xrf_devs[KW2XRF_NUM];
|
2016-05-20 17:13:31 +02:00
|
|
|
static gnrc_netdev2_t gnrc_adpt[KW2XRF_NUM];
|
|
|
|
static char _nomac_stacks[KW2XRF_MAC_STACKSIZE][KW2XRF_NUM];
|
2015-05-17 15:21:49 +02:00
|
|
|
|
|
|
|
void auto_init_kw2xrf(void)
|
|
|
|
{
|
2017-01-18 14:48:23 +01:00
|
|
|
for (unsigned i = 0; i < KW2XRF_NUM; i++) {
|
2015-05-17 15:21:49 +02:00
|
|
|
const kw2xrf_params_t *p = &kw2xrf_params[i];
|
|
|
|
|
2017-01-18 14:48:23 +01:00
|
|
|
LOG_DEBUG("[auto_init_netif] initializing kw2xrf #%u\n", i);
|
|
|
|
|
2016-05-20 17:13:31 +02:00
|
|
|
kw2xrf_setup(&kw2xrf_devs[i], (kw2xrf_params_t*) p);
|
|
|
|
int res = gnrc_netdev2_ieee802154_init(&gnrc_adpt[i],
|
|
|
|
(netdev2_ieee802154_t *)&kw2xrf_devs[i]);
|
2015-05-17 15:21:49 +02:00
|
|
|
if (res < 0) {
|
2017-01-18 14:48:23 +01:00
|
|
|
LOG_ERROR("[auto_init_netif] initializing kw2xrf #%u\n", i);
|
2015-05-17 15:21:49 +02:00
|
|
|
}
|
|
|
|
else {
|
2016-05-20 17:13:31 +02:00
|
|
|
gnrc_netdev2_init(_nomac_stacks[i],
|
|
|
|
KW2XRF_MAC_STACKSIZE,
|
|
|
|
KW2XRF_MAC_PRIO,
|
|
|
|
"kw2xrf",
|
|
|
|
&gnrc_adpt[i]);
|
2015-05-17 15:21:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-27 21:52:49 +02:00
|
|
|
#else
|
|
|
|
typedef int dont_be_pedantic;
|
2015-08-17 15:41:29 +02:00
|
|
|
#endif /* MODULE_GNRC_KW2XRF */
|
2015-05-17 15:21:49 +02:00
|
|
|
|
|
|
|
/** @} */
|