This is SPI library using DMA buffer for Teensy, inspired by @crteensy 's DmaSpi and its @KurtE 's fork for Teensy 4.0.
- support DMA buffer (more than 64 byte transfer is available)
- Master has two ways to send/receive transactions
transfer()
to send/receive transaction one by onequeue()
andyield()
to send/receive multiple transactions at once
This library currently supports only Teensy 4.0.
#include <TsyDMASPI.h>
#define PIN_CS 10
#define DMASIZE 8192
uint8_t src[DMASIZE];
volatile uint8_t dest[DMASIZE];
volatile uint8_t dest1[DMASIZE];
void setup() {
TsyDMASPI0.begin(PIN_CS, SPISettings(4000000, MSBFIRST, SPI_MODE3));
// one by one transaction
TsyDMASPI0.transfer(src, dest, DMASIZE);
// multiple transaction at once
TsyDMASPI0.queue(src, dest, DMASIZE);
TsyDMASPI0.queue(src, dest1, DMASIZE);
TsyDMASPI0.yield();
}
// SPI with DMA on SPI0
TsyDMASPI0.begin(PIN_CS, SPISettings(4000000, MSBFIRST, SPI_MODE3));
TsyDMASPI0.transfer(tx_buf, rx_buf, DMASIZE);
// SPI with DMA on SPI0
TsyDMASPI0.begin(PIN_CS, SPISettings(4000000, MSBFIRST, SPI_MODE3));
TsyDMASPI0.queue(tx_buf0, rx_buf0, DMASIZE);
TsyDMASPI0.queue(tx_buf1, rx_buf1, DMASIZE);
TsyDMASPI0.yield(); // wait until all transactions will be done
- Teensy LC, 3.2, 3.5, 3.6 implementation
- Slave mode with DMA for example like this thread
MIT