Unverified Commit d554df76 authored by Earle F. Philhower, III's avatar Earle F. Philhower, III Committed by GitHub

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

Fixes #2105

W5100 doesn't support isLinked, so no change needed there.
parent 3aaa132e
...@@ -715,8 +715,10 @@ uint16_t ENC28J60::phyread(uint8_t reg) { ...@@ -715,8 +715,10 @@ uint16_t ENC28J60::phyread(uint8_t reg) {
bool ENC28J60::isLinked() { bool ENC28J60::isLinked() {
// ( https://github.com/JAndrassy/EthernetENC/tree/master/src/utility/enc28j60.h ) // ( https://github.com/JAndrassy/EthernetENC/tree/master/src/utility/enc28j60.h )
ethernet_arch_lwip_gpio_mask();
ethernet_arch_lwip_begin(); ethernet_arch_lwip_begin();
auto ret = !!(phyread(MACSTAT2) & 0x400); auto ret = !!(phyread(MACSTAT2) & 0x400);
ethernet_arch_lwip_end(); ethernet_arch_lwip_end();
ethernet_arch_lwip_gpio_unmask();
return ret; return ret;
} }
...@@ -84,9 +84,11 @@ public: ...@@ -84,9 +84,11 @@ public:
@return true when physical link is up @return true when physical link is up
*/ */
bool isLinked() { bool isLinked() {
ethernet_arch_lwip_gpio_mask();
ethernet_arch_lwip_begin(); ethernet_arch_lwip_begin();
auto ret = wizphy_getphylink() == PHY_LINK_ON; auto ret = wizphy_getphylink() == PHY_LINK_ON;
ethernet_arch_lwip_end(); ethernet_arch_lwip_end();
ethernet_arch_lwip_gpio_unmask();
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment