From 434e946aa79b5a7e60799f996887bc6467889b92 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 31 Dec 2012 14:22:37 -0800 Subject: Allow CC1120 to sit on other SPI busses Reading the incoming data bypasses the SPI API and touches the SPI data register directly; which port that is needs to be specified in the pins file Signed-off-by: Keith Packard --- src/drivers/ao_cc1120.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/drivers/ao_cc1120.c') diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index 63d2f955..d9b2e5bf 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -834,8 +834,8 @@ ao_radio_rx_isr(void) { uint8_t d; - d = stm_spi2.dr; - stm_spi2.dr = 0; + d = AO_CC1120_SPI.dr; + AO_CC1120_SPI.dr = 0; if (rx_ignore == 0) { if (rx_data_cur >= rx_data_count) ao_exti_disable(AO_CC1120_INT_PORT, AO_CC1120_INT_PIN); @@ -922,10 +922,10 @@ ao_radio_recv(__xdata void *d, uint8_t size) ao_radio_wake = 0; ao_radio_mcu_wake = 0; - stm_spi2.cr2 = 0; + AO_CC1120_SPI.cr2 = 0; /* clear any RXNE */ - (void) stm_spi2.dr; + (void) AO_CC1120_SPI.dr; /* Have the radio signal when the preamble quality goes high */ ao_radio_reg_write(AO_CC1120_INT_GPIO_IOCFG, CC1120_IOCFG_GPIO_CFG_PQT_REACHED); -- cgit v1.2.3 From acff2f466031fd1a8533fc315411c3734a8bacc6 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 10 Jan 2013 21:27:32 -0800 Subject: altos: Time out reading packet data from cc1120 after 100ms Sometimes the radio will give a spurious wakeup indicating that a preamble seems to have arrived, but no packet data will appear. In this case, abandon the packet reception and go back to waiting for a preamble again. This releases the SPI bus for other users and also avoids missing packets. Signed-off-by: Keith Packard --- src/drivers/ao_cc1120.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/drivers/ao_cc1120.c') diff --git a/src/drivers/ao_cc1120.c b/src/drivers/ao_cc1120.c index 63d2f955..35be54a4 100644 --- a/src/drivers/ao_cc1120.c +++ b/src/drivers/ao_cc1120.c @@ -862,6 +862,7 @@ ao_radio_rx_wait(void) do { if (ao_radio_mcu_wake) ao_radio_check_marc_status(); + ao_alarm(AO_MS_TO_TICKS(100)); ao_arch_block_interrupts(); rx_waiting = 1; while (rx_data_cur - rx_data_consumed < AO_FEC_DECODE_BLOCK && @@ -873,6 +874,7 @@ ao_radio_rx_wait(void) } rx_waiting = 0; ao_arch_release_interrupts(); + ao_clear_alarm(); } while (ao_radio_mcu_wake); if (ao_radio_abort) return 0; -- cgit v1.2.3