2016-02-05 12:52:02 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
*
|
|
|
|
* 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-02-05 12:52:02 +01:00
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Auto initialization for ethernet-over-serial module
|
|
|
|
*
|
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
*/
|
|
|
|
|
2017-01-18 14:48:23 +01:00
|
|
|
#include "log.h"
|
|
|
|
#include "debug.h"
|
2016-02-05 12:52:02 +01:00
|
|
|
#include "ethos.h"
|
2021-06-11 10:51:34 +02:00
|
|
|
#include "ethos_params.h"
|
2016-02-05 12:52:02 +01:00
|
|
|
#include "periph/uart.h"
|
2017-11-16 18:06:46 +01:00
|
|
|
#include "net/gnrc/netif/ethernet.h"
|
2016-02-05 12:52:02 +01:00
|
|
|
|
2021-06-11 10:51:34 +02:00
|
|
|
#define ETHOS_NUM ARRAY_SIZE(ethos_params)
|
|
|
|
|
2016-02-05 12:52:02 +01:00
|
|
|
/**
|
2018-07-05 14:09:08 +02:00
|
|
|
* @brief global ethos object, used by stdio_uart
|
2016-02-05 12:52:02 +01:00
|
|
|
*/
|
2021-06-11 10:51:34 +02:00
|
|
|
ethos_t ethos[ETHOS_NUM];
|
2016-02-05 12:52:02 +01:00
|
|
|
|
2021-06-11 10:51:34 +02:00
|
|
|
static gnrc_netif_t _netif[ETHOS_NUM];
|
2019-12-19 19:23:15 +01:00
|
|
|
|
2016-02-05 12:52:02 +01:00
|
|
|
/**
|
|
|
|
* @brief Define stack parameters for the MAC layer thread
|
|
|
|
* @{
|
|
|
|
*/
|
2016-09-03 02:07:03 +02:00
|
|
|
#define ETHOS_MAC_STACKSIZE (THREAD_STACKSIZE_DEFAULT + DEBUG_EXTRA_STACKSIZE)
|
|
|
|
#ifndef ETHOS_MAC_PRIO
|
2017-11-16 18:06:46 +01:00
|
|
|
#define ETHOS_MAC_PRIO (GNRC_NETIF_PRIO)
|
2017-07-25 22:48:00 +02:00
|
|
|
#endif
|
2016-02-05 12:52:02 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Stacks for the MAC layer threads
|
|
|
|
*/
|
2021-06-11 10:51:34 +02:00
|
|
|
static char _netdev_eth_stack[ETHOS_NUM][ETHOS_MAC_STACKSIZE];
|
2016-02-05 12:52:02 +01:00
|
|
|
|
2021-06-11 10:51:34 +02:00
|
|
|
static uint8_t _inbuf[ETHOS_NUM][2048];
|
2016-02-05 12:52:02 +01:00
|
|
|
|
|
|
|
void auto_init_ethos(void)
|
|
|
|
{
|
2021-06-11 10:51:34 +02:00
|
|
|
for (unsigned i = 0; i < ETHOS_NUM; ++i) {
|
|
|
|
LOG_DEBUG("[auto_init_netif] initializing ethos #%u\n", i);
|
2016-02-05 12:52:02 +01:00
|
|
|
|
2021-06-11 10:51:34 +02:00
|
|
|
/* setup netdev device */
|
|
|
|
ethos_setup(ðos[i], ðos_params[i], i, _inbuf[i], sizeof(_inbuf[i]));
|
2016-02-05 12:52:02 +01:00
|
|
|
|
2021-06-11 10:51:34 +02:00
|
|
|
/* initialize netdev<->gnrc adapter state */
|
|
|
|
gnrc_netif_ethernet_create(&_netif[i], _netdev_eth_stack[i], ETHOS_MAC_STACKSIZE,
|
2021-06-22 15:52:45 +02:00
|
|
|
ETHOS_MAC_PRIO, "ethos", ðos[i].netdev);
|
2021-06-11 10:51:34 +02:00
|
|
|
}
|
2016-02-05 12:52:02 +01:00
|
|
|
}
|
|
|
|
/** @} */
|