Add support for KL46Z

Fork of BurstSPI by Erik -

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BurstSPI_NUCLEO_L152RE.cpp Source File

BurstSPI_NUCLEO_L152RE.cpp

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