x

Fork of BurstSPI by Erik Olieman

Committer:
JackB
Date:
Mon Jul 23 12:23:44 2018 +0000
Revision:
14:35df38577abd
Parent:
5:4437229b0738
BSPI

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