diff --git a/platform/drivers/display/SH110x_Mod17.c b/platform/drivers/display/SH110x_Mod17.c index b88803f9..3310210b 100644 --- a/platform/drivers/display/SH110x_Mod17.c +++ b/platform/drivers/display/SH110x_Mod17.c @@ -29,20 +29,9 @@ #include #include -/* - * LCD framebuffer, statically allocated and placed in the "large" RAM block - * starting at 0x20000000. - * Pixel format is black and white, one bit per pixel. - */ -#define FB_SIZE (((CONFIG_SCREEN_HEIGHT * CONFIG_SCREEN_WIDTH) / 8 ) + 1) -static uint8_t __attribute__((section(".bss2"))) frameBuffer[FB_SIZE]; - void display_init() { - /* Clear framebuffer, setting all pixels to 0x00 makes the screen white */ - memset(frameBuffer, 0x00, FB_SIZE); - /* * Initialise SPI2 for external flash and LCD */ @@ -103,10 +92,11 @@ void display_terminate() spi2_terminate(); } -void display_renderRows(uint8_t startRow, uint8_t endRow) +void display_renderRows(uint8_t startRow, uint8_t endRow, void *fb) { gpio_clearPin(LCD_CS); + uint8_t *frameBuffer = (uint8_t *) fb; for(uint8_t y = startRow; y < endRow; y++) { for(uint8_t x = 0; x < CONFIG_SCREEN_WIDTH/8; x++) @@ -125,14 +115,9 @@ void display_renderRows(uint8_t startRow, uint8_t endRow) gpio_setPin(LCD_CS); } -void display_render() +void display_render(void *fb) { - display_renderRows(0, CONFIG_SCREEN_HEIGHT); -} - -void *display_getFrameBuffer() -{ - return (void *)(frameBuffer); + display_renderRows(0, CONFIG_SCREEN_HEIGHT, fb); } void display_setContrast(uint8_t contrast) diff --git a/platform/drivers/display/SSD1306_Mod17.c b/platform/drivers/display/SSD1306_Mod17.c index 9b1a485b..ee115485 100644 --- a/platform/drivers/display/SSD1306_Mod17.c +++ b/platform/drivers/display/SSD1306_Mod17.c @@ -30,14 +30,6 @@ #include -/* - * LCD framebuffer, statically allocated and placed in the "large" RAM block - * starting at 0x20000000. - * Pixel format is black and white, one bit per pixel. - */ -#define FB_SIZE (((CONFIG_SCREEN_HEIGHT * CONFIG_SCREEN_WIDTH) / 8 ) + 1) -static uint8_t __attribute__((section(".bss2"))) frameBuffer[FB_SIZE]; - /** * \internal * Send one row of pixels to the display. @@ -46,7 +38,7 @@ static uint8_t __attribute__((section(".bss2"))) frameBuffer[FB_SIZE]; * * @param row: pixel row to be be sent. */ -void display_renderRow(uint8_t row) +void display_renderRow(uint8_t row, uint8_t *frameBuffer) { for(uint16_t i = 0; i < 64; i++) { @@ -65,9 +57,6 @@ void display_renderRow(uint8_t row) void display_init() { - /* Clear framebuffer, setting all pixels to 0x00 makes the screen white */ - memset(frameBuffer, 0x00, FB_SIZE); - /* * Initialise SPI2 for external flash and LCD */ @@ -128,7 +117,7 @@ void display_terminate() spi2_terminate(); } -void display_renderRows(uint8_t startRow, uint8_t endRow) +void display_renderRows(uint8_t startRow, uint8_t endRow, void *fb) { gpio_clearPin(LCD_CS); @@ -139,20 +128,15 @@ void display_renderRows(uint8_t startRow, uint8_t endRow) (void) spi2_sendRecv(0x00); /* Set X position */ (void) spi2_sendRecv(0x10); gpio_setPin(LCD_RS); /* RS high -> data mode */ - display_renderRow(row); + display_renderRow(row, (uint8_t *) fb); } gpio_setPin(LCD_CS); } -void display_render() +void display_render(void *fb) { - display_renderRows(0, (CONFIG_SCREEN_WIDTH / 8) - 1); -} - -void *display_getFrameBuffer() -{ - return (void *)(frameBuffer); + display_renderRows(0, (CONFIG_SCREEN_WIDTH / 8) - 1, fb); } void display_setContrast(uint8_t contrast) diff --git a/platform/mcu/STM32F4xx/linker_script_Mod17.ld b/platform/mcu/STM32F4xx/linker_script_Mod17.ld index 13473b0c..372fb671 100644 --- a/platform/mcu/STM32F4xx/linker_script_Mod17.ld +++ b/platform/mcu/STM32F4xx/linker_script_Mod17.ld @@ -163,10 +163,18 @@ SECTIONS } > smallram AT > flash _etext = LOADADDR(.data); + /* Put the display framebuffer in the "large" RAM, explicitly request to not + initialize it */ + .bss2 (NOLOAD) : + { + *(.bss.fb) + . = ALIGN(8); + } > largeram + /* .bss section: uninitialized global variables go to ram */ - _bss_start = .; .bss : { + _bss_start = .; *(.bss) *(.bss.*) *(.gnu.linkonce.b.*) @@ -174,14 +182,6 @@ SECTIONS } > smallram _bss_end = .; - /* Second BSS section located in the "large" RAM, explicitly request to not - initialize it */ - .bss2 (NOLOAD) : - { - *(.bss2) - . = ALIGN(8); - } > largeram - _end = .; PROVIDE(end = .); }