diff --git a/part14-ethernet/kernel/arp.c b/part14-ethernet/kernel/arp.c index 9df07fa..6752c71 100644 --- a/part14-ethernet/kernel/arp.c +++ b/part14-ethernet/kernel/arp.c @@ -188,10 +188,14 @@ void arp_test(void) void init_network(void) { - handle.Init.DuplexMode = ETH_MODE_FULLDUPLEX; + handle.Init.DuplexMode = ETH_MODE_HALFDUPLEX; handle.Init.MACAddr = myMAC; 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."); debugcrlf(); @@ -202,7 +206,11 @@ void init_network(void) } 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(); - ENC_SetMacAddr(&handle); } diff --git a/part14-ethernet/net/enc28j60.c b/part14-ethernet/net/enc28j60.c index 0815fc6..05093a0 100644 --- a/part14-ethernet/net/enc28j60.c +++ b/part14-ethernet/net/enc28j60.c @@ -885,16 +885,6 @@ bool ENC_Start(ENC_HandleTypeDef *handle) /* Enable the receiver */ 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; }