Fast SPI write, added LPC812 Target
Fork of BurstSPI by
Revision 14:83e3b8ba3f43, committed 2016-10-09
- Comitter:
- JojoS
- Date:
- Sun Oct 09 16:48:17 2016 +0000
- Parent:
- 13:bc069279eb37
- Child:
- 15:8241b7d84ad2
- Commit message:
- added LPC8XX Target, added define for not setting EOT flag after transmission
Changed in this revision
--- a/BurstSPI.h Sat May 16 11:09:59 2015 +0000 +++ b/BurstSPI.h Sun Oct 09 16:48:17 2016 +0000 @@ -3,6 +3,11 @@ #include "mbed.h" +// this define is for compatibility of LPC15xx or LPC8xx SPI +// if not defined, the fastWrite() sets the EOT flag after transmission. Then the MOSI line is set high (or high Imp?) +// This is not the same behaviour as with older SPI hardware. +// For use in standard SPI this may be ok, for use as NRZ driver as in wsLib (driver for WS2812 LED) the EOT must not be set. +#define NO_EOT_AFTER_WRITE /** An SPI Master, used for communicating with SPI slave devices at very high speeds *
--- a/BurstSPI_LPC_1549.cpp Sat May 16 11:09:59 2015 +0000 +++ b/BurstSPI_LPC_1549.cpp Sun Oct 09 16:48:17 2016 +0000 @@ -1,4 +1,4 @@ -#if defined(TARGET_LPC1549) +#if (defined(TARGET_LPC1549)) #include "BurstSPI.h" void BurstSPI::fastWrite(int data) { @@ -6,7 +6,13 @@ _spi.spi->TXDAT = (data & 0xffff); // end of transfer and receive ignore flag +#ifndef NO_EOT_AFTER_WRITE + // set EOT and receive ignore flag _spi.spi->TXCTL |= ((1 << 20) | (1 << 22)); +#else + // set receive ignore flag + _spi.spi->TXCTL |= (1 << 22); +#endif } void BurstSPI::clearRX( void ) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BurstSPI_LPC_8XX.cpp Sun Oct 09 16:48:17 2016 +0000 @@ -0,0 +1,23 @@ +#if (defined(TARGET_LPC81X)) +#include "BurstSPI.h" + +void BurstSPI::fastWrite(int data) { + while (!(_spi.spi->STAT & (1 << 1))); + + _spi.spi->TXDAT = (data & 0xffff); +#ifndef NO_EOT_AFTER_WRITE + // set EOT and receive ignore flag + _spi.spi->TXDATCTL |= ((1 << 20) | (1 << 22)); +#else + // EOT Flag disables SPI and sets MOSI level high. + // This is bad for cases where MOSI is used to generate NRZ signals like in wsLib for WS2812 LED + // set receive ignore flag + _spi.spi->TXDATCTL |= (1 << 22); +#endif +} + +void BurstSPI::clearRX( void ) { + //We already set receive ignore flag, so this function is never run. +} + +#endif \ No newline at end of file
--- a/BurstSPI_LPC_X.cpp Sat May 16 11:09:59 2015 +0000 +++ b/BurstSPI_LPC_X.cpp Sun Oct 09 16:48:17 2016 +0000 @@ -1,4 +1,4 @@ -#if defined(TARGET_LPC1768) || defined(TARGET_LPC1114) || defined(TARGET_LPC11U24) || defined(TARGET_LPC13XX) +#if (defined(TARGET_LPC1768) || defined(TARGET_LPC1114) || defined(TARGET_LPC11U24) || defined(TARGET_LPC13XX)) #include "BurstSPI.h" void BurstSPI::fastWrite(int data) {
--- a/BurstSPI_Unsupported.cpp Sat May 16 11:09:59 2015 +0000 +++ b/BurstSPI_Unsupported.cpp Sun Oct 09 16:48:17 2016 +0000 @@ -1,5 +1,5 @@ #if !(defined(TARGET_KL25Z) || defined(TARGET_KL46Z)) -#if !(defined(TARGET_LPC1768) || defined(TARGET_LPC1114) || defined(TARGET_LPC11U24) || defined(TARGET_LPC13XX) || defined(TARGET_LPC1549)) +#if !(defined(TARGET_LPC1768) || defined(TARGET_LPC1114) || defined(TARGET_LPC11U24) || defined(TARGET_LPC13XX) || defined(TARGET_LPC1549) || defined(TARGET_LPC81X)) #if !(defined(TARGET_NUCLEO_L152RE) || defined(TARGET_STM32F4)) #warning BurstSPI target not supported, reverting to regular SPI