Date: Fri, 22 Feb 2013 14:15:06 +0000 Subject: [PATCH] fixed crash if MACB failed to sent a frame, a failed frame does not set the USED/OK bit, so the current implementation locked the circular buffer --- src/asf/avr32/drivers/macb/macb.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/asf/avr32/drivers/macb/macb.c b/src/asf/avr32/drivers/macb/macb.c index ac07afe..4fe19e3 100644 --- a/src/asf/avr32/drivers/macb/macb.c +++ b/src/asf/avr32/drivers/macb/macb.c @@ -572,30 +572,28 @@ void vClearMACBTxBuffer(void) // Tx buffer within the frame just transmitted. This marks all the buffers // as available again. - // The first buffer in the frame should have the bit set automatically. */ - if( xTxDescriptors[ uxNextBufferToClear ].U_Status.status & AVR32_TRANSMIT_OK ) - { - // Loop through the other buffers in the frame. - while( !( xTxDescriptors[ uxNextBufferToClear ].U_Status.status & AVR32_LAST_BUFFER ) ) - { - uxNextBufferToClear++; - - if( uxNextBufferToClear >= ETHERNET_CONF_NB_TX_BUFFERS ) - { - uxNextBufferToClear = 0; - } - - xTxDescriptors[ uxNextBufferToClear ].U_Status.status |= AVR32_TRANSMIT_OK; - } + xTxDescriptors[ uxNextBufferToClear ].U_Status.status |= AVR32_TRANSMIT_OK; - // Start with the next buffer the next time a Tx interrupt is called. + // Loop through the other buffers in the frame. + while( !( xTxDescriptors[ uxNextBufferToClear ].U_Status.status & AVR32_LAST_BUFFER ) ) + { uxNextBufferToClear++; - // Do we need to wrap back to the first buffer? if( uxNextBufferToClear >= ETHERNET_CONF_NB_TX_BUFFERS ) { uxNextBufferToClear = 0; } + + xTxDescriptors[ uxNextBufferToClear ].U_Status.status |= AVR32_TRANSMIT_OK; + } + + // Start with the next buffer the next time a Tx interrupt is called. + uxNextBufferToClear++; + + // Do we need to wrap back to the first buffer? + if( uxNextBufferToClear >= ETHERNET_CONF_NB_TX_BUFFERS ) + { + uxNextBufferToClear = 0; } } -- 2.5.1