From: Keith Packard Date: Sun, 13 Nov 2022 03:35:26 +0000 (-0800) Subject: altos/ms5607: Use duplex for fetching data X-Git-Tag: 1.9.13~1^2~26^2~17 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=5c182ab460fef614e2b987c808d4b4e2c4240a4f;p=fw%2Faltos altos/ms5607: Use duplex for fetching data Much more efficient than send/recv Signed-off-by: Keith Packard --- diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 46da4e83..1e4cd159 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -154,8 +154,7 @@ ao_ms5607_isr(void) static uint32_t ao_ms5607_get_sample(uint8_t cmd) { - uint8_t reply[3]; - uint8_t read; + uint8_t reply[4]; ao_ms5607_done = 0; @@ -179,12 +178,12 @@ ao_ms5607_get_sample(uint8_t cmd) { #endif ao_ms5607_start(); - read = AO_MS5607_ADC_READ; - ao_spi_send(&read, 1, AO_MS5607_SPI_INDEX); - ao_spi_recv(&reply, 3, AO_MS5607_SPI_INDEX); + memset(reply, 0, sizeof(reply)); + reply[0] = AO_MS5607_ADC_READ; + ao_spi_duplex(&reply, &reply, 6, AO_MS5607_SPI_INDEX); ao_ms5607_stop(); - return ((uint32_t) reply[0] << 16) | ((uint32_t) reply[1] << 8) | (uint32_t) reply[2]; + return ((uint32_t) reply[1] << 16) | ((uint32_t) reply[2] << 8) | (uint32_t) reply[3]; } #ifndef AO_MS5607_BARO_OVERSAMPLE