Skip to content

Commit

Permalink
Read all 16 bits in readPhyByte, not just upper 8 bits
Browse files Browse the repository at this point in the history
Adjusted isLinkUp accordingly
  • Loading branch information
JerthG committed Dec 19, 2020
1 parent 39a1188 commit af16ae5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/enc28j60.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}

/*
Expand Down

0 comments on commit af16ae5

Please sign in to comment.