diff options
author | Keith Packard <keithp@keithp.com> | 2014-09-26 22:53:39 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2014-09-26 23:00:37 -0700 |
commit | 1b19c9b0c622b79a0fa251fd369eb6834256b4f7 (patch) | |
tree | 769ca889ce8787085961bf19e7f180454be88a12 /src/drivers/ao_cc1120.c | |
parent | 453abb62172324989b38629772f32eddf0c46ea7 (diff) |
altos: Make sure we drop the SPI mutex when aborting cc1120 recvbranch-1.5
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>
Diffstat (limited to 'src/drivers/ao_cc1120.c')
-rw-r--r-- | src/drivers/ao_cc1120.c | 9 |
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; } |