@@ -673,7 +673,27 @@ void Adafruit_SPITFT::initSPI(uint32_t freq) {
673673 dma.setTrigger (dmac_id);
674674 dma.setAction (DMA_TRIGGER_ACTON_BEAT);
675675
676- } else { // Parallel connection
676+ // Initialize descriptor list.
677+ for (int d=0 ; d<numDescriptors; d++) {
678+ // No need to set SRCADDR, DESCADDR or BTCNT --
679+ // those are done in the pixel-writing functions.
680+ descriptor[d].BTCTRL .bit .VALID = true ;
681+ descriptor[d].BTCTRL .bit .EVOSEL =
682+ DMA_EVENT_OUTPUT_DISABLE;
683+ descriptor[d].BTCTRL .bit .BLOCKACT =
684+ DMA_BLOCK_ACTION_NOACT;
685+ descriptor[d].BTCTRL .bit .BEATSIZE =
686+ DMA_BEAT_SIZE_BYTE;
687+ descriptor[d].BTCTRL .bit .DSTINC = 0 ;
688+ descriptor[d].BTCTRL .bit .STEPSEL =
689+ DMA_STEPSEL_SRC;
690+ descriptor[d].BTCTRL .bit .STEPSIZE =
691+ DMA_ADDRESS_INCREMENT_STEP_SIZE_1;
692+ descriptor[d].DSTADDR .reg =
693+ (uint32_t )data_reg;
694+ }
695+
696+ } else { // Parallel connection
677697
678698 int dmaChannel = dma.getChannel ();
679699 // Enable event output, use EVOSEL output
@@ -748,6 +768,7 @@ void Adafruit_SPITFT::initSPI(uint32_t freq) {
748768 // Wait for it, then enable EVSYS clock
749769 while (!GCLK->PCHCTRL [EVSYS_GCLK_ID_0].bit .CHEN );
750770 MCLK->APBBMASK .bit .EVSYS_ = 1 ;
771+
751772 // Connect Timer EVU to ch 0
752773 EVSYS->USER [tcList[tcNum].evu ].reg = 1 ;
753774 // Datasheet recommends single write operation;
@@ -758,27 +779,29 @@ void Adafruit_SPITFT::initSPI(uint32_t freq) {
758779 ev.bit .PATH = 2 ; // Asynchronous
759780 ev.bit .EVGEN = 0x22 + dmaChannel; // DMA channel 0+
760781 EVSYS->Channel [0 ].CHANNEL .reg = ev.reg ;
782+
783+ // Initialize descriptor list.
784+ for (int d=0 ; d<numDescriptors; d++) {
785+ // No need to set SRCADDR, DESCADDR or BTCNT --
786+ // those are done in the pixel-writing functions.
787+ descriptor[d].BTCTRL .bit .VALID = true ;
788+ // Event strobe on beat xfer:
789+ descriptor[d].BTCTRL .bit .EVOSEL = 0x3 ;
790+ descriptor[d].BTCTRL .bit .BLOCKACT =
791+ DMA_BLOCK_ACTION_NOACT;
792+ descriptor[d].BTCTRL .bit .BEATSIZE = tft8.wide ?
793+ DMA_BEAT_SIZE_HWORD : DMA_BEAT_SIZE_BYTE;
794+ descriptor[d].BTCTRL .bit .SRCINC = 1 ;
795+ descriptor[d].BTCTRL .bit .DSTINC = 0 ;
796+ descriptor[d].BTCTRL .bit .STEPSEL =
797+ DMA_STEPSEL_SRC;
798+ descriptor[d].BTCTRL .bit .STEPSIZE =
799+ DMA_ADDRESS_INCREMENT_STEP_SIZE_1;
800+ descriptor[d].DSTADDR .reg =
801+ (uint32_t )tft8.writePort ;
802+ }
761803 } // end parallel-specific DMA setup
762804
763- // Initialize descriptor list.
764- for (int d=0 ; d<numDescriptors; d++) {
765- // No need to set SRCADDR, DESCADDR or BTCNT --
766- // those are done in the pixel-writing functions.
767- descriptor[d].BTCTRL .bit .VALID = true ;
768- descriptor[d].BTCTRL .bit .EVOSEL =
769- DMA_EVENT_OUTPUT_DISABLE;
770- descriptor[d].BTCTRL .bit .BLOCKACT =
771- DMA_BLOCK_ACTION_NOACT;
772- descriptor[d].BTCTRL .bit .BEATSIZE =
773- DMA_BEAT_SIZE_BYTE;
774- descriptor[d].BTCTRL .bit .DSTINC = 0 ;
775- descriptor[d].BTCTRL .bit .STEPSEL =
776- DMA_STEPSEL_SRC;
777- descriptor[d].BTCTRL .bit .STEPSIZE =
778- DMA_ADDRESS_INCREMENT_STEP_SIZE_1;
779- descriptor[d].DSTADDR .reg =
780- (uint32_t )data_reg;
781- }
782805 lastFillColor = 0x0000 ;
783806 lastFillLen = 0 ;
784807 dma.setCallback (dma_callback);
@@ -892,6 +915,7 @@ void Adafruit_SPITFT::writePixels(uint16_t *colors, uint32_t len) {
892915 memcpy (dptr, &descriptor[pixelBufIdx], sizeof (DmacDescriptor));
893916 dma_busy = true ;
894917 dma.startJob (); // Trigger SPI DMA transfer
918+ if (connection == TFT_PARALLEL) dma.trigger ();
895919 pixelBufIdx = 1 - pixelBufIdx; // Swap DMA pixel buffers
896920
897921 len -= count;
@@ -1022,6 +1046,7 @@ void Adafruit_SPITFT::writeColor(uint16_t color, uint32_t len) {
10221046
10231047 dma_busy = true ;
10241048 dma.startJob ();
1049+ if (connection == TFT_PARALLEL) dma.trigger ();
10251050 while (dma_busy); // Wait for completion
10261051 // Unfortunately blocking is necessary. An earlier version returned
10271052 // immediately and checked dma_busy on startWrite() instead, but it
0 commit comments