Got link detection working on the Ethernet interface

This commit is contained in:
Adam Greenwood-Byrne 2021-10-30 12:11:59 +01:00
parent bca2e179f9
commit bbe5d156b7
2 changed files with 12 additions and 14 deletions

View file

@ -188,10 +188,14 @@ void arp_test(void)
void init_network(void) void init_network(void)
{ {
handle.Init.DuplexMode = ETH_MODE_FULLDUPLEX; handle.Init.DuplexMode = ETH_MODE_HALFDUPLEX;
handle.Init.MACAddr = myMAC; handle.Init.MACAddr = myMAC;
handle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE; handle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
handle.Init.InterruptEnableBits = 0; handle.Init.InterruptEnableBits = EIE_LINKIE;
debugstr("Setting MAC address to C0:FF:EE:C0:FF:EE.");
debugcrlf();
ENC_SetMacAddr(&handle);
debugstr("Starting network up."); debugstr("Starting network up.");
debugcrlf(); debugcrlf();
@ -202,7 +206,11 @@ void init_network(void)
} }
debugcrlf(); debugcrlf();
debugstr("Setting MAC address to C0:FF:EE:C0:FF:EE."); debugstr("Waiting for ifup.");
debugcrlf();
while (!(handle.LinkStatus & PHSTAT2_LSTAT)) ENC_IRQHandler(&handle);
debugstr("Link status: ");
debughex(((handle.LinkStatus & PHSTAT2_LSTAT) != 0));
debugcrlf(); debugcrlf();
ENC_SetMacAddr(&handle);
} }

View file

@ -885,16 +885,6 @@ bool ENC_Start(ENC_HandleTypeDef *handle)
/* Enable the receiver */ /* Enable the receiver */
enc_bfsgreg(ENC_ECON1, ECON1_RXEN); enc_bfsgreg(ENC_ECON1, ECON1_RXEN);
regval = enc_rdphy(handle, ENC_PHSTAT1) & PHSTAT1_LLSTAT;
debugstr("Link status 1: ");
debughex(regval);
debugcrlf();
regval = enc_rdphy(handle, ENC_PHSTAT2) & PHSTAT2_LSTAT;
debugstr("Link status 2: ");
debughex(regval);
debugcrlf();
return true; return true;
} }