1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/mcp2515: support no rst_pin

This commit is contained in:
Francisco Molina 2022-04-08 13:56:06 +02:00
parent 0c526f12c6
commit 3084928151

View File

@ -99,7 +99,9 @@ int mcp2515_init(candev_mcp2515_t *dev, void (*irq_handler_cb)(void *))
DEBUG("Error setting interrupt pin!\n"); DEBUG("Error setting interrupt pin!\n");
return -1; return -1;
} }
gpio_init(dev->conf->rst_pin, GPIO_OUT); if (gpio_is_valid(dev->conf->rst_pin)) {
gpio_init(dev->conf->rst_pin, GPIO_OUT);
}
res = mcp2515_spi_init(dev); res = mcp2515_spi_init(dev);
if (res < 0) { if (res < 0) {
@ -118,9 +120,14 @@ int mcp2515_init(candev_mcp2515_t *dev, void (*irq_handler_cb)(void *))
void mcp2515_reset(candev_mcp2515_t *dev) void mcp2515_reset(candev_mcp2515_t *dev)
{ {
gpio_clear(dev->conf->rst_pin); if (gpio_is_valid(dev->conf->rst_pin)) {
xtimer_usleep(RESET_DELAY_US); gpio_clear(dev->conf->rst_pin);
gpio_set(dev->conf->rst_pin); xtimer_usleep(RESET_DELAY_US);
gpio_set(dev->conf->rst_pin);
}
else {
mcp2515_spi_reset(dev);
}
xtimer_usleep(_osc_startup(dev)); xtimer_usleep(_osc_startup(dev));
} }