since now we have SPI DMA for nrf, we need to add some more #define's

This commit is contained in:
ladyada 2019-10-17 15:05:39 -04:00
parent 051fe67a0f
commit 8596d46bce
2 changed files with 12 additions and 14 deletions

View File

@ -50,8 +50,8 @@
#define digitalPinToPort(P) (&(PORT_IOBUS->Group[g_APinDescription[P].ulPort])) #define digitalPinToPort(P) (&(PORT_IOBUS->Group[g_APinDescription[P].ulPort]))
#endif // end PORT_IOBUS #endif // end PORT_IOBUS
#if defined(USE_SPI_DMA) #if defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(__SAMD21__))
#pragma message ("GFX DMA IS ENABLED. HIGHLY EXPERIMENTAL.") // #pragma message ("GFX DMA IS ENABLED. HIGHLY EXPERIMENTAL.")
#include <Adafruit_ZeroDMA.h> #include <Adafruit_ZeroDMA.h>
#include "wiring_private.h" // pinPeripheral() function #include "wiring_private.h" // pinPeripheral() function
#include <malloc.h> // memalign() function #include <malloc.h> // memalign() function
@ -648,7 +648,7 @@ void Adafruit_SPITFT::initSPI(uint32_t freq, uint8_t spiMode) {
delay(200); delay(200);
} }
#if defined(USE_SPI_DMA) #if defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(__SAMD21__))
if(((connection == TFT_HARD_SPI) || (connection == TFT_PARALLEL)) && if(((connection == TFT_HARD_SPI) || (connection == TFT_PARALLEL)) &&
(dma.allocate() == DMA_STATUS_OK)) { // Allocate channel (dma.allocate() == DMA_STATUS_OK)) { // Allocate channel
// The DMA library needs to alloc at least one valid descriptor, // The DMA library needs to alloc at least one valid descriptor,
@ -1003,7 +1003,7 @@ void Adafruit_SPITFT::writePixels(uint16_t *colors, uint32_t len,
} }
return; return;
#elif defined(USE_SPI_DMA) #elif defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(__SAMD21__))
if((connection == TFT_HARD_SPI) || (connection == TFT_PARALLEL)) { if((connection == TFT_HARD_SPI) || (connection == TFT_PARALLEL)) {
int maxSpan = maxFillLen / 2; // One scanline max int maxSpan = maxFillLen / 2; // One scanline max
uint8_t pixelBufIdx = 0; // Active pixel buffer number uint8_t pixelBufIdx = 0; // Active pixel buffer number
@ -1103,7 +1103,7 @@ void Adafruit_SPITFT::writePixels(uint16_t *colors, uint32_t len,
was used (as is the default case). was used (as is the default case).
*/ */
void Adafruit_SPITFT::dmaWait(void) { void Adafruit_SPITFT::dmaWait(void) {
#if defined(USE_SPI_DMA) #if defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(__SAMD21__))
while(dma_busy); while(dma_busy);
#if defined(__SAMD51__) || defined(_SAMD21_) #if defined(__SAMD51__) || defined(_SAMD21_)
if(connection == TFT_HARD_SPI) { if(connection == TFT_HARD_SPI) {
@ -1175,7 +1175,7 @@ void Adafruit_SPITFT::writeColor(uint16_t color, uint32_t len) {
return; return;
} }
#else // !ESP32 #else // !ESP32
#if defined(USE_SPI_DMA) #if defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(__SAMD21__))
if(((connection == TFT_HARD_SPI) || (connection == TFT_PARALLEL)) && if(((connection == TFT_HARD_SPI) || (connection == TFT_PARALLEL)) &&
(len >= 16)) { // Don't bother with DMA on short pixel runs (len >= 16)) { // Don't bother with DMA on short pixel runs
int i, d, numDescriptors; int i, d, numDescriptors;

View File

@ -71,8 +71,10 @@ typedef volatile ADAGFX_PORT_t* PORTreg_t; ///< PORT register type
#define DEFAULT_SPI_FREQ 16000000L ///< Hardware SPI default speed #define DEFAULT_SPI_FREQ 16000000L ///< Hardware SPI default speed
#endif #endif
#if defined(ADAFRUIT_PYPORTAL) || defined(ADAFRUIT_PYBADGE_M4_EXPRESS) || defined(ADAFRUIT_PYGAMER_M4_EXPRESS)|| defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) #if defined(ADAFRUIT_PYPORTAL) || defined(ADAFRUIT_PYBADGE_M4_EXPRESS) || \
#define USE_SPI_DMA ///< Auto DMA if using PyPortal defined(ADAFRUIT_PYGAMER_M4_EXPRESS)|| defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) \
defined(NRF52)
#define USE_SPI_DMA ///< Auto DMA
#else #else
//#define USE_SPI_DMA ///< If set, use DMA if available //#define USE_SPI_DMA ///< If set, use DMA if available
#endif #endif
@ -82,11 +84,7 @@ typedef volatile ADAGFX_PORT_t* PORTreg_t; ///< PORT register type
// 4 bytes/pixel on display major axis + 8 bytes/pixel on minor axis, // 4 bytes/pixel on display major axis + 8 bytes/pixel on minor axis,
// e.g. 320x240 pixels = 320 * 4 + 240 * 8 = 3,200 bytes. // e.g. 320x240 pixels = 320 * 4 + 240 * 8 = 3,200 bytes.
#if !defined(ARDUINO_ARCH_SAMD) #if defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(__SAMD21__))
#undef USE_SPI_DMA ///< DMA currently for SAMD chips only
#endif
#if defined(USE_SPI_DMA)
#include <Adafruit_ZeroDMA.h> #include <Adafruit_ZeroDMA.h>
#endif #endif
@ -479,7 +477,7 @@ class Adafruit_SPITFT : public Adafruit_GFX {
#if defined(__cplusplus) && (__cplusplus >= 201100) #if defined(__cplusplus) && (__cplusplus >= 201100)
}; ///< Only one interface is active }; ///< Only one interface is active
#endif #endif
#if defined(USE_SPI_DMA) // Used by hardware SPI and tft8 #if defined(USE_SPI_DMA) && (defined(__SAMD51__) || defined(__SAMD21__)) // Used by hardware SPI and tft8
Adafruit_ZeroDMA dma; ///< DMA instance Adafruit_ZeroDMA dma; ///< DMA instance
DmacDescriptor *dptr = NULL; ///< 1st descriptor DmacDescriptor *dptr = NULL; ///< 1st descriptor
DmacDescriptor *descriptor = NULL; ///< Allocated descriptor list DmacDescriptor *descriptor = NULL; ///< Allocated descriptor list