Just a fork with fix for newer mbed versions
BurstSPI_STM32F4.cpp@15:5809125b8dac, 2021-04-18 (annotated)
- Committer:
- reneg973
- Date:
- Sun Apr 18 21:31:53 2021 +0000
- Revision:
- 15:5809125b8dac
- Parent:
- 14:98658a80a698
fixed LPC_1768 compiler issue and transfer problems; ; Performance:; loop SPI.write() => 138.1 ms for updating a display; loop BurstSPI.fastWrite() => 22.4 ms;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Sissors | 13:bc069279eb37 | 1 | #if defined(TARGET_STM32F4) |
Sissors | 13:bc069279eb37 | 2 | #include "BurstSPI.h" |
Sissors | 13:bc069279eb37 | 3 | |
Sissors | 13:bc069279eb37 | 4 | void BurstSPI::fastWrite(int data) { |
Sissors | 13:bc069279eb37 | 5 | |
EricWieser | 14:98658a80a698 | 6 | SPI_TypeDef *spi = _spi.spi.handle.Instance; |
Sissors | 13:bc069279eb37 | 7 | // Check if data is transmitted |
Sissors | 13:bc069279eb37 | 8 | while ((spi->SR & SPI_SR_TXE) == 0); |
Sissors | 13:bc069279eb37 | 9 | spi->DR = data; |
Sissors | 13:bc069279eb37 | 10 | } |
Sissors | 13:bc069279eb37 | 11 | |
Sissors | 13:bc069279eb37 | 12 | void BurstSPI::clearRX( void ) { |
Sissors | 13:bc069279eb37 | 13 | //Check if the RX buffer is busy |
EricWieser | 14:98658a80a698 | 14 | SPI_TypeDef *spi = _spi.spi.handle.Instance; |
Sissors | 13:bc069279eb37 | 15 | //While busy, keep checking |
Sissors | 13:bc069279eb37 | 16 | while (spi->SR & SPI_SR_BSY){ |
Sissors | 13:bc069279eb37 | 17 | // Check RX buffer readable |
Sissors | 13:bc069279eb37 | 18 | while ((spi->SR & SPI_SR_RXNE) == 0); |
Sissors | 13:bc069279eb37 | 19 | int dummy = spi->DR; |
Sissors | 13:bc069279eb37 | 20 | } |
Sissors | 13:bc069279eb37 | 21 | } |
Sissors | 13:bc069279eb37 | 22 | #endif |
Sissors | 13:bc069279eb37 | 23 |