From af16ae5e4885d6d2b6521f25aac91f939efbe3dd Mon Sep 17 00:00:00 2001 From: Jasper Gerth Date: Thu, 17 Dec 2020 09:08:26 +0100 Subject: [PATCH] Read all 16 bits in readPhyByte, not just upper 8 bits Adjusted isLinkUp accordingly --- src/enc28j60.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/enc28j60.cpp b/src/enc28j60.cpp index 586b638..a7ae63b 100644 --- a/src/enc28j60.cpp +++ b/src/enc28j60.cpp @@ -353,7 +353,7 @@ static uint16_t readPhyByte (byte address) { while (readRegByte(MISTAT) & MISTAT_BUSY) ; writeRegByte(MICMD, 0x00); - return readRegByte(MIRD+1); + return readRegByte(MIRD) | readRegByte(MIRD+1)<<8; //Read MIRDL and MIRDH } static void writePhy (byte address, uint16_t data) { @@ -415,7 +415,7 @@ byte ENC28J60::initialize (uint16_t size, const byte* macaddr, byte csPin) { } bool ENC28J60::isLinkUp() { - return (readPhyByte(PHSTAT2) >> 2) & 1; + return (readPhyByte(PHSTAT2) >> 10) & 1; //LSTAT is bit 10 } /*