Class to be able to send SPI data with almost no overhead, useful at very high speeds.

Dependents:   MakerBotServer epaper_mbed_130411_KL25Z epaper_mbed_test epaper_mbed_test_copy1 ... more

General

BurstSPI sends SPI data without reading it back, allowing higher speeds than the regular SPI library. This is mainly useful at high frequencies and large payloads. With a small number of bytes the setting up and finishing time will remove any advantage.

The three new functions compared to regular SPI are: fastWrite, setFormat and clearRX.

fastWrite is the function to quickly write data. setFormat is only required if the SPI format might have changed, or the first time you fastWrite something and you haven't used a regular SPI write before. clearRX is required if you also want to be able read from the SPI peripheral later on.

//Send 1000 SPI packets as fast as possible
spi.setFormat();
for (int i = 0; i<1000; i++)
    spi.fastWrite(data[i]);
spi.clearRX();

Supported targets

  • KL25Z, KL46Z
  • LPC1768, LPC11u24, LPC1114, LPC1549, LPC1347
  • STML152RE

If a target is not supported the library will issue a warning, and use regular writes. This means if you for example use this library to speed up writing to an LCD display, your LCD display library will work on all targets, and if possible BurstSPI will speed up the process.

Committer:
Backstrom
Date:
Fri Apr 03 06:02:58 2015 +0000
Revision:
11:36ac5fd058dd
Parent:
10:6ed1d9f1ef37
Child:
13:bc069279eb37
Add LPC1549 target support.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Sissors 10:6ed1d9f1ef37 1 #if !(defined(TARGET_KL25Z) || defined(TARGET_KL46Z))
Backstrom 11:36ac5fd058dd 2 #if !(defined(TARGET_LPC1768) || defined(TARGET_LPC1114) || defined(TARGET_LPC11U24) || defined(TARGET_LPC13XX) || defined(TARGET_LPC1549))
Sissors 10:6ed1d9f1ef37 3 #if !(defined(TARGET_NUCLEO_L152RE))
Sissors 10:6ed1d9f1ef37 4
Sissors 10:6ed1d9f1ef37 5 #warning BurstSPI target not supported, reverting to regular SPI
Sissors 10:6ed1d9f1ef37 6
Sissors 10:6ed1d9f1ef37 7 #include "BurstSPI.h"
Sissors 10:6ed1d9f1ef37 8
Sissors 10:6ed1d9f1ef37 9 void BurstSPI::fastWrite(int data) {
Sissors 10:6ed1d9f1ef37 10 write(data);
Sissors 10:6ed1d9f1ef37 11 }
Sissors 10:6ed1d9f1ef37 12
Sissors 10:6ed1d9f1ef37 13 void BurstSPI::clearRX( void ) {
Sissors 10:6ed1d9f1ef37 14
Sissors 10:6ed1d9f1ef37 15 }
Sissors 10:6ed1d9f1ef37 16 #endif //Freescale
Sissors 10:6ed1d9f1ef37 17 #endif //NXP
Sissors 10:6ed1d9f1ef37 18 #endif //NUCLEO