Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers/w5500: fix W5500 link up/down events in interrupt mode #20728

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions drivers/w5500/Kconfig

This file was deleted.

21 changes: 7 additions & 14 deletions drivers/w5500/w5500.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ static void extint(void *arg)
w5500_t *dev = (w5500_t *)arg;

netdev_trigger_event_isr(&dev->netdev);
if (!gpio_is_valid(dev->p.irq)) {
/* restart timer if we are polling */
ztimer_set(ZTIMER_MSEC, &dev->timerInstance, dev->p.polling_interval_ms);
}

ztimer_set(ZTIMER_MSEC, &dev->timerInstance, dev->p.polling_interval_ms);
}

void w5500_setup(w5500_t *dev, const w5500_params_t *params, uint8_t index)
Expand Down Expand Up @@ -181,12 +179,11 @@ static int init(netdev_t *netdev)
write_register(dev, REG_SIPR2, 0x00);
write_register(dev, REG_SIPR3, 0x00);

if (!gpio_is_valid(dev->p.irq)) {
dev->timerInstance.callback = extint;
dev->timerInstance.arg = dev;
ztimer_set(ZTIMER_MSEC, &dev->timerInstance, dev->p.polling_interval_ms);
}
else {
dev->timerInstance.callback = extint;
dev->timerInstance.arg = dev;
ztimer_set(ZTIMER_MSEC, &dev->timerInstance, dev->p.polling_interval_ms);

if (gpio_is_valid(dev->p.irq)) {
/* Configure interrupt pin to trigger on socket 0 events. */
write_register(dev, REG_SIMR, IMR_S0_INT);
}
Expand Down Expand Up @@ -419,10 +416,6 @@ static int get(netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
res = ETHERNET_ADDR_LEN;
break;
case NETOPT_LINK:
spi_acquire(dev->p.spi, dev->p.cs, SPI_CONF, dev->p.clk);
uint8_t tmp = read_register(dev, REG_PHYCFGR);
spi_release(dev->p.spi);
dev->link_up = ((tmp & PHY_LINK_UP) != 0u);
*((netopt_enable_t *)value) = dev->link_up ? NETOPT_ENABLE
: NETOPT_DISABLE;
res = sizeof(netopt_enable_t);
Expand Down
2 changes: 0 additions & 2 deletions tests/drivers/w5500/app.config.test

This file was deleted.

Loading