Added support for STM32F103RB
Revision 14:8872ab64789c, committed 2020-04-24
- Comitter:
- peekpt
- Date:
- Fri Apr 24 11:09:03 2020 +0000
- Parent:
- 13:bc069279eb37
- Commit message:
- Added support for STM32F103RB
Changed in this revision
BurstSPI_STMF103RB.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BurstSPI_STMF103RB.cpp Fri Apr 24 11:09:03 2020 +0000 @@ -0,0 +1,25 @@ +#if defined(TARGET_STM32F103RB) +#include "BurstSPI.h" + +void BurstSPI::fastWrite(int data) +{ + SPI_TypeDef *spi = (SPI_TypeDef *)(_peripheral->spi.spi.handle.Instance); + // Check if data is transmitted + while ((spi->SR & SPI_SR_TXE) == 0); + spi->DR = data; +} + +void BurstSPI::clearRX(void) +{ + const SPI_TypeDef *spi = + (SPI_TypeDef *)(_peripheral->spi.spi.handle.Instance); + while (spi->SR & SPI_SR_BSY) { + // Check RX buffer readable + while ((spi->SR & SPI_SR_RXNE) == 0) + ; + int dummy = spi->DR; + (void)dummy; // suppress UNUSED warning + } +} + +#endif \ No newline at end of file