STM32LTDC: Rename user config options for consistency & add docs

develop
Joel Bodenmann 2021-08-17 14:23:57 +02:00
parent 91247717a0
commit 7f78be1183
8 changed files with 49 additions and 55 deletions

View File

@ -23,10 +23,6 @@ static const SPIConfig spi_cfg = {
((1 << 3) & SPI_CR1_BR) | SPI_CR1_SSM | SPI_CR1_SSI | SPI_CR1_MSTR
};
#define LTDC_USE_DMA2D GFXON
#define LTDC_USE_2ND_LAYER GFXON
#define LTDC_DMA_CACHE_FLUSH GFXOFF // This will be turned on automatically on certain systems/platforms
static const ltdcConfig driverCfg = {
240, 320,
10, 2,
@ -49,7 +45,7 @@ static const ltdcConfig driverCfg = {
0xFF, // alpha
LTDC_LEF_ENABLE // flags
},
#if LTDC_USE_2ND_LAYER
#if STM32LTDC_USE_LAYER2
{ // Foreground layer config (if turned on)
(LLDCOLOR_TYPE *)(SDRAM_BANK_ADDR+(240 * 320 * LTDC_PIXELBYTES)), // Frame buffer address
240, 320, // width, height

View File

@ -19,10 +19,6 @@
#include "stm32f4xx_hal.h"
#include "stm324x9i_eval_sdram.h"
#define LTDC_USE_DMA2D GFXON
#define LTDC_USE_2ND_LAYER GFXON
#define LTDC_DMA_CACHE_FLUSH GFXOFF // This will be turned on automatically on certain systems/platforms
// Panel parameters
// This panel is a AMPIRE640480 panel.
@ -50,7 +46,7 @@ static const ltdcConfig driverCfg = {
LTDC_LEF_ENABLE // Layer configuration flags
},
#if LTDC_USE_2ND_LAYER
#if STM32LTDC_USE_LAYER2
{ // Foreground layer config (if turned on)
(LLDCOLOR_TYPE *)(SDRAM_DEVICE_ADDR+(640 * 480 * LTDC_PIXELBYTES)), // Frame buffer address
640, 480, // Width, Height (pixels)

View File

@ -8,10 +8,6 @@
#ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H
#define LTDC_USE_DMA2D GFXON
#define LTDC_USE_2ND_LAYER GFXON
#define LTDC_DMA_CACHE_FLUSH GFXOFF // This will be turned on automatically on certain systems/platforms
/* Avoid naming collisions with CubeHAL. */
#if GFX_COMPAT_V2 && GFX_COMPAT_OLDCOLORS
#undef Red

View File

@ -36,10 +36,6 @@
#define AFRH AFR[1]
#endif
#define LTDC_USE_DMA2D GFXON
#define LTDC_USE_2ND_LAYER GFXON
#define LTDC_DMA_CACHE_FLUSH GFXOFF // This will be turned on automatically on certain systems/platforms
static const ltdcConfig driverCfg = {
480, 272, // Width, Height (pixels)
41, 10, // Horizontal, Vertical sync (pixels)
@ -64,7 +60,7 @@ static const ltdcConfig driverCfg = {
LTDC_LEF_ENABLE // Layer configuration flags
},
#if LTDC_USE_2ND_LAYER
#if STM32LTDC_USE_LAYER2
{ // Foreground layer config (if turned on)
(LLDCOLOR_TYPE *)(SDRAM_DEVICE_ADDR+(480 * 272 * LTDC_PIXELBYTES)), // Frame buffer address
480, 272, // Width, Height (pixels)
@ -408,7 +404,7 @@ static GFXINLINE void init_ltdc_clock(void)
RCC->APB2ENR |= RCC_APB2ENR_LTDCEN;
}
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
static GFXINLINE void init_dma2d_clock(void)
{
// Enable DMA2D clock

View File

@ -8,10 +8,6 @@
#ifndef _GDISP_LLD_BOARD_H
#define _GDISP_LLD_BOARD_H
#define LTDC_USE_DMA2D GFXON
#define LTDC_USE_2ND_LAYER GFXOFF
#define LTDC_DMA_CACHE_FLUSH GFXOFF // This will be turned on automatically on certain systems/platforms
static const ltdcConfig driverCfg = {
480, 272, // Width, Height (pixels)
41, 10, // Horizontal, Vertical sync (pixels)
@ -36,7 +32,7 @@ static const ltdcConfig driverCfg = {
LTDC_LEF_ENABLE // Layer configuration flags
},
#if LTDC_USE_2ND_LAYER
#if STM32LTDC_USE_LAYER2
{ // Foreground layer config (if turned on)
(LLDCOLOR_TYPE *)(SDRAM_DEVICE_ADDR+(480 * 272 * LTDC_PIXELBYTES)), // Frame buffer address
480, 272, // Width, Height (pixels)
@ -62,7 +58,7 @@ static GFXINLINE void init_ltdc_clock(void)
// Setup LTDC clock and enable the peripheral
}
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
static GFXINLINE void init_dma2d_clock(void)
{
// Setup DMA2D clock and enable the peripheral

View File

@ -13,7 +13,7 @@
#include "gdisp_lld_config.h"
#include "../../../src/gdisp/gdisp_driver.h"
#include "stm32_ltdc.h"
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
#include "stm32_dma2d.h"
#endif
@ -27,6 +27,27 @@
#undef GDISP_SCREEN_HEIGHT
#endif
#ifndef STM32LTDC_DMA_CACHE_FLUSH
#define STM32LTDC_DMA_CACHE_FLUSH GFXOFF
#endif
#ifndef STM32LTDC_USE_DMA2D
#define STM32LTDC_USE_DMA2D GFXOFF
#endif
#ifndef STM32LTDC_USE_LAYER2
#define STM32LTDC_USE_LAYER2 GFXOFF
#endif
#ifndef STM32LTDC_USE_RGB565
#define STM32LTDC_USE_RGB565 GFXOFF
#endif
// Force DMA cache flushing on certain platforms/systems.
#if STM32LTDC_USE_DMA2D
#if defined(STM32F7) || defined(STM32H7) || defined(STM32F746xx)
#undef STM32LTDC_DMA_CACHE_FLUSH
#define STM32LTDC_DMA_CACHE_FLUSH GFXON
#endif
#endif
typedef struct ltdcLayerConfig {
// Frame
LLDCOLOR_TYPE* frame; // Frame buffer address
@ -75,20 +96,6 @@ typedef struct ltdcConfig {
#include "board_STM32LTDC.h"
#ifndef LTDC_USE_DMA2D
#define LTDC_USE_DMA2D GFXOFF
#endif
#ifndef LTDC_DMA_CACHE_FLUSH
#define LTDC_DMA_CACHE_FLUSH GFXOFF
#endif
#if LTDC_USE_DMA2D
#if defined(STM32F7) || defined(STM32H7) || defined(STM32F746xx)
#undef LTDC_DMA_CACHE_FLUSH
#define LTDC_DMA_CACHE_FLUSH GFXON
#endif
#endif
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
@ -226,7 +233,7 @@ LLDSPEC gBool gdisp_lld_init(GDisplay* g) {
_ltdc_init();
// Initialise DMA2D
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
dma2d_init();
#endif
@ -297,7 +304,7 @@ LLDSPEC void gdisp_lld_draw_pixel(GDisplay* g) {
pos = PIXIL_POS(g, g->p.x, g->p.y);
#endif
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
while(DMA2D->CR & DMA2D_CR_START);
#endif
@ -335,7 +342,7 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
pos = PIXIL_POS(g, g->p.x, g->p.y);
#endif
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
while(DMA2D->CR & DMA2D_CR_START);
#endif
@ -393,8 +400,8 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
}
#endif
#if LTDC_USE_DMA2D
#if LTDC_DMA_CACHE_FLUSH
#if STM32LTDC_USE_DMA2D
#if STM32LTDC_DMA_CACHE_FLUSH
#if defined(__CC_ARM)
#define __ugfxDSB() __dsb(0xF)
#else // GCC like
@ -459,7 +466,7 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
shape = (g->p.cx << 16) | (g->p.cy);
#endif
#if LTDC_DMA_CACHE_FLUSH
#if STM32LTDC_DMA_CACHE_FLUSH
{
// This is slightly less than optimal as we flush the whole line in the source and destination image
// instead of just the cx portion but this saves us having to iterate over each line.
@ -524,7 +531,7 @@ LLDSPEC gColor gdisp_lld_get_pixel_color(GDisplay* g) {
srcstart = LTDC_PIXELBYTES * ((gU32)g->p.x2 * g->p.y1 * + g->p.x1) + (gU32)g->p.ptr;
dststart = (gU32)PIXEL_ADDR(g, PIXIL_POS(g, g->p.x, g->p.y));
#if LTDC_DMA_CACHE_FLUSH
#if STM32LTDC_DMA_CACHE_FLUSH
{
// This is slightly less than optimal as we flush the whole line in the source and destination image
// instead of just the cx portion but this saves us having to iterate over each line.

View File

@ -14,7 +14,6 @@
/* Driver hardware support. */
/*===========================================================================*/
#define LTDC_USE_DMA2D GFXON
#define GDISP_HARDWARE_DRAWPIXEL GFXON
#define GDISP_HARDWARE_PIXELREAD GFXON
#define GDISP_HARDWARE_CONTROL GFXON
@ -22,10 +21,10 @@
// Both these pixel formats are supported - pick one.
// RGB565 obviously is faster and uses less RAM but with lower color resolution than RGB888
#if defined(GDISP_LTDC_USE_RGB565) && GDISP_LTDC_USE_RGB565
#if defined(STM32LTDC_USE_RGB565) && STM32LTDC_USE_RGB565
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB565
#if GDISP_TOTAL_DISPLAYS > 1
#error "LTDC: You must use RGB888 pixel format with LTDC when using dual layers as only RGB888 currently supports using alpha"
#error "GDISP - STM32LTDC: You must use RGB888 pixel format with LTDC when using dual layers as only RGB888 currently supports using alpha"
#endif
#else
#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB888
@ -36,7 +35,7 @@
/* Don't change stuff below this line. Please. */
/*===========================================================================*/
#if LTDC_USE_DMA2D
#if STM32LTDC_USE_DMA2D
// DMA2D supports accelerated fills
#define GDISP_HARDWARE_FILLS GFXON

View File

@ -12,11 +12,19 @@ To use this driver:
3. Add a `board_STM32LTDC.h` to you project directory (or board directory)
based on one of the templates.
# Configuration
Configuration options available in `gfxconf.h`:
| Option | Default | Description |
| --- | --- | --- |
| `STM32LTDC_DMA_CACHE_FLUSH` | `GFOFF` | Whether to flush the DMA cache on DMA2D operations. This will be turned on automatically on certian platforms/systems. |
| `STM32LTDC_USE_DMA2D` | `GFXON` | Whether to use the DMA2D peripheral for hardware acceleration. |
| `STM32LTDC_USE_LAYER2` | `GFXOFF` | Whether to use the 2nd LTDC layer. |
| `STM32LTDC_USE_RGB565` | `GFXOFF` | Whether to use RGB565 instead of RGB888. |
# 2nd layer
Two things need to happen in order to use the 2nd LTDC layer:
- Set `LTDC_USE_2ND_LAYER` to `GFXON` in the board file.
- Set `GDISP_TOTAL_DISPLAYS` to `2` in `gfxconf.h`.
To use the 2nd LTDC layer, set `STM32LTDC_USE_LAYER2` to `GFXON` in `gfxconf.h`.
The 2nd layer is exposed as a separate display. Use `gdispGetDisplay()` to retrieve the individual layers.