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_LPC_X.cpp Source File

BurstSPI_LPC_X.cpp

00001 #if defined(TARGET_LPC1768) || defined(TARGET_LPC1114) || defined(TARGET_LPC11U24) || defined(TARGET_LPC13XX)
00002 #include "BurstSPI.h"
00003 
00004 void BurstSPI::fastWrite(int data) {
00005     //Wait until FIFO has space
00006     while(((_spi.spi->SR) & 0x02) == 0);
00007     
00008     //transmit data
00009     _spi.spi->DR = data;
00010     }
00011 
00012 void BurstSPI::clearRX( void ) {
00013     //Do it while either data in RX buffer, or while it is busy
00014     while(((_spi.spi->SR) & ((1<<4) + (1<<2))) != 0) {
00015         //Wait until data in RX buffer
00016         while(((_spi.spi->SR) & (1<<2)) == 0);
00017         int dummy = _spi.spi->DR;
00018         }
00019 }
00020 #endif