From a4ab4e8873d5da47d5d78bdaa3e14ce49c259166 Mon Sep 17 00:00:00 2001 From: fizgig10 Date: Mon, 16 Feb 2015 13:16:24 -0800 Subject: [PATCH] Update enc28j60.c Fixed errata handling so it works now. --- enc28j60.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/enc28j60.c b/enc28j60.c index 2ca78aa..bf35569 100644 --- a/enc28j60.c +++ b/enc28j60.c @@ -276,6 +276,11 @@ uint8_t enc28j60getrev(void) void enc28j60PacketSend(uint16_t len, uint8_t* packet) { + // Reset the transmit logic problem. See Errata point 12 for all chip revs + enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRST); + enc28j60WriteOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRST); + enc28j60WriteOp(ENC28J60_BIT_FIELD_CLR, EIR, EIR_TXERIF); + // Set the write pointer to start of transmit buffer area enc28j60Write(EWRPTL, TXSTART_INIT&0xFF); enc28j60Write(EWRPTH, TXSTART_INIT>>8); @@ -288,10 +293,6 @@ void enc28j60PacketSend(uint16_t len, uint8_t* packet) enc28j60WriteBuffer(len, packet); // send the contents of the transmit buffer onto the network enc28j60WriteOp(ENC28J60_BIT_FIELD_SET, ECON1, ECON1_TXRTS); - // Reset the transmit logic problem. See Rev. B4 Silicon Errata point 12. - if( (enc28j60Read(EIR) & EIR_TXERIF) ){ - enc28j60WriteOp(ENC28J60_BIT_FIELD_CLR, ECON1, ECON1_TXRTS); - } } // Gets a packet from the network receive buffer, if one is available.