Re: [riot-devel] auto_init_at86rf2xx - discovering valid devices

2016-03-03 Thread Martine Lenders
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


2016-03-03 12:33 GMT+01:00 Bernhard Nägele :

> 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 = _params[k];
> int res = at86rf2xx_init(_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
> *)_devs[k]);
> }
> //}
>
> Regards,
> Bernhard
> ___
> devel mailing list
> devel@riot-os.org
> https://lists.riot-os.org/mailman/listinfo/devel
>
___
devel mailing list
devel@riot-os.org
https://lists.riot-os.org/mailman/listinfo/devel


[riot-devel] auto_init_at86rf2xx - discovering valid devices

2016-03-03 Thread Bernhard Nägele

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 = _params[k];
int res = at86rf2xx_init(_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 
*)_devs[k]);

}
//}

Regards,
Bernhard
___
devel mailing list
devel@riot-os.org
https://lists.riot-os.org/mailman/listinfo/devel