spi: properly exchange bytes by sending and reading each byte within a SPI transaction

tags/0.1.0
S.J.R. van Schaik 8 years ago
parent e7ad03608a
commit 85a3f84d61
  1. 4
      source/drivers/stm32f0_spi.c

@ -75,11 +75,13 @@ static int stm32f0_spi_tx_rx(struct spi_dev *dev, void *rx_buf, size_t rx_len,
gpio_clear(GPIOA, GPIO4);
for (i = 0; i < tx_len; ++i) {
spi_send8(dev->dev_id, tx ? *tx++ : 0);
spi_send8(dev->dev_id, *tx++);
(void)spi_read8(dev->dev_id);
}
if (rx_buf) {
for (i = 0; i < rx_len; ++i) {
spi_send8(dev->dev_id, 0);
*rx++ = spi_read8(dev->dev_id);
}
}

Loading…
Cancel
Save