Added SPI burst mode to spi 8 bit.
Dependents: Bicycl_Computer_NUCLEO-F411RE Bicycl_Computer_NUCLEO-L476RG
Fork of UniGraphic by
Added SPI burst mode to this graphics driver. If whoever wants this rolled in to repository let me know. I replaced _spi.write(); with fastWrite(); and clearRX();
SPI8.cpp
// need to re-create SPI firmware to access SPI handle static SPI_HandleTypeDef SpiHandle; void SPI8::fastWrite(int data) { SpiHandle.Instance = SPI1; // Check if data is transmitted while ((SpiHandle.Instance->SR & SPI_SR_TXE) == 0); SpiHandle.Instance->DR = data; } void SPI8::clearRX( void ) { SpiHandle.Instance = SPI1; //Check if the RX buffer is busy //While busy, keep checking while (SpiHandle.Instance->SR & SPI_SR_BSY){ // Check RX buffer readable while ((SpiHandle.Instance->SR & SPI_SR_RXNE) == 0); int dummy = SpiHandle.Instance->DR; } }
Revision 34:7eea44b19734, committed 2017-04-28
- Comitter:
- trevieze
- Date:
- Fri Apr 28 01:45:26 2017 +0000
- Parent:
- 33:e3b3181a57e2
- Child:
- 35:782de649ef6f
- Child:
- 36:0ced7cf0ec8c
- Commit message:
- Burst for 8 bit spi.
Changed in this revision
Protocols/SPI8.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Protocols/SPI8.cpp Wed Apr 12 20:18:25 2017 +0000 +++ b/Protocols/SPI8.cpp Fri Apr 28 01:45:26 2017 +0000 @@ -111,9 +111,11 @@ count<<=1; while(count) { - _spi.write(data); // write 8bit + //_spi.write(data); // write 8bit + fastWrite(data); count--; } + clearRX(); } else { @@ -121,11 +123,11 @@ { //_spi.write(data>>8); // write 8bit //_spi.write(data&0xFF); // write 8bit - fastWrite(data>>8); - fastWrite(data&0xFF); + fastWrite(data>>8); + fastWrite(data&0xFF); count--; } - clearRX(); + clearRX(); } #ifdef USE_CS _CS = 1; @@ -141,12 +143,12 @@ { //_spi.write((*data)>>8); // write 8bit //_spi.write((*data)&0xFF); // write 8bit - fastWrite(*data>>8); - fastWrite(*data&0xFF); + fastWrite(*data>>8); + fastWrite(*data&0xFF); data++; lenght--; } - clearRX(); + clearRX(); #ifdef USE_CS _CS = 1; #endif