Skip to content

Commit

Permalink
Check for valid PHID
Browse files Browse the repository at this point in the history
  • Loading branch information
Extrems committed May 26, 2024
1 parent fa05d20 commit 92d4d35
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lwip/netif/enc28j60if.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ static s32 UnlockedHandler(s32 chan, s32 dev)
static bool ENC28J60_Init(s32 chan, s32 dev, struct enc28j60if *enc28j60if)
{
bool err = false;
u16 phid1, phid2;
u32 id;

if (chan < EXI_CHANNEL_2 && dev == EXI_DEVICE_0) {
Expand All @@ -599,7 +600,9 @@ static bool ENC28J60_Init(s32 chan, s32 dev, struct enc28j60if *enc28j60if)
CurrBank[chan] = 0;
usleep(1000);

if (!EXI_GetIDEx(chan, dev, &id) || id != 0xFA050000) {
if (!EXI_GetIDEx(chan, dev, &id) || id != 0xFA050000 ||
!ENC28J60_ReadPHYReg(chan, ENC28J60_PHID1, &phid1) || phid1 != 0x0083 ||
!ENC28J60_ReadPHYReg(chan, ENC28J60_PHID2, &phid2) || phid2 != 0x1400) {
if (chan < EXI_CHANNEL_2 && dev == EXI_DEVICE_0)
EXI_Detach(chan);
EXI_Unlock(chan);
Expand Down

0 comments on commit 92d4d35

Please sign in to comment.