mirror of
https://github.com/esphome/esphome.git
synced 2026-09-20 03:28:41 +00:00
[ethernet] Document lock-free polling rationale in RP2040 loop
Explain why linkStatus() and connected() are called without LwIPLock — linkStatus() only reads the W5500 PHY via SPI, and connected() does a single atomic 32-bit read of netif->ip_addr.
This commit is contained in:
@@ -80,7 +80,11 @@ void EthernetComponent::setup() {
|
||||
}
|
||||
|
||||
void EthernetComponent::loop() {
|
||||
// On RP2040, we need to poll connection state since there are no events
|
||||
// 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.
|
||||
// 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) {
|
||||
bool link_up = this->eth_->linkStatus() == LinkON;
|
||||
bool has_ip = this->eth_->connected();
|
||||
|
||||
Reference in New Issue
Block a user