this repository aim to make the official ST DISCO F746NG demo from STM32Cube_FW_F7_V1.2.0 working on mbed.
Dependencies: BSP_DISCO_F746NG_patch mbed-rtos mbed
Config/LCDConf.c@0:c00e6c923941, 2015-11-02 (annotated)
- Committer:
- NirT
- Date:
- Mon Nov 02 23:38:08 2015 +0000
- Revision:
- 0:c00e6c923941
Error: Incomplete type is not allowed in "patch/LwIP/src/include/lwip/dhcp.h", Line: 83, Col: 4; ; and more like this.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
NirT | 0:c00e6c923941 | 1 | /** |
NirT | 0:c00e6c923941 | 2 | ****************************************************************************** |
NirT | 0:c00e6c923941 | 3 | * @file lcdconf.c |
NirT | 0:c00e6c923941 | 4 | * @author MCD Application Team |
NirT | 0:c00e6c923941 | 5 | * @version V1.1.0 |
NirT | 0:c00e6c923941 | 6 | * @date 21-September-2015 |
NirT | 0:c00e6c923941 | 7 | * @brief This file implements the configuration for the GUI library |
NirT | 0:c00e6c923941 | 8 | ****************************************************************************** |
NirT | 0:c00e6c923941 | 9 | * @attention |
NirT | 0:c00e6c923941 | 10 | * |
NirT | 0:c00e6c923941 | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
NirT | 0:c00e6c923941 | 12 | * |
NirT | 0:c00e6c923941 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
NirT | 0:c00e6c923941 | 14 | * are permitted provided that the following conditions are met: |
NirT | 0:c00e6c923941 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
NirT | 0:c00e6c923941 | 16 | * this list of conditions and the following disclaimer. |
NirT | 0:c00e6c923941 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
NirT | 0:c00e6c923941 | 18 | * this list of conditions and the following disclaimer in the documentation |
NirT | 0:c00e6c923941 | 19 | * and/or other materials provided with the distribution. |
NirT | 0:c00e6c923941 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
NirT | 0:c00e6c923941 | 21 | * may be used to endorse or promote products derived from this software |
NirT | 0:c00e6c923941 | 22 | * without specific prior written permission. |
NirT | 0:c00e6c923941 | 23 | * |
NirT | 0:c00e6c923941 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
NirT | 0:c00e6c923941 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
NirT | 0:c00e6c923941 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
NirT | 0:c00e6c923941 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
NirT | 0:c00e6c923941 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
NirT | 0:c00e6c923941 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
NirT | 0:c00e6c923941 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
NirT | 0:c00e6c923941 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
NirT | 0:c00e6c923941 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
NirT | 0:c00e6c923941 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
NirT | 0:c00e6c923941 | 34 | * |
NirT | 0:c00e6c923941 | 35 | ****************************************************************************** |
NirT | 0:c00e6c923941 | 36 | */ |
NirT | 0:c00e6c923941 | 37 | |
NirT | 0:c00e6c923941 | 38 | /* Includes ------------------------------------------------------------------*/ |
NirT | 0:c00e6c923941 | 39 | #include "LCDConf.h" |
NirT | 0:c00e6c923941 | 40 | #include "GUI_Private.h" |
NirT | 0:c00e6c923941 | 41 | |
NirT | 0:c00e6c923941 | 42 | /** @addtogroup LCD CONFIGURATION |
NirT | 0:c00e6c923941 | 43 | * @{ |
NirT | 0:c00e6c923941 | 44 | */ |
NirT | 0:c00e6c923941 | 45 | |
NirT | 0:c00e6c923941 | 46 | /** @defgroup LCD CONFIGURATION |
NirT | 0:c00e6c923941 | 47 | * @brief This file contains the LCD Configuration |
NirT | 0:c00e6c923941 | 48 | * @{ |
NirT | 0:c00e6c923941 | 49 | */ |
NirT | 0:c00e6c923941 | 50 | |
NirT | 0:c00e6c923941 | 51 | /** @defgroup LCD CONFIGURATION_Private_TypesDefinitions |
NirT | 0:c00e6c923941 | 52 | * @{ |
NirT | 0:c00e6c923941 | 53 | */ |
NirT | 0:c00e6c923941 | 54 | /** |
NirT | 0:c00e6c923941 | 55 | * @} |
NirT | 0:c00e6c923941 | 56 | */ |
NirT | 0:c00e6c923941 | 57 | |
NirT | 0:c00e6c923941 | 58 | /** @defgroup LCD CONFIGURATION_Private_Defines |
NirT | 0:c00e6c923941 | 59 | * @{ |
NirT | 0:c00e6c923941 | 60 | */ |
NirT | 0:c00e6c923941 | 61 | /* LCD Timings */ |
NirT | 0:c00e6c923941 | 62 | |
NirT | 0:c00e6c923941 | 63 | #define HSYNC ((uint16_t)41) /* Horizontal synchronization */ |
NirT | 0:c00e6c923941 | 64 | #define HBP ((uint16_t)13) /* Horizontal back porch */ |
NirT | 0:c00e6c923941 | 65 | #define HFP ((uint16_t)32) /* Horizontal front porch */ |
NirT | 0:c00e6c923941 | 66 | #define VSYNC ((uint16_t)10) /* Vertical synchronization */ |
NirT | 0:c00e6c923941 | 67 | #define VBP ((uint16_t)2) /* Vertical back porch */ |
NirT | 0:c00e6c923941 | 68 | #define VFP ((uint16_t)2) /* Vertical front porch */ |
NirT | 0:c00e6c923941 | 69 | |
NirT | 0:c00e6c923941 | 70 | #undef LCD_SWAP_XY |
NirT | 0:c00e6c923941 | 71 | #undef LCD_MIRROR_Y |
NirT | 0:c00e6c923941 | 72 | |
NirT | 0:c00e6c923941 | 73 | #undef LCD_SWAP_RB |
NirT | 0:c00e6c923941 | 74 | |
NirT | 0:c00e6c923941 | 75 | #define LCD_SWAP_XY 1 |
NirT | 0:c00e6c923941 | 76 | #define LCD_MIRROR_Y 1 |
NirT | 0:c00e6c923941 | 77 | |
NirT | 0:c00e6c923941 | 78 | #define LCD_SWAP_RB 1 |
NirT | 0:c00e6c923941 | 79 | |
NirT | 0:c00e6c923941 | 80 | #define XSIZE_PHYS 480 |
NirT | 0:c00e6c923941 | 81 | #define YSIZE_PHYS 272 |
NirT | 0:c00e6c923941 | 82 | |
NirT | 0:c00e6c923941 | 83 | #define NUM_BUFFERS 3 /* Number of multiple buffers to be used */ |
NirT | 0:c00e6c923941 | 84 | #define NUM_VSCREENS 1 /* Number of virtual screens to be used */ |
NirT | 0:c00e6c923941 | 85 | |
NirT | 0:c00e6c923941 | 86 | #define BK_COLOR GUI_DARKBLUE |
NirT | 0:c00e6c923941 | 87 | |
NirT | 0:c00e6c923941 | 88 | #undef GUI_NUM_LAYERS |
NirT | 0:c00e6c923941 | 89 | #define GUI_NUM_LAYERS 2 |
NirT | 0:c00e6c923941 | 90 | |
NirT | 0:c00e6c923941 | 91 | #define COLOR_CONVERSION_0 GUICC_M8888I |
NirT | 0:c00e6c923941 | 92 | #define DISPLAY_DRIVER_0 GUIDRV_LIN_32 |
NirT | 0:c00e6c923941 | 93 | |
NirT | 0:c00e6c923941 | 94 | |
NirT | 0:c00e6c923941 | 95 | #if (GUI_NUM_LAYERS > 1) |
NirT | 0:c00e6c923941 | 96 | #define COLOR_CONVERSION_1 GUICC_M1555I |
NirT | 0:c00e6c923941 | 97 | #define DISPLAY_DRIVER_1 GUIDRV_LIN_16 |
NirT | 0:c00e6c923941 | 98 | |
NirT | 0:c00e6c923941 | 99 | #endif |
NirT | 0:c00e6c923941 | 100 | |
NirT | 0:c00e6c923941 | 101 | #ifndef XSIZE_PHYS |
NirT | 0:c00e6c923941 | 102 | #error Physical X size of display is not defined! |
NirT | 0:c00e6c923941 | 103 | #endif |
NirT | 0:c00e6c923941 | 104 | #ifndef YSIZE_PHYS |
NirT | 0:c00e6c923941 | 105 | #error Physical Y size of display is not defined! |
NirT | 0:c00e6c923941 | 106 | #endif |
NirT | 0:c00e6c923941 | 107 | #ifndef NUM_VSCREENS |
NirT | 0:c00e6c923941 | 108 | #define NUM_VSCREENS 1 |
NirT | 0:c00e6c923941 | 109 | #else |
NirT | 0:c00e6c923941 | 110 | #if (NUM_VSCREENS <= 0) |
NirT | 0:c00e6c923941 | 111 | #error At least one screeen needs to be defined! |
NirT | 0:c00e6c923941 | 112 | #endif |
NirT | 0:c00e6c923941 | 113 | #endif |
NirT | 0:c00e6c923941 | 114 | #if (NUM_VSCREENS > 1) && (NUM_BUFFERS > 1) |
NirT | 0:c00e6c923941 | 115 | #error Virtual screens and multiple buffers are not allowed! |
NirT | 0:c00e6c923941 | 116 | #endif |
NirT | 0:c00e6c923941 | 117 | |
NirT | 0:c00e6c923941 | 118 | /* From SDRAM */ |
NirT | 0:c00e6c923941 | 119 | #define LCD_LAYER0_FRAME_BUFFER ((int)0xC0200000) |
NirT | 0:c00e6c923941 | 120 | #define LCD_LAYER1_FRAME_BUFFER ((int)0xC0400000) |
NirT | 0:c00e6c923941 | 121 | |
NirT | 0:c00e6c923941 | 122 | /** |
NirT | 0:c00e6c923941 | 123 | * @} |
NirT | 0:c00e6c923941 | 124 | */ |
NirT | 0:c00e6c923941 | 125 | |
NirT | 0:c00e6c923941 | 126 | |
NirT | 0:c00e6c923941 | 127 | /** @defgroup LCD CONFIGURATION_Private_Macros |
NirT | 0:c00e6c923941 | 128 | * @{ |
NirT | 0:c00e6c923941 | 129 | */ |
NirT | 0:c00e6c923941 | 130 | /** |
NirT | 0:c00e6c923941 | 131 | * @} |
NirT | 0:c00e6c923941 | 132 | */ |
NirT | 0:c00e6c923941 | 133 | |
NirT | 0:c00e6c923941 | 134 | |
NirT | 0:c00e6c923941 | 135 | /** @defgroup LCD CONFIGURATION_Private_Variables |
NirT | 0:c00e6c923941 | 136 | * @{ |
NirT | 0:c00e6c923941 | 137 | */ |
NirT | 0:c00e6c923941 | 138 | LTDC_HandleTypeDef hltdc; |
NirT | 0:c00e6c923941 | 139 | static LCD_LayerPropTypedef layer_prop[GUI_NUM_LAYERS]; |
NirT | 0:c00e6c923941 | 140 | |
NirT | 0:c00e6c923941 | 141 | static const LCD_API_COLOR_CONV * apColorConvAPI[] = |
NirT | 0:c00e6c923941 | 142 | { |
NirT | 0:c00e6c923941 | 143 | COLOR_CONVERSION_0, |
NirT | 0:c00e6c923941 | 144 | #if GUI_NUM_LAYERS > 1 |
NirT | 0:c00e6c923941 | 145 | COLOR_CONVERSION_1, |
NirT | 0:c00e6c923941 | 146 | #endif |
NirT | 0:c00e6c923941 | 147 | }; |
NirT | 0:c00e6c923941 | 148 | |
NirT | 0:c00e6c923941 | 149 | /** |
NirT | 0:c00e6c923941 | 150 | * @} |
NirT | 0:c00e6c923941 | 151 | */ |
NirT | 0:c00e6c923941 | 152 | |
NirT | 0:c00e6c923941 | 153 | /** @defgroup LCD CONFIGURATION_Private_FunctionPrototypes |
NirT | 0:c00e6c923941 | 154 | * @{ |
NirT | 0:c00e6c923941 | 155 | */ |
NirT | 0:c00e6c923941 | 156 | static void DMA2D_CopyBuffer(U32 LayerIndex, void * pSrc, void * pDst, U32 xSize, U32 ySize, U32 OffLineSrc, U32 OffLineDst); |
NirT | 0:c00e6c923941 | 157 | static void DMA2D_FillBuffer(U32 LayerIndex, void * pDst, U32 xSize, U32 ySize, U32 OffLine, U32 ColorIndex); |
NirT | 0:c00e6c923941 | 158 | |
NirT | 0:c00e6c923941 | 159 | static void LCD_LL_Init(void); |
NirT | 0:c00e6c923941 | 160 | static void LCD_LL_LayerInit(U32 LayerIndex); |
NirT | 0:c00e6c923941 | 161 | static void LCD_LL_CopyBuffer(int LayerIndex, int IndexSrc, int IndexDst); |
NirT | 0:c00e6c923941 | 162 | static void LCD_LL_CopyRect(int LayerIndex, int x0, int y0, int x1, int y1, int xSize, int ySize); |
NirT | 0:c00e6c923941 | 163 | static void LCD_LL_FillRect(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex); |
NirT | 0:c00e6c923941 | 164 | static void LCD_LL_DrawBitmap32bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine); |
NirT | 0:c00e6c923941 | 165 | |
NirT | 0:c00e6c923941 | 166 | static U32 GetBufferSize(U32 LayerIndex); |
NirT | 0:c00e6c923941 | 167 | /** |
NirT | 0:c00e6c923941 | 168 | * @} |
NirT | 0:c00e6c923941 | 169 | */ |
NirT | 0:c00e6c923941 | 170 | |
NirT | 0:c00e6c923941 | 171 | /** @defgroup LCD CONFIGURATION_Private_Functions |
NirT | 0:c00e6c923941 | 172 | * @{ |
NirT | 0:c00e6c923941 | 173 | */ |
NirT | 0:c00e6c923941 | 174 | /** |
NirT | 0:c00e6c923941 | 175 | * @brief Return Pixel format for a given layer |
NirT | 0:c00e6c923941 | 176 | * @param LayerIndex : Layer Index |
NirT | 0:c00e6c923941 | 177 | * @retval Status ( 0 : 0k , 1: error) |
NirT | 0:c00e6c923941 | 178 | */ |
NirT | 0:c00e6c923941 | 179 | static inline U32 LCD_LL_GetPixelformat(U32 LayerIndex) |
NirT | 0:c00e6c923941 | 180 | { |
NirT | 0:c00e6c923941 | 181 | if (LayerIndex == 0) |
NirT | 0:c00e6c923941 | 182 | { |
NirT | 0:c00e6c923941 | 183 | return LTDC_PIXEL_FORMAT_ARGB8888; |
NirT | 0:c00e6c923941 | 184 | } |
NirT | 0:c00e6c923941 | 185 | else |
NirT | 0:c00e6c923941 | 186 | { |
NirT | 0:c00e6c923941 | 187 | return LTDC_PIXEL_FORMAT_ARGB1555; |
NirT | 0:c00e6c923941 | 188 | } |
NirT | 0:c00e6c923941 | 189 | } |
NirT | 0:c00e6c923941 | 190 | |
NirT | 0:c00e6c923941 | 191 | /** |
NirT | 0:c00e6c923941 | 192 | * @brief LTDC MSP Initialization |
NirT | 0:c00e6c923941 | 193 | * This function configures the hardware resources used in this example: |
NirT | 0:c00e6c923941 | 194 | * - Peripheral's clock enable |
NirT | 0:c00e6c923941 | 195 | * - Peripheral's GPIO Configuration |
NirT | 0:c00e6c923941 | 196 | * @param hltdc: LTDC handle pointer |
NirT | 0:c00e6c923941 | 197 | * @retval None |
NirT | 0:c00e6c923941 | 198 | */ |
NirT | 0:c00e6c923941 | 199 | void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc) |
NirT | 0:c00e6c923941 | 200 | { |
NirT | 0:c00e6c923941 | 201 | GPIO_InitTypeDef gpio_init_structure; |
NirT | 0:c00e6c923941 | 202 | static RCC_PeriphCLKInitTypeDef PeriphClkInitStruct; |
NirT | 0:c00e6c923941 | 203 | |
NirT | 0:c00e6c923941 | 204 | /* Enable the LTDC clocks */ |
NirT | 0:c00e6c923941 | 205 | __HAL_RCC_LTDC_CLK_ENABLE(); |
NirT | 0:c00e6c923941 | 206 | |
NirT | 0:c00e6c923941 | 207 | |
NirT | 0:c00e6c923941 | 208 | /* LCD clock configuration */ |
NirT | 0:c00e6c923941 | 209 | /* PLLSAI_VCO Input = HSE_VALUE/PLL_M = 1 Mhz */ |
NirT | 0:c00e6c923941 | 210 | /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN = 429 Mhz */ |
NirT | 0:c00e6c923941 | 211 | /* PLLLCDCLK = PLLSAI_VCO Output/PLLSAIR = 429/5 = 85 Mhz */ |
NirT | 0:c00e6c923941 | 212 | /* LTDC clock frequency = PLLLCDCLK / LTDC_PLLSAI_DIVR_2 = 85/4 = 21 Mhz */ |
NirT | 0:c00e6c923941 | 213 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; |
NirT | 0:c00e6c923941 | 214 | PeriphClkInitStruct.PLLSAI.PLLSAIN = 192; |
NirT | 0:c00e6c923941 | 215 | PeriphClkInitStruct.PLLSAI.PLLSAIR = 5; |
NirT | 0:c00e6c923941 | 216 | PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4; |
NirT | 0:c00e6c923941 | 217 | HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct); |
NirT | 0:c00e6c923941 | 218 | |
NirT | 0:c00e6c923941 | 219 | |
NirT | 0:c00e6c923941 | 220 | /* Enable GPIOs clock */ |
NirT | 0:c00e6c923941 | 221 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
NirT | 0:c00e6c923941 | 222 | __HAL_RCC_GPIOG_CLK_ENABLE(); |
NirT | 0:c00e6c923941 | 223 | __HAL_RCC_GPIOI_CLK_ENABLE(); |
NirT | 0:c00e6c923941 | 224 | __HAL_RCC_GPIOJ_CLK_ENABLE(); |
NirT | 0:c00e6c923941 | 225 | __HAL_RCC_GPIOK_CLK_ENABLE(); |
NirT | 0:c00e6c923941 | 226 | |
NirT | 0:c00e6c923941 | 227 | /*** LTDC Pins configuration ***/ |
NirT | 0:c00e6c923941 | 228 | /* GPIOE configuration */ |
NirT | 0:c00e6c923941 | 229 | gpio_init_structure.Pin = GPIO_PIN_4; |
NirT | 0:c00e6c923941 | 230 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
NirT | 0:c00e6c923941 | 231 | gpio_init_structure.Pull = GPIO_NOPULL; |
NirT | 0:c00e6c923941 | 232 | gpio_init_structure.Speed = GPIO_SPEED_FAST; |
NirT | 0:c00e6c923941 | 233 | gpio_init_structure.Alternate = GPIO_AF14_LTDC; |
NirT | 0:c00e6c923941 | 234 | HAL_GPIO_Init(GPIOE, &gpio_init_structure); |
NirT | 0:c00e6c923941 | 235 | |
NirT | 0:c00e6c923941 | 236 | /* GPIOG configuration */ |
NirT | 0:c00e6c923941 | 237 | gpio_init_structure.Pin = GPIO_PIN_12; |
NirT | 0:c00e6c923941 | 238 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
NirT | 0:c00e6c923941 | 239 | gpio_init_structure.Alternate = GPIO_AF9_LTDC; |
NirT | 0:c00e6c923941 | 240 | HAL_GPIO_Init(GPIOG, &gpio_init_structure); |
NirT | 0:c00e6c923941 | 241 | |
NirT | 0:c00e6c923941 | 242 | /* GPIOI LTDC alternate configuration */ |
NirT | 0:c00e6c923941 | 243 | gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | \ |
NirT | 0:c00e6c923941 | 244 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; |
NirT | 0:c00e6c923941 | 245 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
NirT | 0:c00e6c923941 | 246 | gpio_init_structure.Alternate = GPIO_AF14_LTDC; |
NirT | 0:c00e6c923941 | 247 | HAL_GPIO_Init(GPIOI, &gpio_init_structure); |
NirT | 0:c00e6c923941 | 248 | |
NirT | 0:c00e6c923941 | 249 | /* GPIOJ configuration */ |
NirT | 0:c00e6c923941 | 250 | gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | \ |
NirT | 0:c00e6c923941 | 251 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7 | \ |
NirT | 0:c00e6c923941 | 252 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | \ |
NirT | 0:c00e6c923941 | 253 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; |
NirT | 0:c00e6c923941 | 254 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
NirT | 0:c00e6c923941 | 255 | gpio_init_structure.Alternate = GPIO_AF14_LTDC; |
NirT | 0:c00e6c923941 | 256 | HAL_GPIO_Init(GPIOJ, &gpio_init_structure); |
NirT | 0:c00e6c923941 | 257 | |
NirT | 0:c00e6c923941 | 258 | /* GPIOK configuration */ |
NirT | 0:c00e6c923941 | 259 | gpio_init_structure.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_4 | \ |
NirT | 0:c00e6c923941 | 260 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7; |
NirT | 0:c00e6c923941 | 261 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
NirT | 0:c00e6c923941 | 262 | gpio_init_structure.Alternate = GPIO_AF14_LTDC; |
NirT | 0:c00e6c923941 | 263 | HAL_GPIO_Init(GPIOK, &gpio_init_structure); |
NirT | 0:c00e6c923941 | 264 | |
NirT | 0:c00e6c923941 | 265 | /* LCD_DISP GPIO configuration */ |
NirT | 0:c00e6c923941 | 266 | gpio_init_structure.Pin = GPIO_PIN_12; /* LCD_DISP pin has to be manually controlled */ |
NirT | 0:c00e6c923941 | 267 | gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; |
NirT | 0:c00e6c923941 | 268 | HAL_GPIO_Init(GPIOI, &gpio_init_structure); |
NirT | 0:c00e6c923941 | 269 | |
NirT | 0:c00e6c923941 | 270 | /* LCD_BL_CTRL GPIO configuration */ |
NirT | 0:c00e6c923941 | 271 | gpio_init_structure.Pin = GPIO_PIN_3; /* LCD_BL_CTRL pin has to be manually controlled */ |
NirT | 0:c00e6c923941 | 272 | gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; |
NirT | 0:c00e6c923941 | 273 | HAL_GPIO_Init(GPIOK, &gpio_init_structure); |
NirT | 0:c00e6c923941 | 274 | |
NirT | 0:c00e6c923941 | 275 | /* Set LTDC Interrupt to the lowest priority */ |
NirT | 0:c00e6c923941 | 276 | HAL_NVIC_SetPriority(LTDC_IRQn, 0xE, 0); |
NirT | 0:c00e6c923941 | 277 | |
NirT | 0:c00e6c923941 | 278 | /* Enable LTDC Interrupt */ |
NirT | 0:c00e6c923941 | 279 | HAL_NVIC_EnableIRQ(LTDC_IRQn); |
NirT | 0:c00e6c923941 | 280 | } |
NirT | 0:c00e6c923941 | 281 | |
NirT | 0:c00e6c923941 | 282 | /** |
NirT | 0:c00e6c923941 | 283 | * @brief LTDC MSP De-Initialization |
NirT | 0:c00e6c923941 | 284 | * This function frees the hardware resources used in this example: |
NirT | 0:c00e6c923941 | 285 | * - Disable the Peripheral's clock |
NirT | 0:c00e6c923941 | 286 | * @param hltdc: LTDC handle pointer |
NirT | 0:c00e6c923941 | 287 | * @retval None |
NirT | 0:c00e6c923941 | 288 | */ |
NirT | 0:c00e6c923941 | 289 | void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef *hltdc) |
NirT | 0:c00e6c923941 | 290 | { |
NirT | 0:c00e6c923941 | 291 | /* Reset peripherals */ |
NirT | 0:c00e6c923941 | 292 | /* Enable LTDC reset state */ |
NirT | 0:c00e6c923941 | 293 | __HAL_RCC_LTDC_FORCE_RESET(); |
NirT | 0:c00e6c923941 | 294 | |
NirT | 0:c00e6c923941 | 295 | /* Release LTDC from reset state */ |
NirT | 0:c00e6c923941 | 296 | __HAL_RCC_LTDC_RELEASE_RESET(); |
NirT | 0:c00e6c923941 | 297 | } |
NirT | 0:c00e6c923941 | 298 | |
NirT | 0:c00e6c923941 | 299 | /** |
NirT | 0:c00e6c923941 | 300 | * @brief Line Event callback. |
NirT | 0:c00e6c923941 | 301 | * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains |
NirT | 0:c00e6c923941 | 302 | * the configuration information for the specified LTDC. |
NirT | 0:c00e6c923941 | 303 | * @retval None |
NirT | 0:c00e6c923941 | 304 | */ |
NirT | 0:c00e6c923941 | 305 | void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc) { |
NirT | 0:c00e6c923941 | 306 | U32 Addr; |
NirT | 0:c00e6c923941 | 307 | U32 layer; |
NirT | 0:c00e6c923941 | 308 | |
NirT | 0:c00e6c923941 | 309 | for (layer = 0; layer < GUI_NUM_LAYERS; layer++) |
NirT | 0:c00e6c923941 | 310 | { |
NirT | 0:c00e6c923941 | 311 | if (layer_prop[layer].pending_buffer >= 0) |
NirT | 0:c00e6c923941 | 312 | { |
NirT | 0:c00e6c923941 | 313 | /* Calculate address of buffer to be used as visible frame buffer */ |
NirT | 0:c00e6c923941 | 314 | Addr = layer_prop[layer].address + \ |
NirT | 0:c00e6c923941 | 315 | layer_prop[layer].xSize * layer_prop[layer].ySize * layer_prop[layer].pending_buffer * layer_prop[layer].BytesPerPixel; |
NirT | 0:c00e6c923941 | 316 | |
NirT | 0:c00e6c923941 | 317 | __HAL_LTDC_LAYER(hltdc, layer)->CFBAR = Addr; |
NirT | 0:c00e6c923941 | 318 | |
NirT | 0:c00e6c923941 | 319 | __HAL_LTDC_RELOAD_CONFIG(hltdc); |
NirT | 0:c00e6c923941 | 320 | |
NirT | 0:c00e6c923941 | 321 | /* Notify STemWin that buffer is used */ |
NirT | 0:c00e6c923941 | 322 | GUI_MULTIBUF_ConfirmEx(layer, layer_prop[layer].pending_buffer); |
NirT | 0:c00e6c923941 | 323 | |
NirT | 0:c00e6c923941 | 324 | /* Clear pending buffer flag of layer */ |
NirT | 0:c00e6c923941 | 325 | layer_prop[layer].pending_buffer = -1; |
NirT | 0:c00e6c923941 | 326 | } |
NirT | 0:c00e6c923941 | 327 | } |
NirT | 0:c00e6c923941 | 328 | |
NirT | 0:c00e6c923941 | 329 | HAL_LTDC_ProgramLineEvent(hltdc, 0); |
NirT | 0:c00e6c923941 | 330 | } |
NirT | 0:c00e6c923941 | 331 | |
NirT | 0:c00e6c923941 | 332 | /******************************************************************************* |
NirT | 0:c00e6c923941 | 333 | Display configuration |
NirT | 0:c00e6c923941 | 334 | *******************************************************************************/ |
NirT | 0:c00e6c923941 | 335 | /** |
NirT | 0:c00e6c923941 | 336 | * @brief Called during the initialization process in order to set up the |
NirT | 0:c00e6c923941 | 337 | * display driver configuration |
NirT | 0:c00e6c923941 | 338 | * @param None |
NirT | 0:c00e6c923941 | 339 | * @retval None |
NirT | 0:c00e6c923941 | 340 | */ |
NirT | 0:c00e6c923941 | 341 | void LCD_X_Config(void) |
NirT | 0:c00e6c923941 | 342 | { |
NirT | 0:c00e6c923941 | 343 | U32 i; |
NirT | 0:c00e6c923941 | 344 | |
NirT | 0:c00e6c923941 | 345 | LCD_LL_Init (); |
NirT | 0:c00e6c923941 | 346 | |
NirT | 0:c00e6c923941 | 347 | /* At first initialize use of multiple buffers on demand */ |
NirT | 0:c00e6c923941 | 348 | #if (NUM_BUFFERS > 1) |
NirT | 0:c00e6c923941 | 349 | for (i = 0; i < GUI_NUM_LAYERS; i++) |
NirT | 0:c00e6c923941 | 350 | { |
NirT | 0:c00e6c923941 | 351 | GUI_MULTIBUF_ConfigEx(i, NUM_BUFFERS); |
NirT | 0:c00e6c923941 | 352 | } |
NirT | 0:c00e6c923941 | 353 | #endif |
NirT | 0:c00e6c923941 | 354 | |
NirT | 0:c00e6c923941 | 355 | /* Set display driver and color conversion for 1st layer */ |
NirT | 0:c00e6c923941 | 356 | GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER_0, COLOR_CONVERSION_0, 0, 0); |
NirT | 0:c00e6c923941 | 357 | |
NirT | 0:c00e6c923941 | 358 | /* Set size of 1st layer */ |
NirT | 0:c00e6c923941 | 359 | if (LCD_GetSwapXYEx(0)) { |
NirT | 0:c00e6c923941 | 360 | LCD_SetSizeEx (0, YSIZE_PHYS, XSIZE_PHYS); |
NirT | 0:c00e6c923941 | 361 | LCD_SetVSizeEx(0, YSIZE_PHYS * NUM_VSCREENS, XSIZE_PHYS); |
NirT | 0:c00e6c923941 | 362 | } else { |
NirT | 0:c00e6c923941 | 363 | LCD_SetSizeEx (0, XSIZE_PHYS, YSIZE_PHYS); |
NirT | 0:c00e6c923941 | 364 | LCD_SetVSizeEx(0, XSIZE_PHYS, YSIZE_PHYS * NUM_VSCREENS); |
NirT | 0:c00e6c923941 | 365 | } |
NirT | 0:c00e6c923941 | 366 | #if (GUI_NUM_LAYERS > 1) |
NirT | 0:c00e6c923941 | 367 | |
NirT | 0:c00e6c923941 | 368 | /* Set display driver and color conversion for 2nd layer */ |
NirT | 0:c00e6c923941 | 369 | GUI_DEVICE_CreateAndLink(DISPLAY_DRIVER_1, COLOR_CONVERSION_1, 0, 1); |
NirT | 0:c00e6c923941 | 370 | |
NirT | 0:c00e6c923941 | 371 | /* Set size of 2nd layer */ |
NirT | 0:c00e6c923941 | 372 | if (LCD_GetSwapXYEx(1)) { |
NirT | 0:c00e6c923941 | 373 | LCD_SetSizeEx (1, YSIZE_PHYS, XSIZE_PHYS); |
NirT | 0:c00e6c923941 | 374 | LCD_SetVSizeEx(1, YSIZE_PHYS * NUM_VSCREENS, XSIZE_PHYS); |
NirT | 0:c00e6c923941 | 375 | } else { |
NirT | 0:c00e6c923941 | 376 | LCD_SetSizeEx (1, XSIZE_PHYS, YSIZE_PHYS); |
NirT | 0:c00e6c923941 | 377 | LCD_SetVSizeEx(1, XSIZE_PHYS, YSIZE_PHYS * NUM_VSCREENS); |
NirT | 0:c00e6c923941 | 378 | } |
NirT | 0:c00e6c923941 | 379 | #endif |
NirT | 0:c00e6c923941 | 380 | |
NirT | 0:c00e6c923941 | 381 | |
NirT | 0:c00e6c923941 | 382 | /*Initialize GUI Layer structure */ |
NirT | 0:c00e6c923941 | 383 | layer_prop[0].address = LCD_LAYER0_FRAME_BUFFER; |
NirT | 0:c00e6c923941 | 384 | |
NirT | 0:c00e6c923941 | 385 | #if (GUI_NUM_LAYERS > 1) |
NirT | 0:c00e6c923941 | 386 | layer_prop[1].address = LCD_LAYER1_FRAME_BUFFER; |
NirT | 0:c00e6c923941 | 387 | #endif |
NirT | 0:c00e6c923941 | 388 | |
NirT | 0:c00e6c923941 | 389 | /* Setting up VRam address and LCD_LL functions for CopyBuffer-, CopyRect- and FillRect operations */ |
NirT | 0:c00e6c923941 | 390 | for (i = 0; i < GUI_NUM_LAYERS; i++) |
NirT | 0:c00e6c923941 | 391 | { |
NirT | 0:c00e6c923941 | 392 | |
NirT | 0:c00e6c923941 | 393 | layer_prop[i].pColorConvAPI = (LCD_API_COLOR_CONV *)apColorConvAPI[i]; |
NirT | 0:c00e6c923941 | 394 | |
NirT | 0:c00e6c923941 | 395 | layer_prop[i].pending_buffer = -1; |
NirT | 0:c00e6c923941 | 396 | |
NirT | 0:c00e6c923941 | 397 | /* Set VRAM address */ |
NirT | 0:c00e6c923941 | 398 | LCD_SetVRAMAddrEx(i, (void *)(layer_prop[i].address)); |
NirT | 0:c00e6c923941 | 399 | |
NirT | 0:c00e6c923941 | 400 | /* Remember color depth for further operations */ |
NirT | 0:c00e6c923941 | 401 | layer_prop[i].BytesPerPixel = LCD_GetBitsPerPixelEx(i) >> 3; |
NirT | 0:c00e6c923941 | 402 | |
NirT | 0:c00e6c923941 | 403 | /* Set LCD_LL functions for several operations */ |
NirT | 0:c00e6c923941 | 404 | LCD_SetDevFunc(i, LCD_DEVFUNC_COPYBUFFER, (void(*)(void))LCD_LL_CopyBuffer); |
NirT | 0:c00e6c923941 | 405 | LCD_SetDevFunc(i, LCD_DEVFUNC_COPYRECT, (void(*)(void))LCD_LL_CopyRect); |
NirT | 0:c00e6c923941 | 406 | LCD_SetDevFunc(i, LCD_DEVFUNC_FILLRECT, (void(*)(void))LCD_LL_FillRect); |
NirT | 0:c00e6c923941 | 407 | |
NirT | 0:c00e6c923941 | 408 | /* Set up drawing routine for 32bpp bitmap using DMA2D */ |
NirT | 0:c00e6c923941 | 409 | if (LCD_LL_GetPixelformat(i) == LTDC_PIXEL_FORMAT_ARGB8888) { |
NirT | 0:c00e6c923941 | 410 | LCD_SetDevFunc(i, LCD_DEVFUNC_DRAWBMP_32BPP, (void(*)(void))LCD_LL_DrawBitmap32bpp); /* Set up drawing routine for 32bpp bitmap using DMA2D. Makes only sense with ARGB8888 */ |
NirT | 0:c00e6c923941 | 411 | } |
NirT | 0:c00e6c923941 | 412 | } |
NirT | 0:c00e6c923941 | 413 | } |
NirT | 0:c00e6c923941 | 414 | |
NirT | 0:c00e6c923941 | 415 | /** |
NirT | 0:c00e6c923941 | 416 | * @brief This function is called by the display driver for several purposes. |
NirT | 0:c00e6c923941 | 417 | * To support the according task the routine needs to be adapted to |
NirT | 0:c00e6c923941 | 418 | * the display controller. Please note that the commands marked with |
NirT | 0:c00e6c923941 | 419 | * 'optional' are not cogently required and should only be adapted if |
NirT | 0:c00e6c923941 | 420 | * the display controller supports these features |
NirT | 0:c00e6c923941 | 421 | * @param LayerIndex: Index of layer to be configured |
NirT | 0:c00e6c923941 | 422 | * @param Cmd :Please refer to the details in the switch statement below |
NirT | 0:c00e6c923941 | 423 | * @param pData :Pointer to a LCD_X_DATA structure |
NirT | 0:c00e6c923941 | 424 | * @retval Status (-1 : Error, 0 : Ok) |
NirT | 0:c00e6c923941 | 425 | */ |
NirT | 0:c00e6c923941 | 426 | int LCD_X_DisplayDriver(unsigned LayerIndex, unsigned Cmd, void * pData) |
NirT | 0:c00e6c923941 | 427 | { |
NirT | 0:c00e6c923941 | 428 | int r = 0; |
NirT | 0:c00e6c923941 | 429 | U32 addr; |
NirT | 0:c00e6c923941 | 430 | int xPos, yPos; |
NirT | 0:c00e6c923941 | 431 | U32 Color; |
NirT | 0:c00e6c923941 | 432 | |
NirT | 0:c00e6c923941 | 433 | switch (Cmd) |
NirT | 0:c00e6c923941 | 434 | { |
NirT | 0:c00e6c923941 | 435 | case LCD_X_INITCONTROLLER: |
NirT | 0:c00e6c923941 | 436 | LCD_LL_LayerInit(LayerIndex); |
NirT | 0:c00e6c923941 | 437 | break; |
NirT | 0:c00e6c923941 | 438 | |
NirT | 0:c00e6c923941 | 439 | case LCD_X_SETORG: |
NirT | 0:c00e6c923941 | 440 | addr = layer_prop[LayerIndex].address + ((LCD_X_SETORG_INFO *)pData)->yPos * layer_prop[LayerIndex].xSize * layer_prop[LayerIndex].BytesPerPixel; |
NirT | 0:c00e6c923941 | 441 | HAL_LTDC_SetAddress(&hltdc, addr, LayerIndex); |
NirT | 0:c00e6c923941 | 442 | break; |
NirT | 0:c00e6c923941 | 443 | |
NirT | 0:c00e6c923941 | 444 | case LCD_X_SHOWBUFFER: |
NirT | 0:c00e6c923941 | 445 | layer_prop[LayerIndex].pending_buffer = ((LCD_X_SHOWBUFFER_INFO *)pData)->Index; |
NirT | 0:c00e6c923941 | 446 | break; |
NirT | 0:c00e6c923941 | 447 | |
NirT | 0:c00e6c923941 | 448 | case LCD_X_SETLUTENTRY: |
NirT | 0:c00e6c923941 | 449 | HAL_LTDC_ConfigCLUT(&hltdc, (uint32_t *)&(((LCD_X_SETLUTENTRY_INFO *)pData)->Color), 1, LayerIndex); |
NirT | 0:c00e6c923941 | 450 | break; |
NirT | 0:c00e6c923941 | 451 | |
NirT | 0:c00e6c923941 | 452 | case LCD_X_ON: |
NirT | 0:c00e6c923941 | 453 | __HAL_LTDC_ENABLE(&hltdc); |
NirT | 0:c00e6c923941 | 454 | break; |
NirT | 0:c00e6c923941 | 455 | |
NirT | 0:c00e6c923941 | 456 | case LCD_X_OFF: |
NirT | 0:c00e6c923941 | 457 | __HAL_LTDC_DISABLE(&hltdc); |
NirT | 0:c00e6c923941 | 458 | break; |
NirT | 0:c00e6c923941 | 459 | |
NirT | 0:c00e6c923941 | 460 | case LCD_X_SETVIS: |
NirT | 0:c00e6c923941 | 461 | if(((LCD_X_SETVIS_INFO *)pData)->OnOff == ENABLE ) |
NirT | 0:c00e6c923941 | 462 | { |
NirT | 0:c00e6c923941 | 463 | __HAL_LTDC_LAYER_ENABLE(&hltdc, LayerIndex); |
NirT | 0:c00e6c923941 | 464 | } |
NirT | 0:c00e6c923941 | 465 | else |
NirT | 0:c00e6c923941 | 466 | { |
NirT | 0:c00e6c923941 | 467 | __HAL_LTDC_LAYER_DISABLE(&hltdc, LayerIndex); |
NirT | 0:c00e6c923941 | 468 | } |
NirT | 0:c00e6c923941 | 469 | __HAL_LTDC_RELOAD_CONFIG(&hltdc); |
NirT | 0:c00e6c923941 | 470 | break; |
NirT | 0:c00e6c923941 | 471 | |
NirT | 0:c00e6c923941 | 472 | case LCD_X_SETPOS: |
NirT | 0:c00e6c923941 | 473 | HAL_LTDC_SetWindowPosition(&hltdc, |
NirT | 0:c00e6c923941 | 474 | ((LCD_X_SETPOS_INFO *)pData)->xPos, |
NirT | 0:c00e6c923941 | 475 | ((LCD_X_SETPOS_INFO *)pData)->yPos, |
NirT | 0:c00e6c923941 | 476 | LayerIndex); |
NirT | 0:c00e6c923941 | 477 | break; |
NirT | 0:c00e6c923941 | 478 | |
NirT | 0:c00e6c923941 | 479 | case LCD_X_SETSIZE: |
NirT | 0:c00e6c923941 | 480 | GUI_GetLayerPosEx(LayerIndex, &xPos, &yPos); |
NirT | 0:c00e6c923941 | 481 | layer_prop[LayerIndex].xSize = ((LCD_X_SETSIZE_INFO *)pData)->xSize; |
NirT | 0:c00e6c923941 | 482 | layer_prop[LayerIndex].ySize = ((LCD_X_SETSIZE_INFO *)pData)->ySize; |
NirT | 0:c00e6c923941 | 483 | HAL_LTDC_SetWindowPosition(&hltdc, xPos, yPos, LayerIndex); |
NirT | 0:c00e6c923941 | 484 | break; |
NirT | 0:c00e6c923941 | 485 | |
NirT | 0:c00e6c923941 | 486 | case LCD_X_SETALPHA: |
NirT | 0:c00e6c923941 | 487 | HAL_LTDC_SetAlpha(&hltdc, ((LCD_X_SETALPHA_INFO *)pData)->Alpha, LayerIndex); |
NirT | 0:c00e6c923941 | 488 | break; |
NirT | 0:c00e6c923941 | 489 | |
NirT | 0:c00e6c923941 | 490 | case LCD_X_SETCHROMAMODE: |
NirT | 0:c00e6c923941 | 491 | if(((LCD_X_SETCHROMAMODE_INFO *)pData)->ChromaMode != 0) |
NirT | 0:c00e6c923941 | 492 | { |
NirT | 0:c00e6c923941 | 493 | HAL_LTDC_EnableColorKeying(&hltdc, LayerIndex); |
NirT | 0:c00e6c923941 | 494 | } |
NirT | 0:c00e6c923941 | 495 | else |
NirT | 0:c00e6c923941 | 496 | { |
NirT | 0:c00e6c923941 | 497 | HAL_LTDC_DisableColorKeying(&hltdc, LayerIndex); |
NirT | 0:c00e6c923941 | 498 | } |
NirT | 0:c00e6c923941 | 499 | break; |
NirT | 0:c00e6c923941 | 500 | |
NirT | 0:c00e6c923941 | 501 | case LCD_X_SETCHROMA: |
NirT | 0:c00e6c923941 | 502 | |
NirT | 0:c00e6c923941 | 503 | Color = ((((LCD_X_SETCHROMA_INFO *)pData)->ChromaMin & 0xFF0000) >> 16) |\ |
NirT | 0:c00e6c923941 | 504 | (((LCD_X_SETCHROMA_INFO *)pData)->ChromaMin & 0x00FF00) |\ |
NirT | 0:c00e6c923941 | 505 | ((((LCD_X_SETCHROMA_INFO *)pData)->ChromaMin & 0x0000FF) << 16); |
NirT | 0:c00e6c923941 | 506 | |
NirT | 0:c00e6c923941 | 507 | HAL_LTDC_ConfigColorKeying(&hltdc, Color, LayerIndex); |
NirT | 0:c00e6c923941 | 508 | break; |
NirT | 0:c00e6c923941 | 509 | |
NirT | 0:c00e6c923941 | 510 | default: |
NirT | 0:c00e6c923941 | 511 | r = -1; |
NirT | 0:c00e6c923941 | 512 | } |
NirT | 0:c00e6c923941 | 513 | return r; |
NirT | 0:c00e6c923941 | 514 | } |
NirT | 0:c00e6c923941 | 515 | |
NirT | 0:c00e6c923941 | 516 | /** |
NirT | 0:c00e6c923941 | 517 | * @brief Initialize the LCD Controller. |
NirT | 0:c00e6c923941 | 518 | * @param LayerIndex : layer Index. |
NirT | 0:c00e6c923941 | 519 | * @retval None |
NirT | 0:c00e6c923941 | 520 | */ |
NirT | 0:c00e6c923941 | 521 | static void LCD_LL_LayerInit(U32 LayerIndex) |
NirT | 0:c00e6c923941 | 522 | { |
NirT | 0:c00e6c923941 | 523 | LTDC_LayerCfgTypeDef layer_cfg; |
NirT | 0:c00e6c923941 | 524 | |
NirT | 0:c00e6c923941 | 525 | if (LayerIndex < GUI_NUM_LAYERS) |
NirT | 0:c00e6c923941 | 526 | { |
NirT | 0:c00e6c923941 | 527 | /* Layer configuration */ |
NirT | 0:c00e6c923941 | 528 | layer_cfg.WindowX0 = 0; |
NirT | 0:c00e6c923941 | 529 | layer_cfg.WindowX1 = XSIZE_PHYS; |
NirT | 0:c00e6c923941 | 530 | layer_cfg.WindowY0 = 0; |
NirT | 0:c00e6c923941 | 531 | layer_cfg.WindowY1 = YSIZE_PHYS; |
NirT | 0:c00e6c923941 | 532 | layer_cfg.PixelFormat = LCD_LL_GetPixelformat(LayerIndex); |
NirT | 0:c00e6c923941 | 533 | layer_cfg.FBStartAdress = layer_prop[LayerIndex].address; |
NirT | 0:c00e6c923941 | 534 | layer_cfg.Alpha = 255; |
NirT | 0:c00e6c923941 | 535 | layer_cfg.Alpha0 = 0; |
NirT | 0:c00e6c923941 | 536 | layer_cfg.Backcolor.Blue = 0; |
NirT | 0:c00e6c923941 | 537 | layer_cfg.Backcolor.Green = 0; |
NirT | 0:c00e6c923941 | 538 | layer_cfg.Backcolor.Red = 0; |
NirT | 0:c00e6c923941 | 539 | layer_cfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; |
NirT | 0:c00e6c923941 | 540 | layer_cfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; |
NirT | 0:c00e6c923941 | 541 | layer_cfg.ImageWidth = XSIZE_PHYS; |
NirT | 0:c00e6c923941 | 542 | layer_cfg.ImageHeight = YSIZE_PHYS; |
NirT | 0:c00e6c923941 | 543 | HAL_LTDC_ConfigLayer(&hltdc, &layer_cfg, LayerIndex); |
NirT | 0:c00e6c923941 | 544 | |
NirT | 0:c00e6c923941 | 545 | /* Enable LUT on demand */ |
NirT | 0:c00e6c923941 | 546 | if (LCD_GetBitsPerPixelEx(LayerIndex) <= 8) |
NirT | 0:c00e6c923941 | 547 | { |
NirT | 0:c00e6c923941 | 548 | /* Enable usage of LUT for all modes with <= 8bpp*/ |
NirT | 0:c00e6c923941 | 549 | HAL_LTDC_EnableCLUT(&hltdc, LayerIndex); |
NirT | 0:c00e6c923941 | 550 | } |
NirT | 0:c00e6c923941 | 551 | } |
NirT | 0:c00e6c923941 | 552 | } |
NirT | 0:c00e6c923941 | 553 | |
NirT | 0:c00e6c923941 | 554 | /** |
NirT | 0:c00e6c923941 | 555 | * @brief Initialize the LCD Controller. |
NirT | 0:c00e6c923941 | 556 | * @param LayerIndex : layer Index. |
NirT | 0:c00e6c923941 | 557 | * @retval None |
NirT | 0:c00e6c923941 | 558 | */ |
NirT | 0:c00e6c923941 | 559 | static void LCD_LL_Init(void) |
NirT | 0:c00e6c923941 | 560 | { |
NirT | 0:c00e6c923941 | 561 | /* DeInit */ |
NirT | 0:c00e6c923941 | 562 | HAL_LTDC_DeInit(&hltdc); |
NirT | 0:c00e6c923941 | 563 | |
NirT | 0:c00e6c923941 | 564 | /* Set LCD Timings */ |
NirT | 0:c00e6c923941 | 565 | hltdc.Init.HorizontalSync = (HSYNC - 1); |
NirT | 0:c00e6c923941 | 566 | hltdc.Init.VerticalSync = (VSYNC - 1); |
NirT | 0:c00e6c923941 | 567 | hltdc.Init.AccumulatedHBP = (HSYNC + HBP - 1); |
NirT | 0:c00e6c923941 | 568 | hltdc.Init.AccumulatedVBP = (VSYNC + VBP - 1); |
NirT | 0:c00e6c923941 | 569 | hltdc.Init.AccumulatedActiveH = (YSIZE_PHYS + VSYNC + VBP - 1); |
NirT | 0:c00e6c923941 | 570 | hltdc.Init.AccumulatedActiveW = (XSIZE_PHYS + HSYNC + HBP - 1); |
NirT | 0:c00e6c923941 | 571 | hltdc.Init.TotalHeigh = (YSIZE_PHYS + VSYNC + VBP + VFP - 1); |
NirT | 0:c00e6c923941 | 572 | hltdc.Init.TotalWidth = (XSIZE_PHYS + HSYNC + HBP + HFP - 1); |
NirT | 0:c00e6c923941 | 573 | |
NirT | 0:c00e6c923941 | 574 | /* background value */ |
NirT | 0:c00e6c923941 | 575 | hltdc.Init.Backcolor.Blue = 0; |
NirT | 0:c00e6c923941 | 576 | hltdc.Init.Backcolor.Green = 0; |
NirT | 0:c00e6c923941 | 577 | hltdc.Init.Backcolor.Red = 0; |
NirT | 0:c00e6c923941 | 578 | |
NirT | 0:c00e6c923941 | 579 | /* Polarity */ |
NirT | 0:c00e6c923941 | 580 | hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL; |
NirT | 0:c00e6c923941 | 581 | hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL; |
NirT | 0:c00e6c923941 | 582 | hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL; |
NirT | 0:c00e6c923941 | 583 | hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC; |
NirT | 0:c00e6c923941 | 584 | hltdc.Instance = LTDC; |
NirT | 0:c00e6c923941 | 585 | |
NirT | 0:c00e6c923941 | 586 | HAL_LTDC_Init(&hltdc); |
NirT | 0:c00e6c923941 | 587 | HAL_LTDC_ProgramLineEvent(&hltdc, 0); |
NirT | 0:c00e6c923941 | 588 | |
NirT | 0:c00e6c923941 | 589 | /* Enable dithering */ |
NirT | 0:c00e6c923941 | 590 | HAL_LTDC_EnableDither(&hltdc); |
NirT | 0:c00e6c923941 | 591 | |
NirT | 0:c00e6c923941 | 592 | /* Enable DMA2D */ |
NirT | 0:c00e6c923941 | 593 | __HAL_RCC_DMA2D_CLK_ENABLE(); |
NirT | 0:c00e6c923941 | 594 | |
NirT | 0:c00e6c923941 | 595 | /* Assert display enable LCD_DISP pin */ |
NirT | 0:c00e6c923941 | 596 | HAL_GPIO_WritePin(GPIOI, GPIO_PIN_12, GPIO_PIN_SET); |
NirT | 0:c00e6c923941 | 597 | |
NirT | 0:c00e6c923941 | 598 | /* Assert backlight LCD_BL_CTRL pin */ |
NirT | 0:c00e6c923941 | 599 | HAL_GPIO_WritePin(GPIOK, GPIO_PIN_3, GPIO_PIN_SET); |
NirT | 0:c00e6c923941 | 600 | |
NirT | 0:c00e6c923941 | 601 | } |
NirT | 0:c00e6c923941 | 602 | |
NirT | 0:c00e6c923941 | 603 | |
NirT | 0:c00e6c923941 | 604 | /** |
NirT | 0:c00e6c923941 | 605 | * @brief Return Pixel format for a given layer |
NirT | 0:c00e6c923941 | 606 | * @param LayerIndex : Layer Index |
NirT | 0:c00e6c923941 | 607 | * @retval Status ( 0 : 0k , 1: error) |
NirT | 0:c00e6c923941 | 608 | */ |
NirT | 0:c00e6c923941 | 609 | static void DMA2D_CopyBuffer(U32 LayerIndex, void * pSrc, void * pDst, U32 xSize, U32 ySize, U32 OffLineSrc, U32 OffLineDst) |
NirT | 0:c00e6c923941 | 610 | { |
NirT | 0:c00e6c923941 | 611 | U32 PixelFormat; |
NirT | 0:c00e6c923941 | 612 | |
NirT | 0:c00e6c923941 | 613 | PixelFormat = LCD_LL_GetPixelformat(LayerIndex); |
NirT | 0:c00e6c923941 | 614 | DMA2D->CR = 0x00000000UL | (1 << 9); |
NirT | 0:c00e6c923941 | 615 | |
NirT | 0:c00e6c923941 | 616 | /* Set up pointers */ |
NirT | 0:c00e6c923941 | 617 | DMA2D->FGMAR = (U32)pSrc; |
NirT | 0:c00e6c923941 | 618 | DMA2D->OMAR = (U32)pDst; |
NirT | 0:c00e6c923941 | 619 | DMA2D->FGOR = OffLineSrc; |
NirT | 0:c00e6c923941 | 620 | DMA2D->OOR = OffLineDst; |
NirT | 0:c00e6c923941 | 621 | |
NirT | 0:c00e6c923941 | 622 | /* Set up pixel format */ |
NirT | 0:c00e6c923941 | 623 | DMA2D->FGPFCCR = PixelFormat; |
NirT | 0:c00e6c923941 | 624 | |
NirT | 0:c00e6c923941 | 625 | /* Set up size */ |
NirT | 0:c00e6c923941 | 626 | DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize; |
NirT | 0:c00e6c923941 | 627 | |
NirT | 0:c00e6c923941 | 628 | DMA2D->CR |= DMA2D_CR_START; |
NirT | 0:c00e6c923941 | 629 | |
NirT | 0:c00e6c923941 | 630 | /* Wait until transfer is done */ |
NirT | 0:c00e6c923941 | 631 | while (DMA2D->CR & DMA2D_CR_START) |
NirT | 0:c00e6c923941 | 632 | { |
NirT | 0:c00e6c923941 | 633 | } |
NirT | 0:c00e6c923941 | 634 | } |
NirT | 0:c00e6c923941 | 635 | |
NirT | 0:c00e6c923941 | 636 | /** |
NirT | 0:c00e6c923941 | 637 | * @brief Fill Buffer |
NirT | 0:c00e6c923941 | 638 | * @param LayerIndex : Layer Index |
NirT | 0:c00e6c923941 | 639 | * @param pDst: pointer to destination |
NirT | 0:c00e6c923941 | 640 | * @param xSize: X size |
NirT | 0:c00e6c923941 | 641 | * @param ySize: Y size |
NirT | 0:c00e6c923941 | 642 | * @param OffLine: offset after each line |
NirT | 0:c00e6c923941 | 643 | * @param ColorIndex: color to be used. |
NirT | 0:c00e6c923941 | 644 | * @retval None. |
NirT | 0:c00e6c923941 | 645 | */ |
NirT | 0:c00e6c923941 | 646 | static void DMA2D_FillBuffer(U32 LayerIndex, void * pDst, U32 xSize, U32 ySize, U32 OffLine, U32 ColorIndex) |
NirT | 0:c00e6c923941 | 647 | { |
NirT | 0:c00e6c923941 | 648 | |
NirT | 0:c00e6c923941 | 649 | U32 PixelFormat; |
NirT | 0:c00e6c923941 | 650 | |
NirT | 0:c00e6c923941 | 651 | PixelFormat = LCD_LL_GetPixelformat(LayerIndex); |
NirT | 0:c00e6c923941 | 652 | |
NirT | 0:c00e6c923941 | 653 | /* Set up mode */ |
NirT | 0:c00e6c923941 | 654 | DMA2D->CR = 0x00030000UL | (1 << 9); |
NirT | 0:c00e6c923941 | 655 | DMA2D->OCOLR = ColorIndex; |
NirT | 0:c00e6c923941 | 656 | |
NirT | 0:c00e6c923941 | 657 | /* Set up pointers */ |
NirT | 0:c00e6c923941 | 658 | DMA2D->OMAR = (U32)pDst; |
NirT | 0:c00e6c923941 | 659 | |
NirT | 0:c00e6c923941 | 660 | /* Set up offsets */ |
NirT | 0:c00e6c923941 | 661 | DMA2D->OOR = OffLine; |
NirT | 0:c00e6c923941 | 662 | |
NirT | 0:c00e6c923941 | 663 | /* Set up pixel format */ |
NirT | 0:c00e6c923941 | 664 | DMA2D->OPFCCR = PixelFormat; |
NirT | 0:c00e6c923941 | 665 | |
NirT | 0:c00e6c923941 | 666 | /* Set up size */ |
NirT | 0:c00e6c923941 | 667 | DMA2D->NLR = (U32)(xSize << 16) | (U16)ySize; |
NirT | 0:c00e6c923941 | 668 | |
NirT | 0:c00e6c923941 | 669 | DMA2D->CR |= DMA2D_CR_START; |
NirT | 0:c00e6c923941 | 670 | |
NirT | 0:c00e6c923941 | 671 | /* Wait until transfer is done */ |
NirT | 0:c00e6c923941 | 672 | while (DMA2D->CR & DMA2D_CR_START) |
NirT | 0:c00e6c923941 | 673 | { |
NirT | 0:c00e6c923941 | 674 | } |
NirT | 0:c00e6c923941 | 675 | } |
NirT | 0:c00e6c923941 | 676 | |
NirT | 0:c00e6c923941 | 677 | |
NirT | 0:c00e6c923941 | 678 | /** |
NirT | 0:c00e6c923941 | 679 | * @brief Get buffer size |
NirT | 0:c00e6c923941 | 680 | * @param LayerIndex : Layer Index |
NirT | 0:c00e6c923941 | 681 | * @retval None. |
NirT | 0:c00e6c923941 | 682 | */ |
NirT | 0:c00e6c923941 | 683 | static U32 GetBufferSize(U32 LayerIndex) |
NirT | 0:c00e6c923941 | 684 | { |
NirT | 0:c00e6c923941 | 685 | U32 BufferSize; |
NirT | 0:c00e6c923941 | 686 | |
NirT | 0:c00e6c923941 | 687 | BufferSize = layer_prop[LayerIndex].xSize * layer_prop[LayerIndex].ySize * layer_prop[LayerIndex].BytesPerPixel; |
NirT | 0:c00e6c923941 | 688 | return BufferSize; |
NirT | 0:c00e6c923941 | 689 | } |
NirT | 0:c00e6c923941 | 690 | |
NirT | 0:c00e6c923941 | 691 | /** |
NirT | 0:c00e6c923941 | 692 | * @brief LCD_LLized copy buffer |
NirT | 0:c00e6c923941 | 693 | * @param LayerIndex : Layer Index |
NirT | 0:c00e6c923941 | 694 | * @param IndexSrc: index source |
NirT | 0:c00e6c923941 | 695 | * @param IndexDst: index destination |
NirT | 0:c00e6c923941 | 696 | * @retval None. |
NirT | 0:c00e6c923941 | 697 | */ |
NirT | 0:c00e6c923941 | 698 | static void LCD_LL_CopyBuffer(int LayerIndex, int IndexSrc, int IndexDst) { |
NirT | 0:c00e6c923941 | 699 | U32 BufferSize, AddrSrc, AddrDst; |
NirT | 0:c00e6c923941 | 700 | |
NirT | 0:c00e6c923941 | 701 | BufferSize = GetBufferSize(LayerIndex); |
NirT | 0:c00e6c923941 | 702 | AddrSrc = layer_prop[LayerIndex].address + BufferSize * IndexSrc; |
NirT | 0:c00e6c923941 | 703 | AddrDst = layer_prop[LayerIndex].address + BufferSize * IndexDst; |
NirT | 0:c00e6c923941 | 704 | DMA2D_CopyBuffer(LayerIndex, (void *)AddrSrc, (void *)AddrDst, layer_prop[LayerIndex].xSize, layer_prop[LayerIndex].ySize, 0, 0); |
NirT | 0:c00e6c923941 | 705 | layer_prop[LayerIndex].buffer_index = IndexDst; |
NirT | 0:c00e6c923941 | 706 | } |
NirT | 0:c00e6c923941 | 707 | |
NirT | 0:c00e6c923941 | 708 | /** |
NirT | 0:c00e6c923941 | 709 | * @brief Copy rectangle |
NirT | 0:c00e6c923941 | 710 | * @param LayerIndex : Layer Index |
NirT | 0:c00e6c923941 | 711 | * @param x0: X0 position |
NirT | 0:c00e6c923941 | 712 | * @param y0: Y0 position |
NirT | 0:c00e6c923941 | 713 | * @param x1: X1 position |
NirT | 0:c00e6c923941 | 714 | * @param y1: Y1 position |
NirT | 0:c00e6c923941 | 715 | * @param xSize: X size. |
NirT | 0:c00e6c923941 | 716 | * @param ySize: Y size. |
NirT | 0:c00e6c923941 | 717 | * @retval None. |
NirT | 0:c00e6c923941 | 718 | */ |
NirT | 0:c00e6c923941 | 719 | static void LCD_LL_CopyRect(int LayerIndex, int x0, int y0, int x1, int y1, int xSize, int ySize) |
NirT | 0:c00e6c923941 | 720 | { |
NirT | 0:c00e6c923941 | 721 | U32 BufferSize, AddrSrc, AddrDst; |
NirT | 0:c00e6c923941 | 722 | |
NirT | 0:c00e6c923941 | 723 | BufferSize = GetBufferSize(LayerIndex); |
NirT | 0:c00e6c923941 | 724 | AddrSrc = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].pending_buffer + (y0 * layer_prop[LayerIndex].xSize + x0) * layer_prop[LayerIndex].BytesPerPixel; |
NirT | 0:c00e6c923941 | 725 | AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].pending_buffer + (y1 * layer_prop[LayerIndex].xSize + x1) * layer_prop[LayerIndex].BytesPerPixel; |
NirT | 0:c00e6c923941 | 726 | DMA2D_CopyBuffer(LayerIndex, (void *)AddrSrc, (void *)AddrDst, xSize, ySize, layer_prop[LayerIndex].xSize - xSize, 0); |
NirT | 0:c00e6c923941 | 727 | } |
NirT | 0:c00e6c923941 | 728 | |
NirT | 0:c00e6c923941 | 729 | /** |
NirT | 0:c00e6c923941 | 730 | * @brief Fill rectangle |
NirT | 0:c00e6c923941 | 731 | * @param LayerIndex : Layer Index |
NirT | 0:c00e6c923941 | 732 | * @param x0: X0 position |
NirT | 0:c00e6c923941 | 733 | * @param y0: Y0 position |
NirT | 0:c00e6c923941 | 734 | * @param x1: X1 position |
NirT | 0:c00e6c923941 | 735 | * @param y1: Y1 position |
NirT | 0:c00e6c923941 | 736 | * @param PixelIndex: Pixel index. |
NirT | 0:c00e6c923941 | 737 | * @retval None. |
NirT | 0:c00e6c923941 | 738 | */ |
NirT | 0:c00e6c923941 | 739 | static void LCD_LL_FillRect(int LayerIndex, int x0, int y0, int x1, int y1, U32 PixelIndex) |
NirT | 0:c00e6c923941 | 740 | { |
NirT | 0:c00e6c923941 | 741 | U32 BufferSize, AddrDst; |
NirT | 0:c00e6c923941 | 742 | int xSize, ySize; |
NirT | 0:c00e6c923941 | 743 | |
NirT | 0:c00e6c923941 | 744 | if (GUI_GetDrawMode() == GUI_DM_XOR) |
NirT | 0:c00e6c923941 | 745 | { |
NirT | 0:c00e6c923941 | 746 | LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, NULL); |
NirT | 0:c00e6c923941 | 747 | LCD_FillRect(x0, y0, x1, y1); |
NirT | 0:c00e6c923941 | 748 | LCD_SetDevFunc(LayerIndex, LCD_DEVFUNC_FILLRECT, (void(*)(void))LCD_LL_FillRect); |
NirT | 0:c00e6c923941 | 749 | } |
NirT | 0:c00e6c923941 | 750 | else |
NirT | 0:c00e6c923941 | 751 | { |
NirT | 0:c00e6c923941 | 752 | xSize = x1 - x0 + 1; |
NirT | 0:c00e6c923941 | 753 | ySize = y1 - y0 + 1; |
NirT | 0:c00e6c923941 | 754 | BufferSize = GetBufferSize(LayerIndex); |
NirT | 0:c00e6c923941 | 755 | AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y0 * layer_prop[LayerIndex].xSize + x0) * layer_prop[LayerIndex].BytesPerPixel; |
NirT | 0:c00e6c923941 | 756 | DMA2D_FillBuffer(LayerIndex, (void *)AddrDst, xSize, ySize, layer_prop[LayerIndex].xSize - xSize, PixelIndex); |
NirT | 0:c00e6c923941 | 757 | } |
NirT | 0:c00e6c923941 | 758 | } |
NirT | 0:c00e6c923941 | 759 | |
NirT | 0:c00e6c923941 | 760 | /** |
NirT | 0:c00e6c923941 | 761 | * @brief Draw indirect color bitmap |
NirT | 0:c00e6c923941 | 762 | * @param pSrc: pointer to the source |
NirT | 0:c00e6c923941 | 763 | * @param pDst: pointer to the destination |
NirT | 0:c00e6c923941 | 764 | * @param OffSrc: offset source |
NirT | 0:c00e6c923941 | 765 | * @param OffDst: offset destination |
NirT | 0:c00e6c923941 | 766 | * @param PixelFormatDst: pixel format for destination |
NirT | 0:c00e6c923941 | 767 | * @param xSize: X size |
NirT | 0:c00e6c923941 | 768 | * @param ySize: Y size |
NirT | 0:c00e6c923941 | 769 | * @retval None |
NirT | 0:c00e6c923941 | 770 | */ |
NirT | 0:c00e6c923941 | 771 | static void LCD_LL_DrawBitmap32bpp(int LayerIndex, int x, int y, U8 const * p, int xSize, int ySize, int BytesPerLine) |
NirT | 0:c00e6c923941 | 772 | { |
NirT | 0:c00e6c923941 | 773 | U32 BufferSize, AddrDst; |
NirT | 0:c00e6c923941 | 774 | int OffLineSrc, OffLineDst; |
NirT | 0:c00e6c923941 | 775 | |
NirT | 0:c00e6c923941 | 776 | BufferSize = GetBufferSize(LayerIndex); |
NirT | 0:c00e6c923941 | 777 | AddrDst = layer_prop[LayerIndex].address + BufferSize * layer_prop[LayerIndex].buffer_index + (y * layer_prop[LayerIndex].xSize + x) * layer_prop[LayerIndex].BytesPerPixel; |
NirT | 0:c00e6c923941 | 778 | OffLineSrc = (BytesPerLine / 4) - xSize; |
NirT | 0:c00e6c923941 | 779 | OffLineDst = layer_prop[LayerIndex].xSize - xSize; |
NirT | 0:c00e6c923941 | 780 | DMA2D_CopyBuffer(LayerIndex, (void *)p, (void *)AddrDst, xSize, ySize, OffLineSrc, OffLineDst); |
NirT | 0:c00e6c923941 | 781 | } |
NirT | 0:c00e6c923941 | 782 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
NirT | 0:c00e6c923941 | 783 |