Add support for KL46Z
Fork of BurstSPI by
BurstSPI_NUCLEO_L152RE.cpp@6:b862ffb6c5e2, 2014-07-25 (annotated)
- Committer:
- kenno
- Date:
- Fri Jul 25 15:09:45 2014 +0000
- Revision:
- 6:b862ffb6c5e2
- Parent:
- 4:8585ddebd28b
Merge with version 2.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Alamalione | 4:8585ddebd28b | 1 | |
Alamalione | 4:8585ddebd28b | 2 | |
Alamalione | 4:8585ddebd28b | 3 | /* BurstSPI_NUCLEO_L152RE.cpp */ |
Alamalione | 4:8585ddebd28b | 4 | #ifdef TARGET_NUCLEO_L152RE |
Alamalione | 4:8585ddebd28b | 5 | #include "BurstSPI.h" |
Alamalione | 4:8585ddebd28b | 6 | |
Alamalione | 4:8585ddebd28b | 7 | void BurstSPI::fastWrite(int data) { |
Alamalione | 4:8585ddebd28b | 8 | |
Alamalione | 4:8585ddebd28b | 9 | SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi); |
Alamalione | 4:8585ddebd28b | 10 | // Check if data is transmitted |
Alamalione | 4:8585ddebd28b | 11 | while (!((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_TXE) != RESET) ? 1 : 0)); |
Alamalione | 4:8585ddebd28b | 12 | SPI_I2S_SendData(spi, (uint16_t)data); |
Alamalione | 4:8585ddebd28b | 13 | } |
Alamalione | 4:8585ddebd28b | 14 | |
Alamalione | 4:8585ddebd28b | 15 | void BurstSPI::clearRX( void ) { |
Alamalione | 4:8585ddebd28b | 16 | int status; |
Alamalione | 4:8585ddebd28b | 17 | //Check if the RX buffer is busy |
Alamalione | 4:8585ddebd28b | 18 | SPI_TypeDef *spi = (SPI_TypeDef *)(_spi.spi); |
Alamalione | 4:8585ddebd28b | 19 | status = ((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_BSY) != RESET) ? 1 : 0); |
Alamalione | 4:8585ddebd28b | 20 | if (status){ |
Alamalione | 4:8585ddebd28b | 21 | // Check RX buffer readable |
Alamalione | 4:8585ddebd28b | 22 | while (!((SPI_I2S_GetFlagStatus(spi, SPI_I2S_FLAG_RXNE) != RESET) ? 1 : 0)); |
Alamalione | 4:8585ddebd28b | 23 | int dummy = (int)SPI_I2S_ReceiveData(spi); |
Alamalione | 4:8585ddebd28b | 24 | } |
Alamalione | 4:8585ddebd28b | 25 | } |
Alamalione | 4:8585ddebd28b | 26 | #endif |
Alamalione | 4:8585ddebd28b | 27 |