Lib BurstSPI give access to fastWrite function and clearRX function, this lib is now compatible with Nucleo L152RE board
Fork of BurstSPI by
BurstSPI_NUCLEO_F030R8.cpp@5:c9c9ef0a40b9, 2014-06-25 (annotated)
- Committer:
- Alamalione
- Date:
- Wed Jun 25 14:11:39 2014 +0000
- Revision:
- 5:c9c9ef0a40b9
Add Nucleo F030R8.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Alamalione | 5:c9c9ef0a40b9 | 1 | |
Alamalione | 5:c9c9ef0a40b9 | 2 | |
Alamalione | 5:c9c9ef0a40b9 | 3 | /* BurstSPI_NUCLEO_F030R8.cpp */ |
Alamalione | 5:c9c9ef0a40b9 | 4 | #ifdef TARGET_NUCLEO_F030R8 |
Alamalione | 5:c9c9ef0a40b9 | 5 | #include "BurstSPI.h" |
Alamalione | 5:c9c9ef0a40b9 | 6 | |
Alamalione | 5:c9c9ef0a40b9 | 7 | void BurstSPI::fastWrite(int data) { |
Alamalione | 5:c9c9ef0a40b9 | 8 | |
Alamalione | 5:c9c9ef0a40b9 | 9 | SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi); |
Alamalione | 5:c9c9ef0a40b9 | 10 | // Check if data is transmitted |
Alamalione | 5:c9c9ef0a40b9 | 11 | while (!((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_TXE) != RESET) ? 1 : 0)); |
Alamalione | 5:c9c9ef0a40b9 | 12 | SPI_I2S_SendData16(spi, (uint16_t)data); |
Alamalione | 5:c9c9ef0a40b9 | 13 | } |
Alamalione | 5:c9c9ef0a40b9 | 14 | |
Alamalione | 5:c9c9ef0a40b9 | 15 | void BurstSPI::clearRX( void ) { |
Alamalione | 5:c9c9ef0a40b9 | 16 | int status; |
Alamalione | 5:c9c9ef0a40b9 | 17 | //Check if the RX buffer is busy |
Alamalione | 5:c9c9ef0a40b9 | 18 | SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi); |
Alamalione | 5:c9c9ef0a40b9 | 19 | status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_BSY) != RESET) ? 1 : 0); |
Alamalione | 5:c9c9ef0a40b9 | 20 | if (status){ |
Alamalione | 5:c9c9ef0a40b9 | 21 | // Check RX buffer readable |
Alamalione | 5:c9c9ef0a40b9 | 22 | while (!((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_RXNE) != RESET) ? 1 : 0)); |
Alamalione | 5:c9c9ef0a40b9 | 23 | int dummy = (int)SPI_I2S_ReceiveData16(spi); |
Alamalione | 5:c9c9ef0a40b9 | 24 | } |
Alamalione | 5:c9c9ef0a40b9 | 25 | } |
Alamalione | 5:c9c9ef0a40b9 | 26 | #endif |
Alamalione | 5:c9c9ef0a40b9 | 27 |