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 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <LwipEthernet.h>
#include "enc28j60.h"
......@@ -696,6 +697,8 @@ uint16_t ENC28J60::phyread(uint8_t reg) {
bool ENC28J60::isLinked() {
// ( https://github.com/JAndrassy/EthernetENC/tree/master/src/utility/enc28j60.h )
return !!(phyread(MACSTAT2) & 0x400);
ethernet_arch_lwip_begin();
auto ret = !!(phyread(MACSTAT2) & 0x400);
ethernet_arch_lwip_end();
return ret;
}
......@@ -38,6 +38,7 @@
#include <stdint.h>
#include <Arduino.h>
#include <SPI.h>
#include <LwipEthernet.h>
class Wiznet5500 {
public:
......@@ -83,7 +84,10 @@ public:
@return true when physical link is up
*/
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