From f4c812bef76a2cd95f675cb27ea89059561ceec7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 13 Feb 2015 23:51:10 -0800 Subject: altos: Replace ao_alarm/ao_clear_alarm with ao_sleep_for Having arbitrary alarms firing in the middle of complicated device logic makes no sense at all. Therefore only correct use of ao_alarm and ao_clear_alarm was around a specific ao_sleep call, with correct recovery in case the alarm fires. This patch replaces all uses of ao_alarm/ao_sleep/ao_clear_alarm with ao_sleep_for, a new function which takes the alarm timeout directly. A few cases which weren't simply calling ao_sleep have been reworked to pass the timeout value down to the place where sleep *is* being called, and having that code deal with the return correctly. Signed-off-by: Keith Packard --- src/drivers/ao_cc1200.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/drivers/ao_cc1200.c') diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c index 8546900e..df4bd335 100644 --- a/src/drivers/ao_cc1200.c +++ b/src/drivers/ao_cc1200.c @@ -715,17 +715,11 @@ ao_radio_show_state(char *where) static void ao_radio_wait_isr(uint16_t timeout) { - if (timeout) - ao_alarm(timeout); - ao_arch_block_interrupts(); while (!ao_radio_wake && !ao_radio_abort) - if (ao_sleep(&ao_radio_wake)) + if (ao_sleep_for(&ao_radio_wake, timeout)) ao_radio_abort = 1; ao_arch_release_interrupts(); - - if (timeout) - ao_clear_alarm(); } static void -- cgit v1.2.3 From dba00b3d9102db99592f5822a703e64d98ace8bb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 19 May 2015 10:17:01 -0700 Subject: altos: Support 32MHz xtal on cc1200 I ended up building some cc1200-based boards with 32MHz xtals, so just make this an option when building the driver. Signed-off-by: Keith Packard --- src/drivers/ao_cc1200.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/drivers/ao_cc1200.c') diff --git a/src/drivers/ao_cc1200.c b/src/drivers/ao_cc1200.c index df4bd335..6547be39 100644 --- a/src/drivers/ao_cc1200.c +++ b/src/drivers/ao_cc1200.c @@ -41,7 +41,11 @@ int8_t ao_radio_rssi; /* Last received RSSI value */ extern const uint32_t ao_radio_cal; +#ifdef AO_CC1200_FOSC +#define FOSC AO_CC1200_FOSC +#else #define FOSC 40000000 +#endif #define ao_radio_select() ao_spi_get_mask(AO_CC1200_SPI_CS_PORT,(1 << AO_CC1200_SPI_CS_PIN),AO_CC1200_SPI_BUS,AO_SPI_SPEED_FAST) #define ao_radio_deselect() ao_spi_put_mask(AO_CC1200_SPI_CS_PORT,(1 << AO_CC1200_SPI_CS_PIN),AO_CC1200_SPI_BUS) @@ -301,20 +305,28 @@ ao_radio_idle(void) * CHANBW = 5.0 (round to 9.5) */ +#if FOSC == 40000000 #define PACKET_SYMBOL_RATE_M 1013008 - #define PACKET_SYMBOL_RATE_E_384 8 +#define PACKET_SYMBOL_RATE_E_96 6 +#define PACKET_SYMBOL_RATE_E_24 4 +#endif + +#if FOSC == 32000000 +#define PACKET_SYMBOL_RATE_M 239914 +#define PACKET_SYMBOL_RATE_E_384 9 +#define PACKET_SYMBOL_RATE_E_96 7 +#define PACKET_SYMBOL_RATE_E_24 5 +#endif /* 200 / 2 = 100 */ #define PACKET_CHAN_BW_384 ((CC1200_CHAN_BW_ADC_CIC_DECFACT_12 << CC1200_CHAN_BW_ADC_CIC_DECFACT) | \ (16 << CC1200_CHAN_BW_BB_CIC_DECFACT)) -#define PACKET_SYMBOL_RATE_E_96 6 /* 200 / 10 = 20 */ #define PACKET_CHAN_BW_96 ((CC1200_CHAN_BW_ADC_CIC_DECFACT_48 << CC1200_CHAN_BW_ADC_CIC_DECFACT) | \ (16 << CC1200_CHAN_BW_BB_CIC_DECFACT)) -#define PACKET_SYMBOL_RATE_E_24 4 /* 200 / 25 = 8 */ #define PACKET_CHAN_BW_24 ((CC1200_CHAN_BW_ADC_CIC_DECFACT_48 << CC1200_CHAN_BW_ADC_CIC_DECFACT) | \ (44 << CC1200_CHAN_BW_BB_CIC_DECFACT)) -- cgit v1.2.3