diff options
author | inmarket <andrewh@inmarket.com.au> | 2017-10-01 18:00:49 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2017-10-01 18:00:49 +1000 |
commit | 82047b1ac6e56361abac0c4b01f06c405e941d19 (patch) | |
tree | 85c199ec82a65f0db2e944f309a93b2b7655724f /boards/base/STM32F439i-Eval/CubeHal/board_STM32LTDC.h | |
parent | 70222f8c8ddaccf1362f97f4c595d1d06ef680ef (diff) | |
download | uGFX-82047b1ac6e56361abac0c4b01f06c405e941d19.tar.gz uGFX-82047b1ac6e56361abac0c4b01f06c405e941d19.tar.bz2 uGFX-82047b1ac6e56361abac0c4b01f06c405e941d19.zip |
STM32LTDC 2nd layer support with alpha
Diffstat (limited to 'boards/base/STM32F439i-Eval/CubeHal/board_STM32LTDC.h')
-rw-r--r-- | boards/base/STM32F439i-Eval/CubeHal/board_STM32LTDC.h | 75 |
1 files changed, 44 insertions, 31 deletions
diff --git a/boards/base/STM32F439i-Eval/CubeHal/board_STM32LTDC.h b/boards/base/STM32F439i-Eval/CubeHal/board_STM32LTDC.h index 2faa8550..fd9a32ca 100644 --- a/boards/base/STM32F439i-Eval/CubeHal/board_STM32LTDC.h +++ b/boards/base/STM32F439i-Eval/CubeHal/board_STM32LTDC.h @@ -17,6 +17,8 @@ #include "stm32f4xx_hal.h" #include "stm324x9i_eval_sdram.h" +#define ALLOW_2ND_LAYER TRUE + // Panel parameters // This panel is a AMPIRE640480 panel. @@ -35,8 +37,8 @@ static const ltdcConfig driverCfg = { LTDC_PIXELFORMAT, // Pixel format 0, 0, // Start pixel position (x, y) 640, 480, // Size of virtual layer (cx, cy) - LTDC_COLOR_FUCHSIA, // Default color (ARGB8888) - 0x980088, // Color key (RGB888) + 0x00000000, // Default color (ARGB8888) + 0x000000, // Color key (RGB888) LTDC_BLEND_FIX1_FIX2, // Blending factors 0, // Palette (RGB888, can be NULL) 0, // Palette length @@ -44,7 +46,25 @@ static const ltdcConfig driverCfg = { LTDC_LEF_ENABLE // Layer configuration flags }, - LTDC_UNUSED_LAYER_CONFIG // Foreground layer config +#if ALLOW_2ND_LAYER + { // Foreground layer config (if turned on) + (LLDCOLOR_TYPE *)(SDRAM_DEVICE_ADDR+(640 * 480 * LTDC_PIXELBYTES)), // Frame buffer address + 640, 480, // Width, Height (pixels) + 640 * LTDC_PIXELBYTES, // Line pitch (bytes) + LTDC_PIXELFORMAT, // Pixel format + 0, 0, // Start pixel position (x, y) + 640, 480, // Size of virtual layer (cx, cy) + 0x00000000, // Default color (ARGB8888) + 0x000000, // Color key (RGB888) + LTDC_BLEND_MOD1_MOD2, // Blending factors + 0, // Palette (RGB888, can be NULL) + 0, // Palette length + 0xFF, // Constant alpha factor + LTDC_LEF_ENABLE // Layer configuration flags + } +#else + LTDC_UNUSED_LAYER_CONFIG +#endif }; // LCD Clock values @@ -56,10 +76,10 @@ static void configureLcdClock(void) { #if 1 RCC_PeriphCLKInitTypeDef periph_clk_init_struct; - + periph_clk_init_struct.PLLSAI.PLLSAIN = LCD_PLLSAIN_VALUE; - periph_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - periph_clk_init_struct.PLLSAI.PLLSAIR = LCD_PLLSAIR_VALUE; + periph_clk_init_struct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; + periph_clk_init_struct.PLLSAI.PLLSAIR = LCD_PLLSAIR_VALUE; periph_clk_init_struct.PLLSAIDivR = LCD_PLLSAIDIVR_VALUE; HAL_RCCEx_PeriphCLKConfig(&periph_clk_init_struct); #else @@ -77,59 +97,52 @@ static void configureLcdPins(void) GPIO_InitTypeDef GPIO_Init_Structure; // Enable peripheral clocks - __GPIOI_CLK_ENABLE(); + __GPIOI_CLK_ENABLE(); __GPIOJ_CLK_ENABLE(); - __GPIOK_CLK_ENABLE(); + __GPIOK_CLK_ENABLE(); /*** LTDC Pins configuration ***/ // GPIOI - GPIO_Init_Structure.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; + GPIO_Init_Structure.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; - GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; + GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOI, &GPIO_Init_Structure); - // GPIOJ + // GPIOJ GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \ GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \ - GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; + GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; - GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; - HAL_GPIO_Init(GPIOJ, &GPIO_Init_Structure); + GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; + HAL_GPIO_Init(GPIOJ, &GPIO_Init_Structure); - // GPIOK configuration + // GPIOK configuration GPIO_Init_Structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ - GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; + GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; GPIO_Init_Structure.Mode = GPIO_MODE_AF_PP; GPIO_Init_Structure.Pull = GPIO_NOPULL; GPIO_Init_Structure.Speed = GPIO_SPEED_FAST; - GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; + GPIO_Init_Structure.Alternate = GPIO_AF14_LTDC; HAL_GPIO_Init(GPIOK, &GPIO_Init_Structure); } static GFXINLINE void init_board(GDisplay* g) { - // As we are not using multiple displays we set g->board to NULL as we don't use it - g->board = 0; - - switch(g->controllerdisplay) { - case 0: + (void) g; - // Set LCD pixel clock rate - configureLcdClock(); - - // Set pin directions - configureLcdPins(); + // Set LCD pixel clock rate + configureLcdClock(); - // Initialise the SDRAM - BSP_SDRAM_Init(); + // Set pin directions + configureLcdPins(); - break; - } + // Initialise the SDRAM + BSP_SDRAM_Init(); } static GFXINLINE void post_init_board(GDisplay* g) |