x

Fork of BurstSPI by Erik Olieman

Committer:
JackB
Date:
Mon Jul 23 12:23:44 2018 +0000
Revision:
14:35df38577abd
Parent:
13:bc069279eb37
BSPI

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Alamalione 4:8585ddebd28b 1 /* BurstSPI_NUCLEO_L152RE.cpp */
Alamalione 4:8585ddebd28b 2 #ifdef TARGET_NUCLEO_L152RE
Alamalione 4:8585ddebd28b 3 #include "BurstSPI.h"
Alamalione 4:8585ddebd28b 4
Alamalione 4:8585ddebd28b 5 void BurstSPI::fastWrite(int data) {
Alamalione 4:8585ddebd28b 6
Alamalione 4:8585ddebd28b 7 SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi);
Alamalione 4:8585ddebd28b 8 // Check if data is transmitted
Alamalione 4:8585ddebd28b 9 while (!((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_TXE) != RESET) ? 1 : 0));
Alamalione 4:8585ddebd28b 10 SPI_I2S_SendData(spi, (uint16_t)data);
Alamalione 4:8585ddebd28b 11 }
Alamalione 4:8585ddebd28b 12
Alamalione 4:8585ddebd28b 13 void BurstSPI::clearRX( void ) {
Alamalione 4:8585ddebd28b 14 int status;
Alamalione 4:8585ddebd28b 15 //Check if the RX buffer is busy
Alamalione 4:8585ddebd28b 16 SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi);
Alamalione 4:8585ddebd28b 17 status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_BSY) != RESET) ? 1 : 0);
Alamalione 4:8585ddebd28b 18 if (status){
Alamalione 4:8585ddebd28b 19 // Check RX buffer readable
Alamalione 4:8585ddebd28b 20 while (!((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_RXNE) != RESET) ? 1 : 0));
Alamalione 4:8585ddebd28b 21 int dummy = (int)SPI_I2S_ReceiveData(spi);
Alamalione 4:8585ddebd28b 22 }
Alamalione 4:8585ddebd28b 23 }
Alamalione 4:8585ddebd28b 24 #endif
Alamalione 4:8585ddebd28b 25