Class to be able to send SPI data with almost no overhead, useful at very high speeds.

Dependents:   MakerBotServer epaper_mbed_130411_KL25Z epaper_mbed_test epaper_mbed_test_copy1 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BurstSPI_KL46Z.cpp Source File

BurstSPI_KL46Z.cpp

00001 #ifdef TARGET_KL46Z
00002 #include "BurstSPI.h"
00003 
00004 void BurstSPI::fastWrite(int data) {
00005     //Wait until FIFO has space
00006     while(((_spi.spi->S) & SPI_S_SPTEF_MASK) == 0);
00007     //transmit data
00008     _spi.spi->DL = data;
00009     }
00010 
00011 void BurstSPI::clearRX( void ) {
00012     //We put in a delay here, this function shouldn't be called very often, so not a huge problem
00013     //Without delay you will rise the CS line before it is finished (been there, done that)
00014     //We use time required to transmit 20 bits (8 bits being transmitted, 8 bits in FIFO, 4 bits safety margin
00015     
00016     float bytetime = 20.0/_hz;
00017     wait(bytetime);    
00018     
00019     //Wait until status is flagged that we can read, read:
00020     while (_spi.spi->S & SPI_S_SPRF_MASK == 0);
00021     int dummy = _spi.spi->DL;
00022 
00023 }
00024 #endif