BurstSPI fork

Fork of BurstSPI by Erik -

Committer:
Backstrom
Date:
Fri Apr 03 06:14:57 2015 +0000
Revision:
14:c99022511536
Parent:
5:4437229b0738
As we set receive ignore flag we don't need any code in clearRX.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenno 5:4437229b0738 1 #ifdef TARGET_KL46Z
kenno 5:4437229b0738 2 #include "BurstSPI.h"
kenno 5:4437229b0738 3
kenno 5:4437229b0738 4 void BurstSPI::fastWrite(int data) {
kenno 5:4437229b0738 5 //Wait until FIFO has space
kenno 5:4437229b0738 6 while(((_spi.spi->S) & SPI_S_SPTEF_MASK) == 0);
kenno 5:4437229b0738 7 //transmit data
kenno 5:4437229b0738 8 _spi.spi->DL = data;
kenno 5:4437229b0738 9 }
kenno 5:4437229b0738 10
kenno 5:4437229b0738 11 void BurstSPI::clearRX( void ) {
kenno 5:4437229b0738 12 //We put in a delay here, this function shouldn't be called very often, so not a huge problem
kenno 5:4437229b0738 13 //Without delay you will rise the CS line before it is finished (been there, done that)
kenno 5:4437229b0738 14 //We use time required to transmit 20 bits (8 bits being transmitted, 8 bits in FIFO, 4 bits safety margin
kenno 5:4437229b0738 15
kenno 5:4437229b0738 16 float bytetime = 20.0/_hz;
kenno 5:4437229b0738 17 wait(bytetime);
kenno 5:4437229b0738 18
kenno 5:4437229b0738 19 //Wait until status is flagged that we can read, read:
kenno 5:4437229b0738 20 while (_spi.spi->S & SPI_S_SPRF_MASK == 0);
kenno 5:4437229b0738 21 int dummy = _spi.spi->DL;
kenno 5:4437229b0738 22
kenno 5:4437229b0738 23 }
kenno 5:4437229b0738 24 #endif