-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
network: make auto_init_ng_netif less board-dependant #2901
Changes from all commits
e655137
3c00ff0
a89b382
8e1370b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2015 Kaspar Schleiser <[email protected]> | ||
* | ||
* 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 board_iot-lab_M3 | ||
* @{ | ||
* | ||
* @file | ||
* @brief at86rf231 board specific configuration | ||
* | ||
* @author Kaspar Schleiser <[email protected]> | ||
*/ | ||
|
||
#ifndef NG_AT86RF2XX_PARAMS_H | ||
#define NG_AT86RF2XX_PARAMS_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @name AT86RF231 configuration | ||
*/ | ||
static const at86rf2xx_params_t at86rf2xx_params[] = | ||
{ | ||
{ | ||
.spi = AT86RF231_SPI, | ||
.spi_speed = AT86RF231_SPI_CLK, | ||
.cs_pin = AT86RF231_CS, | ||
.int_pin = AT86RF231_INT, | ||
.sleep_pin = AT86RF231_SLEEP, | ||
.reset_pin = AT86RF231_RESET, | ||
}, | ||
}; | ||
/** @} */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* NG_AT86RF2XX_PARAMS_H */ | ||
/** @} */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (C) 2015 Kaspar Schleiser <[email protected]> | ||
* | ||
* 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 board_samr21-xpro | ||
* @{ | ||
* | ||
* @file | ||
* @brief at86rf233 board specific configuration | ||
* | ||
* @author Kaspar Schleiser <[email protected]> | ||
*/ | ||
|
||
#ifndef NG_AT86RF2XX_PARAMS_H | ||
#define NG_AT86RF2XX_PARAMS_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @name AT86RF231 configuration | ||
*/ | ||
static const at86rf2xx_params_t at86rf2xx_params[] = | ||
{ | ||
{ | ||
.spi = NG_AT86RF233_SPI, | ||
.spi_speed = NG_AT86RF233_SPI_CLK, | ||
.cs_pin = NG_AT86RF233_CS, | ||
.int_pin = NG_AT86RF233_INT, | ||
.sleep_pin = NG_AT86RF233_SLEEP, | ||
.reset_pin = NG_AT86RF233_RESET, | ||
}, | ||
}; | ||
/** @} */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif /* NG_AT86RF2XX_PARAMS_H */ | ||
/** @} */ |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
MODULE = auto_init_ng_netif | ||
|
||
include $(RIOTBASE)/Makefile.base |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (C) 2015 Kaspar Schleiser <[email protected]> | ||
* | ||
* 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 auto_init_ng_netif | ||
* @{ | ||
* | ||
* @file | ||
* @brief Auto initialization for nx_at86rf2xx network interfaces | ||
* | ||
* @author Kaspar Schleiser <[email protected]> | ||
*/ | ||
|
||
#ifdef MODULE_NG_AT86RF2XX | ||
|
||
#include "board.h" | ||
#include "net/ng_nomac.h" | ||
#include "net/ng_netbase.h" | ||
|
||
#include "ng_at86rf2xx.h" | ||
#include "ng_at86rf2xx_params.h" | ||
|
||
#define ENABLE_DEBUG (0) | ||
#include "debug.h" | ||
|
||
/** | ||
* @brief Define stack parameters for the MAC layer thread | ||
* @{ | ||
*/ | ||
#define AT86RF2XX_MAC_STACKSIZE (KERNEL_CONF_STACKSIZE_DEFAULT) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think this should go into the MAC implementation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the MAC implementation calls a driver's functions for e.g., send, receive, etc. So this is low-level driver dependent and will be different for different devices. That's why it is defined here. If defined by nomac, it would have to be a size that fits all drivers, making possible optimization impossible. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, agreed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, the ideal solution would be to compute this number by something like BASE_STACK + DRIVERS_STACK_NEEDS + MAC_LAYER_STACK_NEEDS, where the driver part is defined by the driver and the MAC part is defined by... you get the picture. The question is just if it is possible to define these numbers in a sensible way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm... One day we need to find a procedure for finding stack sizes for all the little helper threads... |
||
#define AT86RF2XX_MAC_PRIO (PRIORITY_MAIN - 3) | ||
|
||
#define AT86RF2XX_NUM (sizeof(at86rf2xx_params)/sizeof(at86rf2xx_params[0])) | ||
|
||
static ng_at86rf2xx_t ng_at86rf2xx_devs[AT86RF2XX_NUM]; | ||
static char _nomac_stacks[AT86RF2XX_MAC_STACKSIZE][AT86RF2XX_NUM]; | ||
|
||
void auto_init_ng_at86rf2xx(void) | ||
{ | ||
for (int i = 0; i < AT86RF2XX_NUM; i++) { | ||
DEBUG("Initializing AT86RF2xx radio at SPI_%i\n", i); | ||
const at86rf2xx_params_t *p = &at86rf2xx_params[i]; | ||
int res = ng_at86rf2xx_init(&ng_at86rf2xx_devs[i], | ||
p->spi, | ||
p->spi_speed, | ||
p->cs_pin, | ||
p->int_pin, | ||
p->sleep_pin, | ||
p->reset_pin); | ||
|
||
if (res < 0) { | ||
DEBUG("Error initializing AT86RF2xx radio device!"); | ||
} | ||
else { | ||
ng_nomac_init(_nomac_stacks[i], | ||
AT86RF2XX_MAC_STACKSIZE, AT86RF2XX_MAC_PRIO, | ||
"at86rfxx", (ng_netdev_t *)&ng_at86rf2xx_devs[i]); | ||
} | ||
} | ||
} | ||
#endif /* MODULE_NG_AT86RF2XX */ | ||
|
||
/** @} */ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (C) 2015 Kaspar Schleiser <[email protected]> | ||
* | ||
* 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 auto_init_ng_netif | ||
* @{ | ||
* | ||
* @file | ||
* @brief Auto initialization for XBee network interfaces | ||
* | ||
* @author Kaspar Schleiser <[email protected]> | ||
*/ | ||
|
||
#ifdef MODULE_XBEE | ||
|
||
#include "board.h" | ||
#include "net/ng_nomac.h" | ||
#include "net/ng_netbase.h" | ||
|
||
#include "xbee.h" | ||
#include "xbee_params.h" | ||
|
||
#define ENABLE_DEBUG (0) | ||
#include "debug.h" | ||
|
||
#define XBEE_NUM (sizeof(xbee_params)/sizeof(xbee_params_t)) | ||
|
||
static xbee_t xbee_devs[XBEE_NUM]; | ||
|
||
/** | ||
* @brief Define stack parameters for the MAC layer thread | ||
* @{ | ||
*/ | ||
#define XBEE_MAC_STACKSIZE (KERNEL_CONF_STACKSIZE_DEFAULT) | ||
#define XBEE_MAC_PRIO (PRIORITY_MAIN - 3) | ||
|
||
/** | ||
* @brief Stacks for the MAC layer threads | ||
*/ | ||
static char _nomac_stacks[XBEE_MAC_STACKSIZE][XBEE_NUM]; | ||
|
||
void auto_init_xbee(void) | ||
{ | ||
for (int i = 0; i < XBEE_NUM; i++) { | ||
DEBUG("Initializing XBee radio at UART_%i\n", i); | ||
const xbee_params_t *p = &xbee_params[i]; | ||
int res = xbee_init(&xbee_devs[i], | ||
p->uart, | ||
p->baudrate, | ||
p->sleep_pin, | ||
p->status_pin); | ||
|
||
if (res < 0) { | ||
DEBUG("Error initializing XBee radio device!"); | ||
} | ||
else { | ||
ng_nomac_init(_nomac_stacks[i], | ||
XBEE_MAC_STACKSIZE, XBEE_MAC_PRIO, "xbee", | ||
(ng_netdev_t *)&xbee_devs[i]); | ||
} | ||
} | ||
} | ||
|
||
#endif /* MODULE_XBEE */ | ||
/** @} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This get's optimized out.