From: aleph Date: Tue, 26 Oct 2010 15:04:30 +0000 (+0000) Subject: ILI9225 lcd driver: writes one row at a time: a lot faster when using SPI DMA. X-Git-Tag: 2.6.0~5^2~51 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=f29ac1e96200504a6118e5942b66e122509babb2;p=bertos.git ILI9225 lcd driver: writes one row at a time: a lot faster when using SPI DMA. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4469 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/drv/lcd_ili9225.c b/bertos/drv/lcd_ili9225.c index bcfdf812..5594dc96 100644 --- a/bertos/drv/lcd_ili9225.c +++ b/bertos/drv/lcd_ili9225.c @@ -30,7 +30,7 @@ * * --> * - * \brief ILI9225B 176x220 graphic driver + * \brief ILI9225B 4 wire interface graphic driver * * \author Stefano Fedrigo * @@ -73,10 +73,18 @@ #include #include +#include static struct KFile *spi; +/* + * Display row buffer. When refreshing display one full row of + * graphics data is transferred with DMA, to speed up transfer and + * reduce CPU usage. + */ +static uint16_t lcd_row[LCD_WIDTH]; + struct lcd_ili9225_reg { @@ -136,23 +144,21 @@ static void lcd_cmd(uint8_t cmd) kfile_write(spi, &cmd, sizeof(cmd)); } -static void lcd_data(uint16_t data) +static void lcd_data(uint16_t *data, size_t count) { - char bytes[2]; - bytes[0] = data >> 8; - bytes[1] = data & 0xFF; - kfile_flush(spi); LCD_RS_HIGH(); - kfile_write(spi, bytes, 2); + kfile_write(spi, data, count*2); kfile_flush(spi); LCD_CS_HIGH(); } static void lcd_regWrite(uint8_t reg, uint16_t data) { + uint16_t word = cpu_to_be16(data); + lcd_cmd(reg); - lcd_data(data); + lcd_data(&word, 1); } static void lcd_startBlit(uint8_t x, uint8_t y, uint8_t width, uint8_t height) @@ -184,7 +190,6 @@ void lcd_ili9225_blitRaw(UNUSED_ARG(const uint8_t *, data), */ void lcd_ili9225_blitBitmap(const Bitmap *bm) { - //uint16_t lcd_row[bm->width]; uint8_t mask; int i, l, r; @@ -197,10 +202,12 @@ void lcd_ili9225_blitBitmap(const Bitmap *bm) for (i = 0; i < bm->width; i++) { if (bm->raster[l * bm->width + i] & mask) - lcd_regWrite(0x22, 0xffff); + lcd_row[i] = 0x0000; else - lcd_regWrite(0x22, 0x0000); + lcd_row[i] = 0xFFFF; } + lcd_cmd(0x22); + lcd_data(lcd_row, bm->width); } } @@ -209,10 +216,12 @@ void lcd_ili9225_blitBitmap(const Bitmap *bm) for (i = 0; i < bm->width; i++) { if (bm->raster[l * bm->width + i] & mask) - lcd_regWrite(0x22, 0xffff); + lcd_row[i] = 0x0000; else - lcd_regWrite(0x22, 0x0000); + lcd_row[i] = 0xFFFF; } + lcd_cmd(0x22); + lcd_data(lcd_row, bm->width); } } diff --git a/bertos/drv/lcd_ili9225.h b/bertos/drv/lcd_ili9225.h index 8df00aa1..4484ebf9 100644 --- a/bertos/drv/lcd_ili9225.h +++ b/bertos/drv/lcd_ili9225.h @@ -30,7 +30,7 @@ * * --> * - * \brief ILI9225B 176x220 graphic driver + * \brief ILI9225B 4 wire interface graphic driver * * $WIZ$ module_name = "lcd_ili9225" * $WIZ$ module_hw = "bertos/hw/hw_ili9225.h"