From b4960336c0ae960bee40fdd337e58fcc8846ac87 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 12 Nov 2022 23:35:40 -0800 Subject: [PATCH] altos/ms5607: Fixup ms5607 changes for other chips A couple of chips don't bother providing duplex, so allow for that. Signed-off-by: Keith Packard --- src/drivers/ao_ms5607.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 1e4cd159..1cddcaf5 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -178,9 +178,13 @@ ao_ms5607_get_sample(uint8_t cmd) { #endif ao_ms5607_start(); - memset(reply, 0, sizeof(reply)); reply[0] = AO_MS5607_ADC_READ; - ao_spi_duplex(&reply, &reply, 6, AO_MS5607_SPI_INDEX); +#if defined(AO_SPI_DUPLEX) && AO_SPI_DUPLEX == 0 + ao_spi_send(reply, 1, AO_MS5607_SPI_INDEX); + ao_spi_recv(reply+1, 3, AO_MS5607_SPI_INDEX); +#else + ao_spi_duplex(&reply, &reply, 4, AO_MS5607_SPI_INDEX); +#endif ao_ms5607_stop(); return ((uint32_t) reply[1] << 16) | ((uint32_t) reply[2] << 8) | (uint32_t) reply[3]; -- 2.30.2