diff options
| author | Keith Packard <keithp@keithp.com> | 2013-04-28 23:03:57 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2013-05-07 20:07:52 -0700 | 
| commit | b878ca38045b1bee6ea4d649298727ac3fa197c2 (patch) | |
| tree | eb15d0a4adda6d85c3d7fa0634a71dcb6f98e234 /src | |
| parent | f677a83348a9568679240ee9d731ab454f289831 (diff) | |
altos: Make cc1120 driver wait for TX finished
Otherwise, we may come in and try to use the radio again too quickly,
causing it to go into a TX fifo error state.
This change watches the MARC status until the transmitter is
explicitly marked as finished.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/ao_cc1120.c | 6 | 
1 files changed, 6 insertions, 0 deletions
| diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index 5add45e4..bad0c856 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -30,6 +30,7 @@ static uint8_t ao_radio_wake;		/* radio ready. Also used as sleep address */  static uint8_t ao_radio_abort;		/* radio operation should abort */  static uint8_t ao_radio_mcu_wake;	/* MARC status change */  static uint8_t ao_radio_marc_status;	/* Last read MARC status value */ +static uint8_t ao_radio_tx_finished;	/* MARC status indicates TX finished */  #define CC1120_DEBUG	AO_FEC_DEBUG  #define CC1120_TRACE	0 @@ -242,6 +243,8 @@ ao_radio_check_marc_status(void)  	/* Anyt other than 'tx/rx finished' means an error occurred */  	if (ao_radio_marc_status & ~(CC1120_MARC_STATUS1_TX_FINISHED|CC1120_MARC_STATUS1_RX_FINISHED))  		ao_radio_abort = 1; +	if (ao_radio_marc_status & (CC1120_MARC_STATUS1_TX_FINISHED)) +		ao_radio_tx_finished = 1;  }  static void @@ -258,6 +261,7 @@ ao_radio_start_tx(void)  	ao_exti_set_callback(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN, ao_radio_isr);  	ao_exti_enable(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN);  	ao_exti_enable(AO_CC1120_MCU_WAKEUP_PORT, AO_CC1120_MCU_WAKEUP_PIN); +	ao_radio_tx_finished = 0;  	ao_radio_strobe(CC1120_STX);  } @@ -746,6 +750,8 @@ ao_radio_send(const void *d, uint8_t size)  			break;  		}  	} +	while (started && !ao_radio_abort && !ao_radio_tx_finished) +		ao_radio_wait_isr(0);  	ao_radio_put();  } | 
