Date:2013-04-01 19:29:57 (6 years 8 months ago)
Author:Werner Almesberger
Commit:d76bdf6a82d78b896456cce44caff6582d133482
Message:atusb/fw/mac.c (handle_irq): move frame reception to separate function

Files: atusb/fw/mac.c (2 diffs)

Change Details

atusb/fw/mac.c
6464}
6565
6666
67static void receive_frame(void)
68{
69    uint8_t size, i;
70
71    spi_begin();
72    if (!(spi_io(AT86RF230_BUF_READ) & RX_CRC_VALID)) {
73        spi_end();
74        return;
75    }
76    size = spi_recv();
77    if (!size || (size & 0x80)) {
78        spi_end();
79        return;
80    }
81
82    rx_buf[0] = size;
83    for (i = 0; i != size+1; i++)
84        rx_buf[i+1] = spi_recv();
85    spi_end();
86    led(1);
87    usb_send(&eps[1], rx_buf, size+2, rx_done, NULL);
88}
89
90
6791static bool handle_irq(void)
6892{
6993    uint8_t irq;
70    uint8_t size, i;
7194
7295    irq = reg_read(REG_IRQ_STATUS);
7396    if (!(irq & IRQ_TRX_END))
...... 
89112    if (eps[1].state != EP_IDLE)
90113        return 1;
91114
92    spi_begin();
93    if (!(spi_io(AT86RF230_BUF_READ) & RX_CRC_VALID)) {
94        spi_end();
95        return 1;
96    }
97    size = spi_recv();
98    if (!size || (size & 0x80)) {
99        spi_end();
100        return 1;
101    }
115    receive_frame();
102116
103    rx_buf[0] = size;
104    for (i = 0; i != size+1; i++)
105        rx_buf[i+1] = spi_recv();
106    spi_end();
107    led(1);
108    usb_send(&eps[1], rx_buf, size+2, rx_done, NULL);
109117    return 1;
110118}
111119

Archive Download the corresponding diff file



interactive