altos/ms5607: Fixup ms5607 changes for other chips
authorKeith Packard <keithp@keithp.com>
Sun, 13 Nov 2022 07:35:40 +0000 (23:35 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 13 Nov 2022 08:17:32 +0000 (00:17 -0800)
A couple of chips don't bother providing duplex, so allow for that.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_ms5607.c

index 1e4cd1595e74ea959c93d77bfa561d9df7cadd6a..1cddcaf570e540656a2e42b2550a299167c82422 100644 (file)
@@ -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];