IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Commit Details
Date: | 2013-04-01 20:17:37 (10 years 11 months ago) |
---|---|
Author: | Werner Almesberger |
Commit: | 65722d417abd17acf6a5783b4f84154ce9e9fbd7 |
Message: | atusb/fw/mac.c: queue frame reception if USB is busy This way we we make sure we retrieve the frame and thus release dynamic buffer protection (if enabled). |
Files: |
atusb/fw/mac.c (6 diffs) |
Change Details
atusb/fw/mac.c | ||
---|---|---|
30 | 30 | static uint8_t tx_size = 0; |
31 | 31 | static bool txing = 0; |
32 | 32 | static bool queued_tx_ack = 0; |
33 | static bool queued_rx = 0; | |
33 | 34 | |
34 | 35 | |
35 | 36 | static uint8_t reg_read(uint8_t reg) |
... | ... | |
54 | 55 | } |
55 | 56 | |
56 | 57 | |
58 | static void receive_frame(void); | |
59 | ||
60 | ||
57 | 61 | static void rx_done(void *user) |
58 | 62 | { |
59 | 63 | led(0); |
64 | if (queued_rx) { | |
65 | receive_frame(); | |
66 | queued_rx = 0; | |
67 | return; | |
68 | } | |
60 | 69 | if (queued_tx_ack) { |
61 | 70 | usb_send(&eps[1], "", 1, rx_done, NULL); |
62 | 71 | queued_tx_ack = 0; |
... | ... | |
88 | 97 | } |
89 | 98 | |
90 | 99 | |
100 | static void flush_queued_rx(void) | |
101 | { | |
102 | if (queued_rx) | |
103 | receive_frame(); | |
104 | queued_rx = 0; | |
105 | } | |
106 | ||
107 | ||
91 | 108 | static bool handle_irq(void) |
92 | 109 | { |
93 | 110 | uint8_t irq; |
... | ... | |
109 | 126 | } |
110 | 127 | |
111 | 128 | /* unlikely */ |
112 | if (eps[1].state != EP_IDLE) | |
129 | if (eps[1].state != EP_IDLE) { | |
130 | queued_rx = 1; | |
113 | 131 | return 1; |
132 | } | |
114 | 133 | |
115 | 134 | receive_frame(); |
116 | 135 | |
... | ... | |
165 | 184 | */ |
166 | 185 | reg_write(REG_TRX_STATE, TRX_CMD_FORCE_PLL_ON); |
167 | 186 | |
187 | flush_queued_rx(); | |
168 | 188 | handle_irq(); |
189 | queued_rx = 0; | |
169 | 190 | |
170 | 191 | spi_begin(); |
171 | 192 | spi_send(AT86RF230_BUF_WRITE); |
... | ... | |
201 | 222 | mac_irq = NULL; |
202 | 223 | txing = 0; |
203 | 224 | queued_tx_ack = 0; |
225 | queued_rx = 0; | |
204 | 226 | |
205 | 227 | /* enable CRC and PHY_RSSI (with RX_CRC_VALID) in SPI status return */ |
206 | 228 | reg_write(REG_TRX_CTRL_1, |