[riot-notifications] [RIOT] drivers: add driver for encx24j600 ethernet chips (#2800)

Hauke Petersen notifications at github.com
Tue Jun 16 03:05:38 CEST 2015


> +    /* setup IO */
> +    gpio_init_out(dev->cs, GPIO_PULLUP);
> +    gpio_set(dev->cs);
> +    gpio_init_int(dev->int_pin, GPIO_PULLUP, GPIO_FALLING, encx24j600_isr, (void*)dev);
> +
> +    spi_init_master(dev->spi, SPI_CONF_FIRST_RISING, ENCX24J600_SPI_SPEED);
> +
> +    lock(dev);
> +
> +    /* initialization procedure as described in data sheet (39935c.pdf) */
> +    do {
> +        do {
> +            vtimer_usleep(ENCX24J600_INIT_DELAY);
> +            reg_set(dev, EUDAST, 0x1234);
> +            vtimer_usleep(ENCX24J600_INIT_DELAY);
> +        } while (reg_get(dev, EUDAST) != 0x1234);

this seems dangerous to me in the current state. It would be safer if you test the SPI connection once before you go into the `do` loops - isn't there a device ID or similar fixed value register you can read out after SPI initialization to verify the connection and return an error code if the device does not respond? This is how we handle it in most other (newer) drivers...

---
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/2800/files#r32483309
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20150615/32d4bbd0/attachment.html>


More information about the notifications mailing list