Fork of BurstSPI with Nucleo F411RE support
Fork of BurstSPI by
BurstSPI_Nucleo_F411RE.cpp@11:9d43f61b3184, 2014-12-05 (annotated)
- Committer:
- infotech1
- Date:
- Fri Dec 05 06:35:12 2014 +0000
- Revision:
- 11:9d43f61b3184
Added F411RE support
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
infotech1 | 11:9d43f61b3184 | 1 | /* |
infotech1 | 11:9d43f61b3184 | 2 | Only tested with a Ili9341 TFT on a Nucleo F411RE board. |
infotech1 | 11:9d43f61b3184 | 3 | -James Kidd |
infotech1 | 11:9d43f61b3184 | 4 | */ |
infotech1 | 11:9d43f61b3184 | 5 | |
infotech1 | 11:9d43f61b3184 | 6 | /* BurstSPI_NUCLEO_F411RE.cpp */ |
infotech1 | 11:9d43f61b3184 | 7 | #ifdef TARGET_NUCLEO_F411RE |
infotech1 | 11:9d43f61b3184 | 8 | #include "BurstSPI.h" |
infotech1 | 11:9d43f61b3184 | 9 | |
infotech1 | 11:9d43f61b3184 | 10 | static SPI_HandleTypeDef SpiHandle; |
infotech1 | 11:9d43f61b3184 | 11 | |
infotech1 | 11:9d43f61b3184 | 12 | void BurstSPI::fastWrite(int data) { |
infotech1 | 11:9d43f61b3184 | 13 | SpiHandle.Instance = (SPI_TypeDef *)(_spi.spi); |
infotech1 | 11:9d43f61b3184 | 14 | while (!((__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_TXE) != RESET) ? 1 : 0)); |
infotech1 | 11:9d43f61b3184 | 15 | SpiHandle.Instance->DR =(uint16_t)data; |
infotech1 | 11:9d43f61b3184 | 16 | } |
infotech1 | 11:9d43f61b3184 | 17 | |
infotech1 | 11:9d43f61b3184 | 18 | void BurstSPI::clearRX( void ) { |
infotech1 | 11:9d43f61b3184 | 19 | SpiHandle.Instance = (SPI_TypeDef *)(_spi.spi); |
infotech1 | 11:9d43f61b3184 | 20 | //wait till SPI is not busy |
infotech1 | 11:9d43f61b3184 | 21 | while(__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_BSY) != RESET); |
infotech1 | 11:9d43f61b3184 | 22 | //Loop while data in RX, may not be needed |
infotech1 | 11:9d43f61b3184 | 23 | while(__HAL_SPI_GET_FLAG(&SpiHandle, SPI_FLAG_RXNE) != RESET){ |
infotech1 | 11:9d43f61b3184 | 24 | int dummy = SpiHandle.Instance->DR; |
infotech1 | 11:9d43f61b3184 | 25 | } |
infotech1 | 11:9d43f61b3184 | 26 | } |
infotech1 | 11:9d43f61b3184 | 27 | #endif |