From f3f64abc49e20723dd00f0ecc5201f015d4744c3 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Wed, 7 Mar 2012 19:15:10 -0800 Subject: fifo ctrl: various tweaks --- firmware/zpu/lib/spi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'firmware/zpu/lib') diff --git a/firmware/zpu/lib/spi.c b/firmware/zpu/lib/spi.c index 190658d61..6f2f74899 100644 --- a/firmware/zpu/lib/spi.c +++ b/firmware/zpu/lib/spi.c @@ -42,11 +42,14 @@ uint32_t spi_transact(bool readback, int slave, uint32_t data, int length, uint3 if ((flags & SPI_LATCH_RISE) != 0) control_word |= (1 << SPI_CORE_DATA_IN_EDGE_SHIFT); if ((flags & SPI_LATCH_FALL) != 0) control_word |= (0 << SPI_CORE_DATA_IN_EDGE_SHIFT); + const uint32_t data_out = data << (32 - length); + spi_wait(); spi_core->control = control_word; - spi_core->data = (data << (32 - length)); + spi_core->data = data_out; - if (readback) spi_wait(); + if (!readback) return 0; + spi_wait(); return readback_mux->spi; } -- cgit v1.2.3