Merge remote-tracking branch 'origin/ethernet-rp2040-w5500-impl' into integration

This commit is contained in:
J. Nick Koston
2026-03-14 17:09:04 -10:00
3 changed files with 13 additions and 5 deletions
@@ -214,7 +214,9 @@ class EthernetComponent : public Component {
#endif // USE_ESP32
#ifdef USE_RP2040
static constexpr uint32_t LINK_CHECK_INTERVAL = 500; // ms between link/IP polls
Wiznet5500lwIP *eth_{nullptr};
uint32_t last_link_check_{0};
uint8_t clk_pin_;
uint8_t miso_pin_;
uint8_t mosi_pin_;
@@ -81,11 +81,15 @@ void EthernetComponent::setup() {
void EthernetComponent::loop() {
// On RP2040, we need to poll connection state since there are no events.
// linkStatus() reads the W5500 PHY register via SPI — no lwip state involved.
const uint32_t now = App.get_loop_component_start_time();
// Throttle link/IP polling to avoid excessive SPI transactions from linkStatus()
// which reads the W5500 PHY register via SPI on every call.
// connected() reads netif->ip_addr without LwIPLock, but this is a single
// 32-bit aligned read (atomic on ARM) — worst case is a one-iteration-stale
// value, which is benign for polling.
if (this->eth_ != nullptr) {
if (this->eth_ != nullptr && now - this->last_link_check_ >= LINK_CHECK_INTERVAL) {
this->last_link_check_ = now;
bool link_up = this->eth_->linkStatus() == LinkON;
bool has_ip = this->eth_->connected();
@@ -108,9 +112,7 @@ void EthernetComponent::loop() {
}
}
// Call common state machine
const uint32_t now = App.get_loop_component_start_time();
// State machine
switch (this->state_) {
case EthernetComponentState::STOPPED:
if (this->started_) {
+4
View File
@@ -352,9 +352,13 @@
#define USE_SOCKET_IMPL_LWIP_TCP
#define USE_RP2040_BLE
#define USE_SPI
#ifndef USE_ETHERNET
#define USE_ETHERNET
#endif
#ifndef USE_ETHERNET_SPI
#define USE_ETHERNET_SPI
#endif
#endif
#ifdef USE_LIBRETINY
#define USE_CAPTIVE_PORTAL