1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/net/gnrc/netif/init_devs/auto_init_at86rf215.c
Benjamin Valentin eb3daf4c22 drivers/at86rf215: give driver threads different names
Use different names for the sub-GHz and 2.4 GHz driver thread to make
it easier to tell which is which.

```
2020-10-21 19:53:50,608 # 	pid | name                 | state    Q | pri | stack  ( used) ( free) | base addr  | current
2020-10-21 19:53:50,622 # 	  - | isr_stack            | -        - |   - |    512 (  232) (  280) | 0x20000000 | 0x200001c8
2020-10-21 19:53:50,623 # 	  1 | main                 | running  Q |   7 |   1536 (  660) (  876) | 0x200002f8 | 0x2000075c
2020-10-21 19:53:50,639 # 	  2 | pktdump              | bl rx    _ |   6 |   1536 (  236) ( 1300) | 0x200035a8 | 0x20003abc
2020-10-21 19:53:50,653 # 	  3 | 6lo                  | bl rx    _ |   3 |   1024 (  332) (  692) | 0x2000420c | 0x2000450c
2020-10-21 19:53:50,655 # 	  4 | ipv6                 | bl rx    _ |   4 |   1024 (  376) (  648) | 0x200009d4 | 0x20000cd4
2020-10-21 19:53:50,670 # 	  5 | udp                  | bl rx    _ |   5 |   1024 (  252) (  772) | 0x200049f0 | 0x20004cf4
2020-10-21 19:53:50,672 # 	  6 | at86rf215 [sub GHz]  | bl rx    _ |   2 |   1024 (  536) (  488) | 0x20001200 | 0x200014c4
2020-10-21 19:53:50,687 # 	  7 | at86rf215 [2.4 GHz]  | bl rx    _ |   2 |   1024 (  536) (  488) | 0x20001600 | 0x200018c4
2020-10-21 19:53:50,689 # 	    | SUM                  |            |     |   8704 ( 3160) ( 5544)
```
2020-10-21 19:59:42 +02:00

112 lines
3.1 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>
*/
#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"
/**
* @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 gnrc_netif_t _netif[AT86RF215_NUM * USED_BANDS];
static char _at86rf215_stacks[AT86RF215_NUM * USED_BANDS][AT86RF215_MAC_STACKSIZE];
static inline void _setup_netif(gnrc_netif_t *netif, void* netdev, void* stack,
int prio, const char *name)
{
if (netif == NULL || netdev == NULL) {
return;
}
#if defined(MODULE_GNRC_GOMACH)
gnrc_netif_gomach_create(netif, stack,
AT86RF215_MAC_STACKSIZE,
prio, name, netdev);
#elif defined(MODULE_GNRC_LWMAC)
gnrc_netif_lwmac_create(netif, stack,
AT86RF215_MAC_STACKSIZE,
prio, name, netdev);
#else
gnrc_netif_ieee802154_create(netif, stack,
AT86RF215_MAC_STACKSIZE,
prio, name, netdev);
#endif
}
void auto_init_at86rf215(void)
{
unsigned i = 0;
for (unsigned j = 0; j < AT86RF215_NUM; ++j) {
at86rf215_t *dev_09 = NULL;
at86rf215_t *dev_24 = NULL;
void *stack_09 = NULL;
void *stack_24 = NULL;
gnrc_netif_t *netif_09 = NULL;
gnrc_netif_t *netif_24 = NULL;
if (IS_USED(MODULE_AT86RF215_SUBGHZ)) {
dev_09 = &at86rf215_devs[i];
stack_09 = &_at86rf215_stacks[i];
netif_09 = &_netif[i];
++i;
}
if (IS_USED(MODULE_AT86RF215_24GHZ)) {
dev_24 = &at86rf215_devs[i];
stack_24 = &_at86rf215_stacks[i];
netif_24 = &_netif[i];
++i;
}
at86rf215_setup(dev_09, dev_24, &at86rf215_params[j], j);
/* setup sub-GHz interface */
_setup_netif(netif_09, dev_09, stack_09, AT86RF215_MAC_PRIO_SUBGHZ, "at86rf215 [sub GHz]");
/* setup 2.4-GHz interface */
_setup_netif(netif_24, dev_24, stack_24, AT86RF215_MAC_PRIO, "at86rf215 [2.4 GHz]");
}
}
/** @} */