auto_init_at86rf2xx - discovering valid devices

Hello everybody, I have seen in the auto_init_at86rf2xx.c file a loop which tries to find valid devices.

The loop-counter is used for discovering spi-busses and also for the device descriptor ("i" in the code). I think this is not a good idea because what happens if you have only ONE device sitting on the SECOND spi-bus? The device will not be found. I think you need two counters - one for numbering the spi-bus and one for the device descriptor. Do you agree?

// for (unsigned i = 0; i < AT86RF2XX_NUM; i++) {          unsigned i = 1; /* Number of SPI bus */          unsigned k = 0; /* Number device descriptor */          DEBUG("Initializing AT86RF2xx radio at SPI_%i\n", i);          const at86rf2xx_params_t *p = &at86rf2xx_params[k];          int res = at86rf2xx_init(&at86rf2xx_devs[k],                                   p->spi,                                   p->spi_speed,                                   p->cs_pin,                                   p->int_pin,                                   p->sleep_pin,                                   p->reset_pin);

         if (res < 0) {              printf("ERROR");              DEBUG("Error initializing AT86RF2xx radio device!\n");          }          else {              gnrc_nomac_init(_nomac_stacks[k],                              AT86RF2XX_MAC_STACKSIZE, AT86RF2XX_MAC_PRIO,                              "at86rfxx", (gnrc_netdev_t *)&at86rf2xx_devs[k]);          } // }

Regards, Bernhard

Hi Bernhard, I thik the printf is just wrong. It should be

DEBUG(“Initializing AT86RF2xx radio at SPI_%i\n”, p->spi);

The SPI bus itself is stored in the parameter descriptor in at86rf2xx_params.h which is either provided by the board (if it is shipped with the device) or the application (if it is jacked into some pins of the device Arduino-like). But the auto-initialization of network devices needs a bigger overhaul anyways in the near future.

Kind Regards, Martine

Just opened a PR to fix the wrong output: https://github.com/RIOT-OS/RIOT/pull/4951