Protect W5500/ENC28J60 isLinked() call from IRQ (#2115)

Fixes #2105

W5100 doesn't support isLinked, so no change needed there.
This commit is contained in:
Earle F. Philhower, III 2024-04-19 13:59:11 -07:00 committed by GitHub
parent 3aaa132e2e
commit d554df7670
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -715,8 +715,10 @@ uint16_t ENC28J60::phyread(uint8_t reg) {
bool ENC28J60::isLinked() {
// ( https://github.com/JAndrassy/EthernetENC/tree/master/src/utility/enc28j60.h )
ethernet_arch_lwip_gpio_mask();
ethernet_arch_lwip_begin();
auto ret = !!(phyread(MACSTAT2) & 0x400);
ethernet_arch_lwip_end();
ethernet_arch_lwip_gpio_unmask();
return ret;
}

View file

@ -84,9 +84,11 @@ public:
@return true when physical link is up
*/
bool isLinked() {
ethernet_arch_lwip_gpio_mask();
ethernet_arch_lwip_begin();
auto ret = wizphy_getphylink() == PHY_LINK_ON;
ethernet_arch_lwip_end();
ethernet_arch_lwip_gpio_unmask();
return ret;
}