Skip to content

Commit

Permalink
Protect W5500/ENC28J60 isLinked() call from IRQ (#2115)
Browse files Browse the repository at this point in the history
Fixes #2105

W5100 doesn't support isLinked, so no change needed there.
  • Loading branch information
earlephilhower committed Apr 19, 2024
1 parent 3aaa132 commit d554df7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libraries/lwIP_enc28j60/src/utility/enc28j60.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions libraries/lwIP_w5500/src/utility/w5500.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@ class Wiznet5500 {
@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;
}

Expand Down

0 comments on commit d554df7

Please sign in to comment.