Created
March 23, 2016 13:47
-
-
Save macaba/b753612db3b5b1b975b8 to your computer and use it in GitHub Desktop.
DMASPI Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SPI.h> | |
#include <DmaSpi.h> | |
uint16_t buffer[128][128]; | |
#define DMASIZE 16384 | |
DmaSpi::Transfer trxA(nullptr, 0, nullptr); | |
DmaSpi::Transfer trxB(nullptr, 0, nullptr); | |
uint32_t transferCount = 0; | |
void setup() { | |
delay(4000); | |
waitForKeyPress(); | |
SPISettings spiSettings; | |
SPI.begin(); | |
DMASPI0.begin(); | |
DMASPI0.start(); | |
} | |
void loop() { | |
//if(!anyTransferBusy()){ //This was a test to see if checking the transfer busy flag would help | |
if(!DMASPI0.busy()){ | |
Serial.print("Starting transfer "); | |
Serial.println(transferCount++); | |
transfer(); | |
} | |
} | |
/** Wait for and consume a keypress over USB **/ | |
void waitForKeyPress() | |
{ | |
Serial.println("\nPress a key to continue\n"); | |
while(!Serial.available()); | |
while(Serial.available()) | |
{ | |
Serial.read(); | |
} | |
} | |
void transfer(){ | |
ActiveLowChipSelect cs(0, SPISettings()); | |
//trxA = DmaSpi::Transfer((uint8_t*)buffer, DMASIZE, nullptr); //This config works | |
//trxB = DmaSpi::Transfer((uint8_t*)buffer + DMASIZE, DMASIZE, nullptr); //This config works | |
trxA = DmaSpi::Transfer((uint8_t*)buffer, DMASIZE, nullptr, 0, &cs); | |
trxB = DmaSpi::Transfer((uint8_t*)buffer + DMASIZE, DMASIZE, nullptr, 0, &cs); | |
DMASPI0.registerTransfer(trxA); | |
DMASPI0.registerTransfer(trxB); | |
} | |
bool anyTransferBusy(){ | |
return trxA.busy() || trxB.busy(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment