From ac228656ae741e7f9253e4c9238b702cad896cd8 Mon Sep 17 00:00:00 2001 From: mobyfab Date: Mon, 17 Sep 2012 19:35:10 +0200 Subject: DMA fixes, splitting the requests since 65535 is the max count --- drivers/gdisp/SSD1963/gdisp_lld.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'drivers') diff --git a/drivers/gdisp/SSD1963/gdisp_lld.c b/drivers/gdisp/SSD1963/gdisp_lld.c index 2b4fcaf5..50f163bb 100644 --- a/drivers/gdisp/SSD1963/gdisp_lld.c +++ b/drivers/gdisp/SSD1963/gdisp_lld.c @@ -388,10 +388,15 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { if (area > 1000) { // Do not use DMA for small areas dmaStreamSetPeripheral(LCD_DMA_STREAM, &color); dmaStreamSetMemory0(LCD_DMA_STREAM, LCD_RAM); - dmaStreamSetTransactionSize(LCD_DMA_STREAM, area); - dmaStreamSetMode(LCD_DMA_STREAM, STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M | STM32_DMA_CR_EN); - - while ((LCD_DMA_STREAM)->stream->NDTR > 0) chThdSleepMilliseconds(1); + uint32_t i; + uint16_t splitarea; + for (i = (area/65535)+1; i > 0; i--) { + if (i <= 1) splitarea = area%65535; + else splitarea = 65535; + dmaStreamSetTransactionSize(LCD_DMA_STREAM, splitarea); + dmaStreamSetMode(LCD_DMA_STREAM, STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M | STM32_DMA_CR_EN); + while ((LCD_DMA_STREAM)->stream->NDTR > 0) chThdSleepMilliseconds(5); + } } else { for(index = 0; index < area; index++) @@ -444,10 +449,15 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { if (area > 1000) { // Do not use DMA for small areas dmaStreamSetPeripheral(LCD_DMA_STREAM, buffer); dmaStreamSetMemory0(LCD_DMA_STREAM, LCD_RAM); - dmaStreamSetTransactionSize(LCD_DMA_STREAM, area); - dmaStreamSetMode(LCD_DMA_STREAM, STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PINC | STM32_DMA_CR_DIR_M2M | STM32_DMA_CR_EN); - - while ((LCD_DMA_STREAM)->stream->NDTR > 0) chThdSleepMilliseconds(1); + uint32_t i; + uint16_t splitarea; + for (i = (area/65535)+1; i > 0; i--) { + if (i <= 1) splitarea = area%65535; + else splitarea = 65535; + dmaStreamSetTransactionSize(LCD_DMA_STREAM, splitarea); + dmaStreamSetMode(LCD_DMA_STREAM, STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_PINC | STM32_DMA_CR_DIR_M2M | STM32_DMA_CR_EN); + while ((LCD_DMA_STREAM)->stream->NDTR > 0) chThdSleepMilliseconds(5); + } } else { for(; y < endy; y++, buffer += lg) -- cgit v1.2.3