je ne sais plus

Committer:
FreeControl
Date:
Wed Jun 17 13:49:54 2015 +0000
Revision:
0:3787bbf77ca8
je ne sais plus

Who changed what in which revision?

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