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


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
for (int i = 0; i<1000; i++)

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.

Sat May 16 11:09:59 2015 +0000
Added STM F4XX support.
; (And seriously STM, it has the same SPI as the already supported L152, but you just had to go ahead and change all your driver files)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Backstrom 11:36ac5fd058dd 1 #if defined(TARGET_LPC1549)
Backstrom 11:36ac5fd058dd 2 #include "BurstSPI.h"
Backstrom 11:36ac5fd058dd 3
Backstrom 11:36ac5fd058dd 4 void BurstSPI::fastWrite(int data) {
Backstrom 11:36ac5fd058dd 5 while (!(_spi.spi->STAT & (1 << 1)));
Backstrom 11:36ac5fd058dd 6
Backstrom 11:36ac5fd058dd 7 _spi.spi->TXDAT = (data & 0xffff);
Backstrom 12:c99022511536 8 // end of transfer and receive ignore flag
Backstrom 11:36ac5fd058dd 9 _spi.spi->TXCTL |= ((1 << 20) | (1 << 22));
Backstrom 11:36ac5fd058dd 10 }
Backstrom 11:36ac5fd058dd 11
Backstrom 11:36ac5fd058dd 12 void BurstSPI::clearRX( void ) {
Backstrom 12:c99022511536 13 //We already set receive ignore flag, so this function is never run.
Backstrom 11:36ac5fd058dd 14 }
Backstrom 11:36ac5fd058dd 15
Backstrom 11:36ac5fd058dd 16 #endif