The SD card really doesn't like the RFI generated by our enormous
radio, so just lock the radio out while working with the card.
Signed-off-by: Keith Packard <keithp@keithp.com>
#define AO_RADIO_MAX_SEND sizeof (struct ao_telemetry_generic)
#define AO_RADIO_MAX_SEND sizeof (struct ao_telemetry_generic)
-static uint8_t ao_radio_mutex;
static uint8_t ao_radio_fifo; /* fifo drained interrupt received */
static uint8_t ao_radio_done; /* tx done interrupt received */
static uint8_t ao_radio_fifo; /* fifo drained interrupt received */
static uint8_t ao_radio_done; /* tx done interrupt received */
#include "ao.h"
#include "ao_sdcard.h"
#include "ao.h"
#include "ao_sdcard.h"
-#define ao_sdcard_get_slow() ao_spi_get(AO_SDCARD_SPI_BUS, AO_SPI_SPEED_250kHz)
-#define ao_sdcard_get() ao_spi_get(AO_SDCARD_SPI_BUS, AO_SPI_SPEED_FAST)
-#define ao_sdcard_put() ao_spi_put(AO_SDCARD_SPI_BUS)
+extern uint8_t ao_radio_mutex;
+
+#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_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)
#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)
void
ao_sdcard_init(void)
{
void
ao_sdcard_init(void)
{
+ stm_pupdr_set(AO_SDCARD_SPI_PORT, AO_SDCARD_SPI_SCK_PIN, STM_PUPDR_PULL_UP);
+ stm_pupdr_set(AO_SDCARD_SPI_PORT, AO_SDCARD_SPI_MISO_PIN, STM_PUPDR_PULL_UP);
+ stm_pupdr_set(AO_SDCARD_SPI_PORT, AO_SDCARD_SPI_MOSI_PIN, STM_PUPDR_PULL_UP);
ao_spi_init_cs(AO_SDCARD_SPI_CS_PORT, (1 << AO_SDCARD_SPI_CS_PIN));
#if SDCARD_DEBUG
ao_cmd_register(&ao_sdcard_cmds[0]);
ao_spi_init_cs(AO_SDCARD_SPI_CS_PORT, (1 << AO_SDCARD_SPI_CS_PIN));
#if SDCARD_DEBUG
ao_cmd_register(&ao_sdcard_cmds[0]);
ao_fat_init();
ao_gps_init();
ao_fat_init();
ao_gps_init();
-// ao_gps_report_mega_init();
+ ao_gps_report_mega_init();
ao_telemetry_init();
ao_telemetry_set_interval(AO_SEC_TO_TICKS(1));
ao_telemetry_init();
ao_telemetry_set_interval(AO_SEC_TO_TICKS(1));