Just a fork with fix for newer mbed versions
BurstSPI_KL46Z.cpp@15:5809125b8dac, 2021-04-18 (annotated)
- Committer:
- reneg973
- Date:
- Sun Apr 18 21:31:53 2021 +0000
- Revision:
- 15:5809125b8dac
- Parent:
- 5:4437229b0738
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 |
---|---|---|---|
kenno | 5:4437229b0738 | 1 | #ifdef TARGET_KL46Z |
kenno | 5:4437229b0738 | 2 | #include "BurstSPI.h" |
kenno | 5:4437229b0738 | 3 | |
kenno | 5:4437229b0738 | 4 | void BurstSPI::fastWrite(int data) { |
kenno | 5:4437229b0738 | 5 | //Wait until FIFO has space |
kenno | 5:4437229b0738 | 6 | while(((_spi.spi->S) & SPI_S_SPTEF_MASK) == 0); |
kenno | 5:4437229b0738 | 7 | //transmit data |
kenno | 5:4437229b0738 | 8 | _spi.spi->DL = data; |
kenno | 5:4437229b0738 | 9 | } |
kenno | 5:4437229b0738 | 10 | |
kenno | 5:4437229b0738 | 11 | void BurstSPI::clearRX( void ) { |
kenno | 5:4437229b0738 | 12 | //We put in a delay here, this function shouldn't be called very often, so not a huge problem |
kenno | 5:4437229b0738 | 13 | //Without delay you will rise the CS line before it is finished (been there, done that) |
kenno | 5:4437229b0738 | 14 | //We use time required to transmit 20 bits (8 bits being transmitted, 8 bits in FIFO, 4 bits safety margin |
kenno | 5:4437229b0738 | 15 | |
kenno | 5:4437229b0738 | 16 | float bytetime = 20.0/_hz; |
kenno | 5:4437229b0738 | 17 | wait(bytetime); |
kenno | 5:4437229b0738 | 18 | |
kenno | 5:4437229b0738 | 19 | //Wait until status is flagged that we can read, read: |
kenno | 5:4437229b0738 | 20 | while (_spi.spi->S & SPI_S_SPRF_MASK == 0); |
kenno | 5:4437229b0738 | 21 | int dummy = _spi.spi->DL; |
kenno | 5:4437229b0738 | 22 | |
kenno | 5:4437229b0738 | 23 | } |
kenno | 5:4437229b0738 | 24 | #endif |