mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #20728 from LP-HAW/fix-w5500-link-state
drivers/w5500: fix W5500 link up/down events in interrupt mode
This commit is contained in:
commit
c20a9d1276
@ -1,52 +0,0 @@
|
|||||||
# Copyright (C) 2023 Stefan Schmidt
|
|
||||||
#
|
|
||||||
# This file is subject to the terms and conditions of the GNU Lesser
|
|
||||||
# General Public License v2.1. See the file LICENSE in the top level
|
|
||||||
# directory for more details.
|
|
||||||
#
|
|
||||||
|
|
||||||
menuconfig MODULE_W5500
|
|
||||||
bool "W5500 Ethernet Adapter"
|
|
||||||
depends on HAS_PERIPH_GPIO
|
|
||||||
depends on HAS_PERIPH_GPIO_IRQ
|
|
||||||
depends on HAS_PERIPH_SPI
|
|
||||||
depends on TEST_KCONFIG
|
|
||||||
select MODULE_LUID
|
|
||||||
select MODULE_NETDEV_ETH
|
|
||||||
select MODULE_PERIPH_GPIO
|
|
||||||
select MODULE_PERIPH_GPIO_IRQ
|
|
||||||
select MODULE_PERIPH_SPI
|
|
||||||
|
|
||||||
config HAVE_W5500
|
|
||||||
bool
|
|
||||||
select MODULE_W5500 if MODULE_NETDEV_DEFAULT
|
|
||||||
help
|
|
||||||
Indicates that a w5500 ethernet adapter is present.
|
|
||||||
|
|
||||||
if MODULE_W5500
|
|
||||||
|
|
||||||
config W5500_USE_POLLING
|
|
||||||
bool "Use driver in polling mode"
|
|
||||||
default y
|
|
||||||
|
|
||||||
if W5500_USE_POLLING
|
|
||||||
|
|
||||||
config W5500_POLLING_INTERVAL
|
|
||||||
int "Polling interval in ms"
|
|
||||||
default 100
|
|
||||||
|
|
||||||
#endif # W5500_USE_POLLING
|
|
||||||
|
|
||||||
config W5500_MAC_FILTER
|
|
||||||
bool "Enable hardware MAC filter"
|
|
||||||
default n
|
|
||||||
|
|
||||||
config W5500_BROADCAST_FILTER
|
|
||||||
bool "Enable hardware broadcast filter"
|
|
||||||
default n
|
|
||||||
|
|
||||||
config W5500_MULTICAST_FILTER
|
|
||||||
bool "Enable hardware multicast filter"
|
|
||||||
default n
|
|
||||||
|
|
||||||
endif # MODULE_W5500
|
|
@ -104,11 +104,9 @@ static void extint(void *arg)
|
|||||||
w5500_t *dev = (w5500_t *)arg;
|
w5500_t *dev = (w5500_t *)arg;
|
||||||
|
|
||||||
netdev_trigger_event_isr(&dev->netdev);
|
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)
|
void w5500_setup(w5500_t *dev, const w5500_params_t *params, uint8_t index)
|
||||||
{
|
{
|
||||||
@ -181,12 +179,11 @@ static int init(netdev_t *netdev)
|
|||||||
write_register(dev, REG_SIPR2, 0x00);
|
write_register(dev, REG_SIPR2, 0x00);
|
||||||
write_register(dev, REG_SIPR3, 0x00);
|
write_register(dev, REG_SIPR3, 0x00);
|
||||||
|
|
||||||
if (!gpio_is_valid(dev->p.irq)) {
|
|
||||||
dev->timerInstance.callback = extint;
|
dev->timerInstance.callback = extint;
|
||||||
dev->timerInstance.arg = dev;
|
dev->timerInstance.arg = dev;
|
||||||
ztimer_set(ZTIMER_MSEC, &dev->timerInstance, dev->p.polling_interval_ms);
|
ztimer_set(ZTIMER_MSEC, &dev->timerInstance, dev->p.polling_interval_ms);
|
||||||
}
|
|
||||||
else {
|
if (gpio_is_valid(dev->p.irq)) {
|
||||||
/* Configure interrupt pin to trigger on socket 0 events. */
|
/* Configure interrupt pin to trigger on socket 0 events. */
|
||||||
write_register(dev, REG_SIMR, IMR_S0_INT);
|
write_register(dev, REG_SIMR, IMR_S0_INT);
|
||||||
}
|
}
|
||||||
@ -419,10 +416,6 @@ static int get(netdev_t *netdev, netopt_t opt, void *value, size_t max_len)
|
|||||||
res = ETHERNET_ADDR_LEN;
|
res = ETHERNET_ADDR_LEN;
|
||||||
break;
|
break;
|
||||||
case NETOPT_LINK:
|
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_enable_t *)value) = dev->link_up ? NETOPT_ENABLE
|
||||||
: NETOPT_DISABLE;
|
: NETOPT_DISABLE;
|
||||||
res = sizeof(netopt_enable_t);
|
res = sizeof(netopt_enable_t);
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
CONFIG_MODULE_TEST_UTILS_NETDEV_ETH_MINIMAL=y
|
|
||||||
CONFIG_MODULE_W5500=y
|
|
Loading…
Reference in New Issue
Block a user