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

Protect W5500/ENC28J60 isLinked from interrupt (#1805)

Fixes #1786
parent 8ac616e8
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <LwipEthernet.h>
#include "enc28j60.h" #include "enc28j60.h"
...@@ -696,6 +697,8 @@ uint16_t ENC28J60::phyread(uint8_t reg) { ...@@ -696,6 +697,8 @@ 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_begin();
return !!(phyread(MACSTAT2) & 0x400); auto ret = !!(phyread(MACSTAT2) & 0x400);
ethernet_arch_lwip_end();
return ret;
} }
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <stdint.h> #include <stdint.h>
#include <Arduino.h> #include <Arduino.h>
#include <SPI.h> #include <SPI.h>
#include <LwipEthernet.h>
class Wiznet5500 { class Wiznet5500 {
public: public:
...@@ -83,7 +84,10 @@ public: ...@@ -83,7 +84,10 @@ public:
@return true when physical link is up @return true when physical link is up
*/ */
bool isLinked() { bool isLinked() {
return wizphy_getphylink() == PHY_LINK_ON; ethernet_arch_lwip_begin();
auto ret = wizphy_getphylink() == PHY_LINK_ON;
ethernet_arch_lwip_end();
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