summaryrefslogtreecommitdiff
path: root/src/drivers/ao_companion.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-04-09 23:27:43 -0700
committerKeith Packard <keithp@keithp.com>2012-04-14 13:21:09 -0700
commit0dd9e1dd62656a931f9559af6da9131f704f83f9 (patch)
treef0c659cda9e107b8a835c0f815d4153e4da09c8e /src/drivers/ao_companion.c
parent35e3c47da895bdd868b9b66b98bca64bd82db862 (diff)
altos: Add support for multiple SPI busses and sharing device drivers
The STM32L151 has several SPI busses, and we want to use more than one, so add a 'bus' parameter to the SPI interfaces. To avoid wasting time on AVR and CC1111 processors which only use one SPI bus, elide those parameters from the actual functions by wrapping them with macros. Configuring chip select is now all macroized so that each chip can have its own version, allowing the STM to share the various SPI device drivers with the cc1111 and avr processors. Note that only the M25 driver has been ported; porting the others is 'trivial', but not necessary at this point. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/drivers/ao_companion.c')
-rw-r--r--src/drivers/ao_companion.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/drivers/ao_companion.c b/src/drivers/ao_companion.c
index 2e587f8e..fe88e998 100644
--- a/src/drivers/ao_companion.c
+++ b/src/drivers/ao_companion.c
@@ -27,8 +27,8 @@
UxGCR_ORDER_MSB | \
(17 << UxGCR_BAUD_E_SHIFT)))
-#define COMPANION_SELECT() do { ao_spi_get_bit(COMPANION_CS); ao_spi_slow(); } while (0)
-#define COMPANION_DESELECT() do { ao_spi_fast(); ao_spi_put_bit(COMPANION_CS); } while (0)
+#define COMPANION_SELECT() do { ao_spi_get_bit(COMPANION_CS, AO_COMPANION_BUS); ao_spi_slow(); } while (0)
+#define COMPANION_DESELECT() do { ao_spi_fast(); ao_spi_put_bit(COMPANION_CS, AO_COMPANION_BUS); } while (0)
__xdata struct ao_companion_command ao_companion_command;
__xdata struct ao_companion_setup ao_companion_setup;
@@ -45,7 +45,7 @@ ao_companion_send_command(uint8_t command)
ao_companion_command.tick = ao_time();
ao_companion_command.serial = ao_serial_number;
ao_companion_command.flight = ao_flight_number;
- ao_spi_send(&ao_companion_command, sizeof (ao_companion_command));
+ ao_spi_send(&ao_companion_command, sizeof (ao_companion_command), AO_COMPANION_SPI_BUS);
}
static uint8_t
@@ -53,7 +53,7 @@ ao_companion_get_setup(void)
{
COMPANION_SELECT();
ao_companion_send_command(AO_COMPANION_SETUP);
- ao_spi_recv(&ao_companion_setup, sizeof (ao_companion_setup));
+ ao_spi_recv(&ao_companion_setup, sizeof (ao_companion_setup), AO_COMPANION_SPI_BUS);
COMPANION_DESELECT();
return (ao_companion_setup.board_id ==
~ao_companion_setup.board_id_inverse);
@@ -65,7 +65,7 @@ ao_companion_get_data(void)
COMPANION_SELECT();
ao_companion_send_command(AO_COMPANION_FETCH);
ao_mutex_get(&ao_companion_mutex);
- ao_spi_recv(&ao_companion_data, ao_companion_setup.channels * 2);
+ ao_spi_recv(&ao_companion_data, ao_companion_setup.channels * 2, AO_COMPANION_SPI_BUS);
ao_mutex_put(&ao_companion_mutex);
COMPANION_DESELECT();
}