Merge pull request #74 from malvira/maca-dummy-rx

Receive packets in a dummy_rx when the maca packet pool is
This commit is contained in:
Adam Dunkels 2013-01-06 14:10:23 -08:00
commit 326781ef43

View File

@ -96,6 +96,7 @@ volatile packet_t *rx_head, *tx_head;
/* used for ack recpetion if the packet_pool goes empty */ /* used for ack recpetion if the packet_pool goes empty */
/* doesn't go back into the pool when freed */ /* doesn't go back into the pool when freed */
static volatile packet_t dummy_ack; static volatile packet_t dummy_ack;
static volatile packet_t dummy_rx;
/* incremented on every maca entry */ /* incremented on every maca entry */
/* you can use this to detect that the receive loop is still running */ /* you can use this to detect that the receive loop is still running */
@ -359,6 +360,7 @@ void post_receive(void) {
dma_rx = get_free_packet(); dma_rx = get_free_packet();
if (dma_rx == 0) { if (dma_rx == 0) {
PRINTF("trying to fill MACA_DMARX in post_receieve but out of packet buffers\n\r"); PRINTF("trying to fill MACA_DMARX in post_receieve but out of packet buffers\n\r");
dma_rx = &dummy_rx;
/* set the sftclock so that we return to the maca_isr */ /* set the sftclock so that we return to the maca_isr */
*MACA_SFTCLK = *MACA_CLK + RECV_SOFTIMEOUT; /* soft timeout */ *MACA_SFTCLK = *MACA_CLK + RECV_SOFTIMEOUT; /* soft timeout */
*MACA_TMREN = (1 << maca_tmren_sft); *MACA_TMREN = (1 << maca_tmren_sft);
@ -652,12 +654,15 @@ void maca_isr(void) {
if (data_indication_irq()) { if (data_indication_irq()) {
*MACA_CLRIRQ = (1 << maca_irq_di); *MACA_CLRIRQ = (1 << maca_irq_di);
if (dma_rx != &dummy_ack && dma_rx != &dummy_rx)
{
dma_rx->length = *MACA_GETRXLVL - 2; /* packet length does not include FCS */ dma_rx->length = *MACA_GETRXLVL - 2; /* packet length does not include FCS */
dma_rx->lqi = get_lqi(); dma_rx->lqi = get_lqi();
dma_rx->rx_time = *MACA_TIMESTAMP; dma_rx->rx_time = *MACA_TIMESTAMP;
/* check if received packet needs an ack */ /* check if received packet needs an ack */
if(prm_mode == AUTOACK && (dma_rx->data[1] & MAC_ACK_REQUEST_FLAG)) { if(prm_mode == AUTOACK && (dma_rx->data[1] & 0x20)) {
/* this wait is necessary to auto-ack */ /* this wait is necessary to auto-ack */
volatile uint32_t wait_clk; volatile uint32_t wait_clk;
wait_clk = *MACA_CLK + 200; wait_clk = *MACA_CLK + 200;
@ -667,6 +672,7 @@ void maca_isr(void) {
if(maca_rx_callback != 0) { maca_rx_callback(dma_rx); } if(maca_rx_callback != 0) { maca_rx_callback(dma_rx); }
add_to_rx(dma_rx); add_to_rx(dma_rx);
}
dma_rx = 0; dma_rx = 0;
} }
if (filter_failed_irq()) { if (filter_failed_irq()) {