summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-09-26 22:53:39 -0700
committerKeith Packard <keithp@keithp.com>2014-09-26 23:01:18 -0700
commitb4eba3f3a58a9c35e3699ff14405b997c1318d91 (patch)
tree065d882a65ef1744d71d34ac1843ecbb61389d88
parent22661ba69b8919116092382f1f5aa0dc79d02cc9 (diff)
altos: Make sure we drop the SPI mutex when aborting cc1120 recv
The cc1120 receive code is 'twisty', in that it acquires the SPI mutex in the middle of an interrupt handler so that it can quickly start the radio when the signal comes in. This means we have to be careful to drop that mutex in all paths which leave the receive code, including when the packet receive is aborted mid-way through the process. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/drivers/ao_cc1120.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c
index 3ea8b704..90d6cc75 100644
--- a/src/drivers/ao_cc1120.c
+++ b/src/drivers/ao_cc1120.c
@@ -1125,12 +1125,12 @@ ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout)
ao_exti_set_mode(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN,
AO_EXTI_MODE_FALLING|AO_EXTI_PRIORITY_HIGH);
- ao_exti_set_callback(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN, ao_radio_rx_isr);
- ao_exti_enable(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN);
-
rx_starting = 1;
rx_task_id = ao_cur_task->task_id;
+ ao_exti_set_callback(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN, ao_radio_rx_isr);
+ ao_exti_enable(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN);
+
ao_radio_strobe(CC1120_SRX);
if (timeout)
@@ -1148,8 +1148,9 @@ ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout)
ao_clear_alarm();
if (ao_radio_abort) {
+ if (rx_task_id_save == 0)
+ ao_radio_burst_read_stop();
ret = 0;
- rx_task_id = 0;
goto abort;
}