Skip to content

Commit

Permalink
drivers/at86rf215: register driver with netdev
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Jul 7, 2020
1 parent ea912e9 commit 8b37d6f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions drivers/at86rf215/at86rf215.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,32 @@
#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;
}

/* configure the 2.4 GHz interface */
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;
}
}
Expand Down
3 changes: 2 additions & 1 deletion drivers/include/at86rf215.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions sys/net/gnrc/netif/init_devs/auto_init_at86rf215.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 8b37d6f

Please sign in to comment.