summaryrefslogtreecommitdiff
path: root/src/drivers/ao_cc1200.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-10-25 17:44:48 -0700
committerKeith Packard <keithp@keithp.com>2014-10-25 17:44:48 -0700
commitc831f1ffb378c20b7513d209d60cdd5dee9db85b (patch)
treed4755d34dc92976267debf16cba4297e37a8b0a4 /src/drivers/ao_cc1200.c
parent3f7263f57b1b697d92ed6c3d62956e5bdfc11f24 (diff)
altos: Perform cc1200 calibration less often. Tweak radio params
This performs calibration after every 4 operations, or when the frequency changes. This reduces the time it takes to get to receive mode. This also makes the sync and preamble qualifiers more strict to reject bad packets. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/drivers/ao_cc1200.c')
-rw-r--r--src/drivers/ao_cc1200.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c
index 39d3d522..a3c1cbd4 100644
--- a/src/drivers/ao_cc1200.c
+++ b/src/drivers/ao_cc1200.c
@@ -219,18 +219,18 @@ ao_radio_idle(void)
{
for (;;) {
uint8_t state = (ao_radio_strobe(CC1200_SIDLE) >> CC1200_STATUS_STATE) & CC1200_STATUS_STATE_MASK;
- if (state == CC1200_STATUS_STATE_IDLE) {
- ao_radio_strobe(CC1200_SFTX);
- ao_radio_strobe(CC1200_SFRX);
+ if (state == CC1200_STATUS_STATE_IDLE)
break;
- }
if (state == CC1200_STATUS_STATE_TX_FIFO_ERROR)
ao_radio_strobe(CC1200_SFTX);
if (state == CC1200_STATUS_STATE_RX_FIFO_ERROR)
ao_radio_strobe(CC1200_SFRX);
}
- /* Flush any pending TX bytes */
+ /* Flush any pending data in the fifos */
ao_radio_strobe(CC1200_SFTX);
+ ao_radio_strobe(CC1200_SFRX);
+ /* Make sure the RF calibration is current */
+ ao_radio_strobe(CC1200_SCAL);
}
/*
@@ -635,6 +635,8 @@ ao_radio_setup(void)
ao_radio_mode = 0;
+ ao_radio_idle();
+
ao_config_get();
ao_radio_configured = 1;
@@ -666,6 +668,7 @@ ao_radio_get(uint8_t len)
ao_radio_reg_write(CC1200_FREQ1, ao_config.radio_setting >> 8);
ao_radio_reg_write(CC1200_FREQ0, ao_config.radio_setting);
last_radio_setting = ao_config.radio_setting;
+ ao_radio_strobe(CC1200_SCAL);
}
if (ao_config.radio_rate != last_radio_rate) {
ao_radio_mode &= ~AO_RADIO_MODE_BITS_PACKET;
@@ -994,9 +997,8 @@ uint8_t
ao_radio_recv(__xdata void *d, uint8_t size, uint8_t timeout)
{
ao_radio_abort = 0;
- ao_radio_wake = 0;
+
ao_radio_get(size - 2);
- ao_radio_idle();
ao_radio_set_mode(AO_RADIO_MODE_PACKET_RX);
ao_radio_wake = 0;
ao_radio_start_rx();