firmware/main: Fix SPI Xfer and always read the byte from HW
Without that the SPI_SR_RRDY bit isn't cleared for the next transfer. It uses to works simply because the PicoRV32 wasn't fast enough ... Signed-off-by: Sylvain Munaut <tnt@246tNt.com>master
parent
2188b231be
commit
5a98883e03
|
@ -68,6 +68,8 @@ spi_init(void)
|
|||
void
|
||||
spi_xfer(unsigned cs, struct spi_xfer_chunk *xfer, unsigned n)
|
||||
{
|
||||
uint8_t rxd;
|
||||
|
||||
/* Setup CS */
|
||||
spi_regs->csr = 0xf ^ (1 << cs);
|
||||
|
||||
|
@ -77,8 +79,9 @@ spi_xfer(unsigned cs, struct spi_xfer_chunk *xfer, unsigned n)
|
|||
{
|
||||
spi_regs->txdr = xfer->write ? xfer->data[i] : 0x00;
|
||||
while (!(spi_regs->sr & SPI_SR_RRDY));
|
||||
rxd = spi_regs->rxdr;
|
||||
if (xfer->read)
|
||||
xfer->data[i] = spi_regs->rxdr;
|
||||
xfer->data[i] = rxd;
|
||||
}
|
||||
xfer++;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue