Skip to content

Commit 652de85

Browse files
committed
Tufty 2040: RGB565 DMA display update.
Use DMA to transfer a native RGB565 display buffer to PIO rather than pushing into the TX FIFO in a loop. Co-authored by @zx64 - #776
1 parent 8648196 commit 652de85

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

drivers/st7789/st7789.cpp

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -240,29 +240,13 @@ namespace pimoroni {
240240
}
241241

242242
void ST7789::write_blocking_parallel(const uint8_t *src, size_t len) {
243-
const uint8_t *p = src;
244-
while(len--) {
245-
// Does not byte align correctly
246-
//pio_sm_put_blocking(parallel_pio, parallel_sm, *p);
247-
while (pio_sm_is_tx_fifo_full(parallel_pio, parallel_sm))
248-
;
249-
*(volatile uint8_t*)&parallel_pio->txf[parallel_sm] = *p;
250-
p++;
251-
}
243+
write_blocking_dma(src, len);
244+
dma_channel_wait_for_finish_blocking(st_dma);
252245

253-
uint32_t sm_stall_mask = 1u << (parallel_sm + PIO_FDEBUG_TXSTALL_LSB);
254-
parallel_pio->fdebug = sm_stall_mask;
255-
while (!(parallel_pio->fdebug & sm_stall_mask))
256-
;
257-
/*uint32_t mask = 0xff << d0;
258-
while(len--) {
259-
gpio_put(wr_sck, false);
260-
uint8_t v = *src++;
261-
gpio_put_masked(mask, v << d0);
262-
//asm("nop;");
263-
gpio_put(wr_sck, true);
264-
asm("nop;");
265-
}*/
246+
// This may cause a race between PIO and the
247+
// subsequent chipselect deassert for the last pixel
248+
while(!pio_sm_is_tx_fifo_empty(parallel_pio, parallel_sm))
249+
;
266250
}
267251

268252
void ST7789::command(uint8_t command, size_t len, const char *data) {

0 commit comments

Comments
 (0)