From: Keith Packard Date: Fri, 26 Apr 2013 04:25:39 +0000 (-0700) Subject: altos: Make SD card driver compile without radio support X-Git-Tag: 1.2.1~101 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=4ed83e34d1163c7fae0a205528c60dc83973082a;hp=90b0db1ae53182c94bf12d661446fc369d916366 altos: Make SD card driver compile without radio support The SD card driver blocks the radio when trying to access the card as that operation appears very sensitive to RFI. This fix makes the driver work when there *isn't* a radio driver in the same device. Signed-off-by: Keith Packard --- diff --git a/src/drivers/ao_sdcard.c b/src/drivers/ao_sdcard.c index c13017f0..7806bc19 100644 --- a/src/drivers/ao_sdcard.c +++ b/src/drivers/ao_sdcard.c @@ -18,11 +18,18 @@ #include "ao.h" #include "ao_sdcard.h" +#if HAS_RADIO extern uint8_t ao_radio_mutex; +#define get_radio() ao_mutex_get(&ao_radio_mutex) +#define put_radio() ao_mutex_put(&ao_radio_mutex) +#else +#define get_radio() +#define put_radio() +#endif -#define ao_sdcard_get_slow() do { ao_mutex_get(&ao_radio_mutex); ao_spi_get(AO_SDCARD_SPI_BUS, AO_SPI_SPEED_250kHz); } while (0) -#define ao_sdcard_get() do { ao_mutex_get(&ao_radio_mutex); ao_spi_get(AO_SDCARD_SPI_BUS, AO_SPI_SPEED_FAST); } while (0) -#define ao_sdcard_put() do { ao_spi_put(AO_SDCARD_SPI_BUS); ao_mutex_put(&ao_radio_mutex); } while (0) +#define ao_sdcard_get_slow() do { get_radio(); ao_spi_get(AO_SDCARD_SPI_BUS, AO_SPI_SPEED_250kHz); } while (0) +#define ao_sdcard_get() do { get_radio(); ao_spi_get(AO_SDCARD_SPI_BUS, AO_SPI_SPEED_FAST); } while (0) +#define ao_sdcard_put() do { ao_spi_put(AO_SDCARD_SPI_BUS); put_radio(); } while (0) #define ao_sdcard_send_fixed(d,l) ao_spi_send_fixed((d), (l), AO_SDCARD_SPI_BUS) #define ao_sdcard_send(d,l) ao_spi_send((d), (l), AO_SDCARD_SPI_BUS) #define ao_sdcard_recv(d,l) ao_spi_recv((d), (l), AO_SDCARD_SPI_BUS)