drivers/at86rf2xx: register driver with netdev

This commit is contained in:
Benjamin Valentin 2020-07-07 20:15:56 +02:00 committed by Benjamin Valentin
parent 7ceb3f0a68
commit 53eedc283b
8 changed files with 12 additions and 8 deletions

View File

@ -37,7 +37,7 @@
#include "debug.h" #include "debug.h"
void at86rf2xx_setup(at86rf2xx_t *dev, const at86rf2xx_params_t *params) void at86rf2xx_setup(at86rf2xx_t *dev, const at86rf2xx_params_t *params, uint8_t index)
{ {
netdev_t *netdev = (netdev_t *)dev; netdev_t *netdev = (netdev_t *)dev;
@ -56,6 +56,8 @@ void at86rf2xx_setup(at86rf2xx_t *dev, const at86rf2xx_params_t *params)
/* initialize device descriptor */ /* initialize device descriptor */
dev->params = *params; dev->params = *params;
#endif #endif
netdev_register(netdev, NETDEV_AT86RF2XX, index);
} }
static void at86rf2xx_disable_clock_output(at86rf2xx_t *dev) static void at86rf2xx_disable_clock_output(at86rf2xx_t *dev)

View File

@ -294,8 +294,10 @@ typedef struct {
* *
* @param[out] dev device descriptor * @param[out] dev device descriptor
* @param[in] params parameters for device initialization * @param[in] params parameters for device initialization
* @param[in] index index of @p params in a global parameter struct array.
* If initialized manually, pass a unique identifier instead.
*/ */
void at86rf2xx_setup(at86rf2xx_t *dev, const at86rf2xx_params_t *params); void at86rf2xx_setup(at86rf2xx_t *dev, const at86rf2xx_params_t *params, uint8_t index);
/** /**
* @brief Trigger a hardware reset and configure radio with default values * @brief Trigger a hardware reset and configure radio with default values

View File

@ -200,7 +200,7 @@ void lwip_bootstrap(void)
} }
#elif defined(MODULE_AT86RF2XX) #elif defined(MODULE_AT86RF2XX)
for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) { for (unsigned i = 0; i < LWIP_NETIF_NUMOF; i++) {
at86rf2xx_setup(&at86rf2xx_devs[i], &at86rf2xx_params[i]); at86rf2xx_setup(&at86rf2xx_devs[i], &at86rf2xx_params[i], i);
if (netif_add(&netif[i], &at86rf2xx_devs[i], lwip_netdev_init, if (netif_add(&netif[i], &at86rf2xx_devs[i], lwip_netdev_init,
tcpip_6lowpan_input) == NULL) { tcpip_6lowpan_input) == NULL) {
DEBUG("Could not add at86rf2xx device\n"); DEBUG("Could not add at86rf2xx device\n");

View File

@ -64,7 +64,7 @@ void openthread_bootstrap(void)
/* setup netdev modules */ /* setup netdev modules */
#ifdef MODULE_AT86RF2XX #ifdef MODULE_AT86RF2XX
at86rf2xx_setup(&at86rf2xx_dev, &at86rf2xx_params[0]); at86rf2xx_setup(&at86rf2xx_dev, &at86rf2xx_params[0], 0);
netdev_t *netdev = (netdev_t *) &at86rf2xx_dev; netdev_t *netdev = (netdev_t *) &at86rf2xx_dev;
#endif #endif
#ifdef MODULE_KW41ZRF #ifdef MODULE_KW41ZRF

View File

@ -71,7 +71,7 @@ int openwsn_bootstrap(void)
#ifdef MODULE_AT86RF2XX #ifdef MODULE_AT86RF2XX
netdev_t *netdev = (netdev_t *)&at86rf2xx_dev.netdev.netdev; netdev_t *netdev = (netdev_t *)&at86rf2xx_dev.netdev.netdev;
at86rf2xx_setup(&at86rf2xx_dev, &at86rf2xx_params[0]); at86rf2xx_setup(&at86rf2xx_dev, &at86rf2xx_params[0], 0);
(void) netdev; (void) netdev;
#endif #endif

View File

@ -51,7 +51,7 @@ void auto_init_at86rf2xx(void)
for (unsigned i = 0; i < AT86RF2XX_NUM; i++) { for (unsigned i = 0; i < AT86RF2XX_NUM; i++) {
LOG_DEBUG("[auto_init_netif] initializing at86rf2xx #%u\n", i); LOG_DEBUG("[auto_init_netif] initializing at86rf2xx #%u\n", i);
at86rf2xx_setup(&at86rf2xx_devs[i], &at86rf2xx_params[i]); at86rf2xx_setup(&at86rf2xx_devs[i], &at86rf2xx_params[i], i);
#if defined(MODULE_GNRC_GOMACH) #if defined(MODULE_GNRC_GOMACH)
gnrc_netif_gomach_create(&_netif[i], _at86rf2xx_stacks[i], gnrc_netif_gomach_create(&_netif[i], _at86rf2xx_stacks[i],
AT86RF2XX_MAC_STACKSIZE, AT86RF2XX_MAC_STACKSIZE,

View File

@ -96,7 +96,7 @@ int main(void)
netdev_t *dev = (netdev_t *)(&devs[i]); netdev_t *dev = (netdev_t *)(&devs[i]);
printf("Initializing AT86RF2xx radio at SPI_%d\n", p->spi); printf("Initializing AT86RF2xx radio at SPI_%d\n", p->spi);
at86rf2xx_setup(&devs[i], p); at86rf2xx_setup(&devs[i], p, i);
dev->event_callback = _event_cb; dev->event_callback = _event_cb;
if (dev->driver->init(dev) < 0) { if (dev->driver->init(dev) < 0) {
continue; continue;

View File

@ -141,7 +141,7 @@ int main(void)
{ {
at86rf2xx_t dev; at86rf2xx_t dev;
bool success = true; bool success = true;
at86rf2xx_setup(&dev, &at86rf2xx_params[0]); at86rf2xx_setup(&dev, &at86rf2xx_params[0], 0);
dev.netdev.netdev.event_callback = _event_cb; dev.netdev.netdev.event_callback = _event_cb;
if (dev.netdev.netdev.driver->init(&dev.netdev.netdev) != 0) { if (dev.netdev.netdev.driver->init(&dev.netdev.netdev) != 0) {
return EXIT_FAILURE; return EXIT_FAILURE;