Browse Source

T4 SPI transfer16 implemented

Implemented using 16 bit writes
main
Kurt Eckhardt 5 years ago
parent
commit
fa6664b48b
1 changed files with 6 additions and 7 deletions
  1. +6
    -7
      SPI.h

+ 6
- 7
SPI.h View File

@@ -1179,13 +1179,12 @@ public:
//return port().POPR;
}
uint16_t transfer16(uint16_t data) {
uint16_t ret_val = transfer(data >> 8);
ret_val = (ret_val << 8) | transfer(data & 255);
//port().SR = SPI_SR_TCF;
//port().PUSHR = data | SPI_PUSHR_CTAS(1);
//while (!(port().SR & SPI_SR_TCF)) ; // wait
//return port().POPR;
return ret_val;
uint32_t tcr = port->TCR;
port->TCR = (tcr & 0xfffff000) | LPSPI_TCR_FRAMESZ(15); // turn on 16 bit mode
port->TDR = data; // output 16 bit data.
while ((port->RSR & LPSPI_RSR_RXEMPTY)) ; // wait while the RSR fifo is empty...
port->TCR = tcr; // restore back
return port->RDR;
}

void inline transfer(void *buf, size_t count) {transfer(buf, buf, count);}

Loading…
Cancel
Save