Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BurstSPI by
Diff: BurstSPI.cpp
- Revision:
- 0:600eecd89a78
diff -r 000000000000 -r 600eecd89a78 BurstSPI.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BurstSPI.cpp Thu Jan 03 09:14:10 2013 +0000 @@ -0,0 +1,28 @@ +#include "BurstSPI.h" + +BurstSPI::BurstSPI(PinName mosi, PinName miso, PinName sclk) : SPI(mosi, miso, sclk){ + +} + + +void BurstSPI::fastWrite(int data) { + //Wait until FIFO has space + while(((_spi.spi->SR) & 0x02) == 0); + + //transmit data + _spi.spi->DR = data; + } + +void BurstSPI::setFormat( void ) { + format(_bits, _mode); + frequency(_hz); + } + +void BurstSPI::clearRX( void ) { + //Do it while either data in RX buffer, or while it is busy + while(((_spi.spi->SR) & ((1<<4) + (1<<2))) != 0) { + //Wait until data in RX buffer + while(((_spi.spi->SR) & (1<<2)) == 0); + int dummy = _spi.spi->DR; + } +} \ No newline at end of file