Fork of BurstSPI with Nucleo F411RE support
Fork of BurstSPI by
Diff: BurstSPI_Nucleo_F411RE.cpp
- Revision:
- 11:9d43f61b3184
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BurstSPI_Nucleo_F411RE.cpp Fri Dec 05 06:35:12 2014 +0000 @@ -0,0 +1,27 @@ +/* + Only tested with a Ili9341 TFT on a Nucleo F411RE board. + -James Kidd +*/ + +/* BurstSPI_NUCLEO_F411RE.cpp */ +#ifdef TARGET_NUCLEO_F411RE +#include "BurstSPI.h" + +static SPI_HandleTypeDef SpiHandle; + +void BurstSPI::fastWrite(int data) { + SpiHandle.Instance = (SPI_TypeDef *)(_spi.spi); + while (!((__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_TXE) != RESET) ? 1 : 0)); + SpiHandle.Instance->DR =(uint16_t)data; + } + +void BurstSPI::clearRX( void ) { + SpiHandle.Instance = (SPI_TypeDef *)(_spi.spi); + //wait till SPI is not busy + while(__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_BSY) != RESET); + //Loop while data in RX, may not be needed + while(__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_RXNE) != RESET){ + int dummy = SpiHandle.Instance->DR; + } +} +#endif