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

BurstSPI_NUCLEO_L152RE.cpp

00001 /* BurstSPI_NUCLEO_L152RE.cpp */
00002 #ifdef TARGET_NUCLEO_L152RE
00003 #include "BurstSPI.h"
00004  
00005 void BurstSPI::fastWrite(int data) {
00006     
00007     SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi);
00008     // Check if data is transmitted
00009     while (!((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_TXE) != RESET) ? 1 : 0));
00010     SPI_I2S_SendData(spi, (uint16_t)data);
00011     }
00012     
00013 void BurstSPI::clearRX( void ) {
00014     int status;
00015     //Check if the RX buffer is busy
00016     SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi);
00017     status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_BSY) != RESET) ? 1 : 0);
00018     if (status){   
00019         // Check RX buffer readable
00020         while (!((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_RXNE) != RESET) ? 1 : 0));
00021         int dummy = (int)SPI_I2S_ReceiveData(spi);
00022     }
00023 }
00024 #endif
00025