From 3c7a2d5bad1f06fe5e7b33906b967b3617fd50c5 Mon Sep 17 00:00:00 2001 From: Rudolph Riedel Date: Mon, 28 Dec 2020 13:51:55 +0100 Subject: [PATCH] Added a isBusy() method to SPI calls to allow non-blocking polling of the DMA transfer status. --- libraries/SPI/SPI.cpp | 6 ++++++ libraries/SPI/SPI.h | 1 + 2 files changed, 7 insertions(+) diff --git a/libraries/SPI/SPI.cpp b/libraries/SPI/SPI.cpp index 2b6b8321d..b315b93bd 100644 --- a/libraries/SPI/SPI.cpp +++ b/libraries/SPI/SPI.cpp @@ -458,6 +458,12 @@ void SPIClass::waitForTransfer(void) { while(dma_busy); } +/* returns the current DMA transfer status to allow non-blocking polling */ +bool SPIClass::isBusy(void) { + return dma_busy; +} + + // End DMA-based SPI transfer() code --------------------------------------- void SPIClass::attachInterrupt() { diff --git a/libraries/SPI/SPI.h b/libraries/SPI/SPI.h index ca1e993ac..7c719f695 100644 --- a/libraries/SPI/SPI.h +++ b/libraries/SPI/SPI.h @@ -120,6 +120,7 @@ class SPIClass { void transfer(const void* txbuf, void* rxbuf, size_t count, bool block = true); void waitForTransfer(void); + bool isBusy(void); // Transaction Functions void usingInterrupt(int interruptNumber);