This is another Arduino SPI library separated from SdFat library, it uses SPI registers and DMA (Arduino Due only) to accelerate SPI communication.
Thanks to Bill Greiman
I have test this library on Arduino Uno/Mega2560/Due, maybe support other AVR/SAM3X MCUs. You can search keywords like "Arduino Mega2560 pinout" to find pinout mapping with your board like this:
SCK to SCK, MISO to MISO, MOSI to MOSI, Reset to Reset,
CS to CS, and other pins.
#include <TurboSPI.h>
TurboSPI g_SPI;
DigitalPin g_PinCS, g_PinRS;
uint8_t g_Buffer[256]; // some data buffer to transfer
uint8_t g_Divisor = 2; // transfer speed set to MCU's clock divide by 2
void setup()
{
// setup pins
g_PinCS.Begin(pinCS);
g_PinRS.Begin(pinRS);
g_PinCS.PinMode(OUTPUT);
g_PinRS.PinMode(OUTPUT);
// setup SPI
g_SPI.Begin();
}
void loop()
{
// setup speed and select slave
g_SPI.Init(g_Divisor);
g_PinCS.Low();
// set some pins
g_PinRS.High();
// transfer data to slave
g_SPI.Send(g_Buffer, sizeof(g_Buffer));
// unselect slave
g_PinCS.High();
}