spi: properly exchange bytes by sending and reading each byte within a SPI transaction
This commit is contained in:
parent
e7ad03608a
commit
85a3f84d61
1 changed files with 3 additions and 1 deletions
|
@ -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…
Add table
Reference in a new issue