From e290cb1b8b1dea29f0247bda4cf92725b8acf017 Mon Sep 17 00:00:00 2001 From: cstout Date: Wed, 9 Mar 2016 11:10:57 -0800 Subject: [PATCH] [display] Fix corruption in color lcd update. Suspect a timing issue related to the trailer bits. Preparing the trailers together with the data seems to resolve the corruption. R=gkalsi@google.com Review URL: https://codereview.chromium.org/1777653003 . --- target/dartuinoP0/memory_lcd.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/target/dartuinoP0/memory_lcd.c b/target/dartuinoP0/memory_lcd.c index 1f792f33..0249211e 100644 --- a/target/dartuinoP0/memory_lcd.c +++ b/target/dartuinoP0/memory_lcd.c @@ -122,6 +122,7 @@ static void mlcd_flush(uint starty, uint endy) static uint8_t localbuf[MLCD_BUF_SIZE]; uint8_t *bufptr = localbuf; + uint8_t trailer = 0; // The first line is preceeded with a write command. *bufptr++ = MLCD_WR | vcom_state; @@ -134,21 +135,20 @@ static void mlcd_flush(uint starty, uint endy) bufptr += lcd_get_line(framebuffer, j, bufptr); + // 8 bit trailer per line + *bufptr++ = trailer; + if (j == endy) { + // 16 bit trailer on the last line + *bufptr++ = trailer; + } + if (HAL_SPI_Transmit(&SpiHandle, localbuf, bufptr - localbuf, HAL_MAX_DELAY) != HAL_OK) { goto finish; } bufptr = localbuf; - - *bufptr++ = (j + 1); } - uint8_t trailer = 0; - if (HAL_SPI_Transmit(&SpiHandle, &trailer, 1, HAL_MAX_DELAY) != HAL_OK) { - goto finish; - } - - finish: chip_select(false); }