summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOld-Ding <[email protected]>2026-07-06 11:02:56 +0800
committerRbb666 <[email protected]>2026-07-08 13:21:51 +0800
commitd8a7e3eeb03ef68b85d957aa2077d81f437ca67f (patch)
tree40ffff839e9f486a6dde361e38938aec8f3b599f
parent50c6853d38125d887aeeb8b0825207af605b0d97 (diff)
bsp: renesas: Fix LCD framebuffer bounds
The Renesas LCD helper treats LCD_WIDTH and LCD_HEIGHT as pixel counts. The framebuffer clear loop and lcd_draw_pixel() accepted those count values as valid indexes, which can write one pixel past the framebuffer. Use strict bounds for the 0-based framebuffer indexes and adjust the 180-degree rotation mapping to target the last valid row and column. Generated-by: OpenAI Codex Signed-off-by: Old-Ding <[email protected]>
-rw-r--r--bsp/renesas/libraries/HAL_Drivers/drivers/drv_lcd.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/bsp/renesas/libraries/HAL_Drivers/drivers/drv_lcd.c b/bsp/renesas/libraries/HAL_Drivers/drivers/drv_lcd.c
index 883b43d2bf..8b77dd3c1b 100644
--- a/bsp/renesas/libraries/HAL_Drivers/drivers/drv_lcd.c
+++ b/bsp/renesas/libraries/HAL_Drivers/drivers/drv_lcd.c
@@ -88,7 +88,7 @@ static void turn_on_lcd_backlight(void)
static void ra_bsp_lcd_clear(uint16_t color)
{
- for (uint32_t i = 0; i <= LCD_BUF_SIZE / sizeof(uint16_t); i++)
+ for (uint32_t i = 0; i < LCD_BUF_SIZE / sizeof(uint16_t); i++)
{
lcd_current_working_buffer[i] = color;
}
@@ -97,7 +97,7 @@ static void ra_bsp_lcd_clear(uint16_t color)
void lcd_draw_pixel(uint32_t x, uint32_t y, uint16_t color)
{
// Verify pixel is within LCD range
- if ((x <= LCD_WIDTH) && (y <= LCD_HEIGHT))
+ if ((x < LCD_WIDTH) && (y < LCD_HEIGHT))
{
switch (screen_rotation)
{
@@ -108,7 +108,7 @@ void lcd_draw_pixel(uint32_t x, uint32_t y, uint16_t color)
}
case ROTATION_180:
{
- lcd_current_working_buffer[((LCD_HEIGHT - y) * LCD_WIDTH) + (LCD_WIDTH - x)] = color;
+ lcd_current_working_buffer[(((LCD_HEIGHT - 1) - y) * LCD_WIDTH) + ((LCD_WIDTH - 1) - x)] = color;
break;
}
default: