sam3x8e: Read from the SPI_RDR on SPI send even if no data needed
Be sure to read the SPI_RDR as that clears the RDRF flag. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
7e9ee6aef7
commit
1eb416002b
|
@ -4,13 +4,10 @@
|
||||||
//
|
//
|
||||||
// This file may be distributed under the terms of the GNU GPLv3 license.
|
// This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
|
|
||||||
#include <stddef.h> // NULL
|
#include <sam3x8e.h> // REGPTR
|
||||||
#include "autoconf.h"
|
|
||||||
#include "command.h" // shutdown
|
#include "command.h" // shutdown
|
||||||
#include "gpio.h"
|
#include "gpio.h" // gpio_peripheral
|
||||||
#include "sched.h"
|
#include "sched.h" // sched_shutdown
|
||||||
#include <sam3x8e.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define REGPTR SPI0
|
#define REGPTR SPI0
|
||||||
#define PERIPH_ID ID_SPI0
|
#define PERIPH_ID ID_SPI0
|
||||||
|
@ -109,7 +106,8 @@ spi_transfer(struct spi_config config, uint8_t receive_data
|
||||||
while (len--) {
|
while (len--) {
|
||||||
pSpi->SPI_TDR = *data;
|
pSpi->SPI_TDR = *data;
|
||||||
// wait for receive register
|
// wait for receive register
|
||||||
while (!(pSpi->SPI_SR & SPI_SR_RDRF)) { asm volatile("nop"); };
|
while (!(pSpi->SPI_SR & SPI_SR_RDRF))
|
||||||
|
;
|
||||||
// get data
|
// get data
|
||||||
*data++ = pSpi->SPI_RDR;
|
*data++ = pSpi->SPI_RDR;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +115,10 @@ spi_transfer(struct spi_config config, uint8_t receive_data
|
||||||
while (len--) {
|
while (len--) {
|
||||||
pSpi->SPI_TDR = *data++;
|
pSpi->SPI_TDR = *data++;
|
||||||
// wait for receive register
|
// wait for receive register
|
||||||
while (!(pSpi->SPI_SR & SPI_SR_RDRF)) { asm volatile("nop"); };
|
while (!(pSpi->SPI_SR & SPI_SR_RDRF))
|
||||||
|
;
|
||||||
|
// read data (to clear RDRF)
|
||||||
|
pSpi->SPI_RDR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue