Brendon Shaw
Active member
I have an odd display which uses a modified ST7789 driver to support SPI9 but to update the display is quite slow. I am using an Teensy 3.6 and running the example DMASpi (https://github.com/crteensy/DmaSpi) and would like to convert the bit banging code to DMA transfer.
The ST7789 SPI 9 librry for the driver is here:
https://github.com/ananevilya/Arduino-ST7789-Library
This is the part of the code which bit bangs the data into SPI, the rest of the code is driver code and commands
I trying to work out if I can somehow replace the above code with DMA transfer, rather than the block data transfer into the bit transfer I want to add it into the DMA "src" buffer. I have tried the code but it does not work and just wondering if it will be possible.
The ST7789 SPI 9 librry for the driver is here:
https://github.com/ananevilya/Arduino-ST7789-Library
This is the part of the code which bit bangs the data into SPI, the rest of the code is driver code and commands
Code:
inline void Arduino_ST7789::spiwrite(uint8_t c)
{
digitalWrite(_sclk, LOW);
if(_DCbit) digitalWrite(_sid, HIGH);
else digitalWrite(_sid, LOW);
digitalWrite(_sclk, HIGH);
// Fast SPI bitbang swiped from LPD8806 library
for(uint8_t bit = 0x80; bit; bit >>= 1)
{
digitalWrite(_sclk, LOW);
if(c & bit)
digitalWrite(_sid, HIGH);
else
digitalWrite(_sid, LOW);
digitalWrite(_sclk, HIGH);
}
}
I trying to work out if I can somehow replace the above code with DMA transfer, rather than the block data transfer into the bit transfer I want to add it into the DMA "src" buffer. I have tried the code but it does not work and just wondering if it will be possible.
Code:
DMASPI0.begin();
DMASPI0.start();
Serial.println("Start DMA transfer");
DmaSpi::Transfer trx(nullptr, 0, nullptr);
trx = DmaSpi::Transfer(src, DMASIZE, dest);
clrDest((uint8_t*)dest);
DMASPI0.registerTransfer(trx);
while(trx.busy())
{
}
Serial.println("Finished DMA transfer");