diff --git a/drivers/at86rf215/at86rf215.c b/drivers/at86rf215/at86rf215.c index df78e98d707e4..97450a17a35a8 100644 --- a/drivers/at86rf215/at86rf215.c +++ b/drivers/at86rf215/at86rf215.c @@ -30,22 +30,24 @@ #define ENABLE_DEBUG (0) #include "debug.h" -static void _setup_interface(at86rf215_t *dev, const at86rf215_params_t *params) +static void _setup_interface(at86rf215_t *dev, const at86rf215_params_t *params, uint8_t index) { netdev_t *netdev = (netdev_t *)dev; netdev->driver = &at86rf215_driver; dev->params = *params; dev->state = AT86RF215_STATE_OFF; + + netdev_register(netdev, NETDEV_AT86RF215, index); } -void at86rf215_setup(at86rf215_t *dev_09, at86rf215_t *dev_24, const at86rf215_params_t *params) +void at86rf215_setup(at86rf215_t *dev_09, at86rf215_t *dev_24, const at86rf215_params_t *params, uint8_t index) { /* configure the sub-GHz interface */ if (dev_09) { dev_09->RF = &RF09_regs; dev_09->BBC = &BBC0_regs; - _setup_interface(dev_09, params); + _setup_interface(dev_09, params, 2 * index); dev_09->sibling = dev_24; } @@ -53,7 +55,7 @@ void at86rf215_setup(at86rf215_t *dev_09, at86rf215_t *dev_24, const at86rf215_p if (dev_24) { dev_24->RF = &RF24_regs; dev_24->BBC = &BBC1_regs; - _setup_interface(dev_24, params); + _setup_interface(dev_24, params, 2 * index + 1); dev_24->sibling = dev_09; } } diff --git a/drivers/include/at86rf215.h b/drivers/include/at86rf215.h index 2171ac1272968..67a31e65b9645 100644 --- a/drivers/include/at86rf215.h +++ b/drivers/include/at86rf215.h @@ -292,8 +292,9 @@ typedef struct at86rf215 { * @param[out] dev_09 sub-GHz device descriptor * @param[out] dev_24 2.4 GHz device descriptor * @param[in] params parameters for device initialization + * @param[in] index Index of the device in the parameter struct */ -void at86rf215_setup(at86rf215_t *dev_09, at86rf215_t *dev_24, const at86rf215_params_t *params); +void at86rf215_setup(at86rf215_t *dev_09, at86rf215_t *dev_24, const at86rf215_params_t *params, uint8_t index); /** * @brief Trigger a hardware reset and configure radio with default values. diff --git a/sys/net/gnrc/netif/init_devs/auto_init_at86rf215.c b/sys/net/gnrc/netif/init_devs/auto_init_at86rf215.c index 4d43ada3a59c7..983af645b5ada 100644 --- a/sys/net/gnrc/netif/init_devs/auto_init_at86rf215.c +++ b/sys/net/gnrc/netif/init_devs/auto_init_at86rf215.c @@ -79,8 +79,7 @@ static inline void _setup_netif(gnrc_netif_t *netif, void* netdev, void* stack, void auto_init_at86rf215(void) { unsigned i = 0; - unsigned j = 0; - while (j < AT86RF215_NUM) { + for (unsigned j = 0; j < AT86RF215_NUM; ++j) { at86rf215_t *dev_09 = NULL; at86rf215_t *dev_24 = NULL; @@ -103,7 +102,7 @@ void auto_init_at86rf215(void) ++i; } - at86rf215_setup(dev_09, dev_24, &at86rf215_params[j++]); + 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);