Emil Johnsen / mbed-src-STM32F030K6

Fork of mbed-src by Ermanno Brusadin

Committer:
ebrus
Date:
Wed Jul 27 18:35:32 2016 +0000
Revision:
0:0a673c671a56
4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ebrus 0:0a673c671a56 1 /**
ebrus 0:0a673c671a56 2 ******************************************************************************
ebrus 0:0a673c671a56 3 * @file stm32f4xx_hal_ltdc.c
ebrus 0:0a673c671a56 4 * @author MCD Application Team
ebrus 0:0a673c671a56 5 * @version V1.1.0RC2
ebrus 0:0a673c671a56 6 * @date 14-May-2014
ebrus 0:0a673c671a56 7 * @brief LTDC HAL module driver.
ebrus 0:0a673c671a56 8 * This file provides firmware functions to manage the following
ebrus 0:0a673c671a56 9 * functionalities of the LTDC peripheral:
ebrus 0:0a673c671a56 10 * + Initialization and de-initialization functions
ebrus 0:0a673c671a56 11 * + IO operation functions
ebrus 0:0a673c671a56 12 * + Peripheral Control functions
ebrus 0:0a673c671a56 13 * + Peripheral State and Errors functions
ebrus 0:0a673c671a56 14 *
ebrus 0:0a673c671a56 15 @verbatim
ebrus 0:0a673c671a56 16 ==============================================================================
ebrus 0:0a673c671a56 17 ##### How to use this driver #####
ebrus 0:0a673c671a56 18 ==============================================================================
ebrus 0:0a673c671a56 19 [..]
ebrus 0:0a673c671a56 20 (#) Program the required configuration through the following parameters:
ebrus 0:0a673c671a56 21 the LTDC timing, the horizontal and vertical polarity,
ebrus 0:0a673c671a56 22 the pixel clock polarity, Data Enable polarity and the LTDC background color value
ebrus 0:0a673c671a56 23 using HAL_LTDC_Init() function
ebrus 0:0a673c671a56 24
ebrus 0:0a673c671a56 25 (#) Program the required configuration through the following parameters:
ebrus 0:0a673c671a56 26 the pixel format, the blending factors, input alpha value, the window size
ebrus 0:0a673c671a56 27 and the image size using HAL_LTDC_ConfigLayer() function for foreground
ebrus 0:0a673c671a56 28 or/and background layer.
ebrus 0:0a673c671a56 29
ebrus 0:0a673c671a56 30 (#) Optionally, configure and enable the CLUT using HAL_LTDC_ConfigCLUT() and
ebrus 0:0a673c671a56 31 HAL_LTDC_EnableCLUT functions.
ebrus 0:0a673c671a56 32
ebrus 0:0a673c671a56 33 (#) Optionally, enable the Dither using HAL_LTDC_EnableDither().
ebrus 0:0a673c671a56 34
ebrus 0:0a673c671a56 35 (#) Optionally, configure and enable the Color keying using HAL_LTDC_ConfigColorKeying()
ebrus 0:0a673c671a56 36 and HAL_LTDC_EnableColorKeying functions.
ebrus 0:0a673c671a56 37
ebrus 0:0a673c671a56 38 (#) Optionally, configure LineInterrupt using HAL_LTDC_ProgramLineInterrupt()
ebrus 0:0a673c671a56 39 function
ebrus 0:0a673c671a56 40
ebrus 0:0a673c671a56 41 (#) If needed, reconfigure and change the pixel format value, the alpha value
ebrus 0:0a673c671a56 42 value, the window size, the window position and the layer start address
ebrus 0:0a673c671a56 43 for foreground or/and background layer using respectively the following
ebrus 0:0a673c671a56 44 functions: HAL_LTDC_SetPixelFormat(), HAL_LTDC_SetAlpha(), HAL_LTDC_SetWindowSize(),
ebrus 0:0a673c671a56 45 HAL_LTDC_SetWindowPosition(), HAL_LTDC_SetAddress.
ebrus 0:0a673c671a56 46
ebrus 0:0a673c671a56 47 (#) To control LTDC state you can use the following function: HAL_LTDC_GetState()
ebrus 0:0a673c671a56 48
ebrus 0:0a673c671a56 49 *** LTDC HAL driver macros list ***
ebrus 0:0a673c671a56 50 =============================================
ebrus 0:0a673c671a56 51 [..]
ebrus 0:0a673c671a56 52 Below the list of most used macros in LTDC HAL driver.
ebrus 0:0a673c671a56 53
ebrus 0:0a673c671a56 54 (+) __HAL_LTDC_ENABLE: Enable the LTDC.
ebrus 0:0a673c671a56 55 (+) __HAL_LTDC_DISABLE: Disable the LTDC.
ebrus 0:0a673c671a56 56 (+) __HAL_LTDC_LAYER_ENABLE: Enable the LTDC Layer.
ebrus 0:0a673c671a56 57 (+) __HAL_LTDC_LAYER_DISABLE: Disable the LTDC Layer.
ebrus 0:0a673c671a56 58 (+) __HAL_LTDC_RELOAD_CONFIG: Reload Layer Configuration.
ebrus 0:0a673c671a56 59 (+) __HAL_LTDC_GET_FLAG: Get the LTDC pending flags.
ebrus 0:0a673c671a56 60 (+) __HAL_LTDC_CLEAR_FLAG: Clear the LTDC pending flags.
ebrus 0:0a673c671a56 61 (+) __HAL_LTDC_ENABLE_IT: Enable the specified LTDC interrupts.
ebrus 0:0a673c671a56 62 (+) __HAL_LTDC_DISABLE_IT: Disable the specified LTDC interrupts.
ebrus 0:0a673c671a56 63 (+) __HAL_LTDC_GET_IT_SOURCE: Check whether the specified LTDC interrupt has occurred or not.
ebrus 0:0a673c671a56 64
ebrus 0:0a673c671a56 65 [..]
ebrus 0:0a673c671a56 66 (@) You can refer to the LTDC HAL driver header file for more useful macros
ebrus 0:0a673c671a56 67
ebrus 0:0a673c671a56 68 @endverbatim
ebrus 0:0a673c671a56 69 ******************************************************************************
ebrus 0:0a673c671a56 70 * @attention
ebrus 0:0a673c671a56 71 *
ebrus 0:0a673c671a56 72 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
ebrus 0:0a673c671a56 73 *
ebrus 0:0a673c671a56 74 * Redistribution and use in source and binary forms, with or without modification,
ebrus 0:0a673c671a56 75 * are permitted provided that the following conditions are met:
ebrus 0:0a673c671a56 76 * 1. Redistributions of source code must retain the above copyright notice,
ebrus 0:0a673c671a56 77 * this list of conditions and the following disclaimer.
ebrus 0:0a673c671a56 78 * 2. Redistributions in binary form must reproduce the above copyright notice,
ebrus 0:0a673c671a56 79 * this list of conditions and the following disclaimer in the documentation
ebrus 0:0a673c671a56 80 * and/or other materials provided with the distribution.
ebrus 0:0a673c671a56 81 * 3. Neither the name of STMicroelectronics nor the names of its contributors
ebrus 0:0a673c671a56 82 * may be used to endorse or promote products derived from this software
ebrus 0:0a673c671a56 83 * without specific prior written permission.
ebrus 0:0a673c671a56 84 *
ebrus 0:0a673c671a56 85 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
ebrus 0:0a673c671a56 86 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ebrus 0:0a673c671a56 87 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
ebrus 0:0a673c671a56 88 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
ebrus 0:0a673c671a56 89 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ebrus 0:0a673c671a56 90 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
ebrus 0:0a673c671a56 91 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
ebrus 0:0a673c671a56 92 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ebrus 0:0a673c671a56 93 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
ebrus 0:0a673c671a56 94 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ebrus 0:0a673c671a56 95 *
ebrus 0:0a673c671a56 96 ******************************************************************************
ebrus 0:0a673c671a56 97 */
ebrus 0:0a673c671a56 98
ebrus 0:0a673c671a56 99 /* Includes ------------------------------------------------------------------*/
ebrus 0:0a673c671a56 100 #include "stm32f4xx_hal.h"
ebrus 0:0a673c671a56 101
ebrus 0:0a673c671a56 102 /** @addtogroup STM32F4xx_HAL_Driver
ebrus 0:0a673c671a56 103 * @{
ebrus 0:0a673c671a56 104 */
ebrus 0:0a673c671a56 105 /** @defgroup LTDC
ebrus 0:0a673c671a56 106 * @brief LTDC HAL module driver
ebrus 0:0a673c671a56 107 * @{
ebrus 0:0a673c671a56 108 */
ebrus 0:0a673c671a56 109
ebrus 0:0a673c671a56 110 #ifdef HAL_LTDC_MODULE_ENABLED
ebrus 0:0a673c671a56 111
ebrus 0:0a673c671a56 112 #if defined(STM32F429xx) || defined(STM32F439xx)
ebrus 0:0a673c671a56 113
ebrus 0:0a673c671a56 114 /* Private typedef -----------------------------------------------------------*/
ebrus 0:0a673c671a56 115 /* Private define ------------------------------------------------------------*/
ebrus 0:0a673c671a56 116 /* Private macro -------------------------------------------------------------*/
ebrus 0:0a673c671a56 117 /* Private variables ---------------------------------------------------------*/
ebrus 0:0a673c671a56 118 /* Private function prototypes -----------------------------------------------*/
ebrus 0:0a673c671a56 119 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx);
ebrus 0:0a673c671a56 120 /* Private functions ---------------------------------------------------------*/
ebrus 0:0a673c671a56 121
ebrus 0:0a673c671a56 122 /** @defgroup LTDC_Private_Functions
ebrus 0:0a673c671a56 123 * @{
ebrus 0:0a673c671a56 124 */
ebrus 0:0a673c671a56 125
ebrus 0:0a673c671a56 126 /** @defgroup LTDC_Group1 Initialization and Configuration functions
ebrus 0:0a673c671a56 127 * @brief Initialization and Configuration functions
ebrus 0:0a673c671a56 128 *
ebrus 0:0a673c671a56 129 @verbatim
ebrus 0:0a673c671a56 130 ===============================================================================
ebrus 0:0a673c671a56 131 ##### Initialization and Configuration functions #####
ebrus 0:0a673c671a56 132 ===============================================================================
ebrus 0:0a673c671a56 133 [..] This section provides functions allowing to:
ebrus 0:0a673c671a56 134 (+) Initialize and configure the LTDC
ebrus 0:0a673c671a56 135 (+) De-initialize the LTDC
ebrus 0:0a673c671a56 136
ebrus 0:0a673c671a56 137 @endverbatim
ebrus 0:0a673c671a56 138 * @{
ebrus 0:0a673c671a56 139 */
ebrus 0:0a673c671a56 140
ebrus 0:0a673c671a56 141 /**
ebrus 0:0a673c671a56 142 * @brief Initializes the LTDC according to the specified
ebrus 0:0a673c671a56 143 * parameters in the LTDC_InitTypeDef and create the associated handle.
ebrus 0:0a673c671a56 144 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 145 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 146 * @retval HAL status
ebrus 0:0a673c671a56 147 */
ebrus 0:0a673c671a56 148 HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc)
ebrus 0:0a673c671a56 149 {
ebrus 0:0a673c671a56 150 uint32_t tmp = 0, tmp1 = 0;
ebrus 0:0a673c671a56 151
ebrus 0:0a673c671a56 152 /* Check the LTDC peripheral state */
ebrus 0:0a673c671a56 153 if(hltdc == NULL)
ebrus 0:0a673c671a56 154 {
ebrus 0:0a673c671a56 155 return HAL_ERROR;
ebrus 0:0a673c671a56 156 }
ebrus 0:0a673c671a56 157
ebrus 0:0a673c671a56 158 /* Check function parameters */
ebrus 0:0a673c671a56 159 assert_param(IS_LTDC_ALL_INSTANCE(hltdc->Instance));
ebrus 0:0a673c671a56 160 assert_param(IS_LTDC_HSYNC(hltdc->Init.HorizontalSync));
ebrus 0:0a673c671a56 161 assert_param(IS_LTDC_VSYNC(hltdc->Init.VerticalSync));
ebrus 0:0a673c671a56 162 assert_param(IS_LTDC_AHBP(hltdc->Init.AccumulatedHBP));
ebrus 0:0a673c671a56 163 assert_param(IS_LTDC_AVBP(hltdc->Init.AccumulatedVBP));
ebrus 0:0a673c671a56 164 assert_param(IS_LTDC_AAH(hltdc->Init.AccumulatedActiveH));
ebrus 0:0a673c671a56 165 assert_param(IS_LTDC_AAW(hltdc->Init.AccumulatedActiveW));
ebrus 0:0a673c671a56 166 assert_param(IS_LTDC_TOTALH(hltdc->Init.TotalHeigh));
ebrus 0:0a673c671a56 167 assert_param(IS_LTDC_TOTALW(hltdc->Init.TotalWidth));
ebrus 0:0a673c671a56 168 assert_param(IS_LTDC_HSPOL(hltdc->Init.HSPolarity));
ebrus 0:0a673c671a56 169 assert_param(IS_LTDC_VSPOL(hltdc->Init.VSPolarity));
ebrus 0:0a673c671a56 170 assert_param(IS_LTDC_DEPOL(hltdc->Init.DEPolarity));
ebrus 0:0a673c671a56 171 assert_param(IS_LTDC_PCPOL(hltdc->Init.PCPolarity));
ebrus 0:0a673c671a56 172
ebrus 0:0a673c671a56 173 if(hltdc->State == HAL_LTDC_STATE_RESET)
ebrus 0:0a673c671a56 174 {
ebrus 0:0a673c671a56 175 /* Init the low level hardware */
ebrus 0:0a673c671a56 176 HAL_LTDC_MspInit(hltdc);
ebrus 0:0a673c671a56 177 }
ebrus 0:0a673c671a56 178
ebrus 0:0a673c671a56 179 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 180 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 181
ebrus 0:0a673c671a56 182 /* Configures the HS, VS, DE and PC polarity */
ebrus 0:0a673c671a56 183 hltdc->Instance->GCR &= ~(LTDC_GCR_HSPOL | LTDC_GCR_VSPOL | LTDC_GCR_DEPOL | LTDC_GCR_PCPOL);
ebrus 0:0a673c671a56 184 hltdc->Instance->GCR |= (uint32_t)(hltdc->Init.HSPolarity | hltdc->Init.VSPolarity | \
ebrus 0:0a673c671a56 185 hltdc->Init.DEPolarity | hltdc->Init.PCPolarity);
ebrus 0:0a673c671a56 186
ebrus 0:0a673c671a56 187 /* Sets Synchronization size */
ebrus 0:0a673c671a56 188 hltdc->Instance->SSCR &= ~(LTDC_SSCR_VSH | LTDC_SSCR_HSW);
ebrus 0:0a673c671a56 189 tmp = (hltdc->Init.HorizontalSync << 16);
ebrus 0:0a673c671a56 190 hltdc->Instance->SSCR |= (tmp | hltdc->Init.VerticalSync);
ebrus 0:0a673c671a56 191
ebrus 0:0a673c671a56 192 /* Sets Accumulated Back porch */
ebrus 0:0a673c671a56 193 hltdc->Instance->BPCR &= ~(LTDC_BPCR_AVBP | LTDC_BPCR_AHBP);
ebrus 0:0a673c671a56 194 tmp = (hltdc->Init.AccumulatedHBP << 16);
ebrus 0:0a673c671a56 195 hltdc->Instance->BPCR |= (tmp | hltdc->Init.AccumulatedVBP);
ebrus 0:0a673c671a56 196
ebrus 0:0a673c671a56 197 /* Sets Accumulated Active Width */
ebrus 0:0a673c671a56 198 hltdc->Instance->AWCR &= ~(LTDC_AWCR_AAH | LTDC_AWCR_AAW);
ebrus 0:0a673c671a56 199 tmp = (hltdc->Init.AccumulatedActiveW << 16);
ebrus 0:0a673c671a56 200 hltdc->Instance->AWCR |= (tmp | hltdc->Init.AccumulatedActiveH);
ebrus 0:0a673c671a56 201
ebrus 0:0a673c671a56 202 /* Sets Total Width */
ebrus 0:0a673c671a56 203 hltdc->Instance->TWCR &= ~(LTDC_TWCR_TOTALH | LTDC_TWCR_TOTALW);
ebrus 0:0a673c671a56 204 tmp = (hltdc->Init.TotalWidth << 16);
ebrus 0:0a673c671a56 205 hltdc->Instance->TWCR |= (tmp | hltdc->Init.TotalHeigh);
ebrus 0:0a673c671a56 206
ebrus 0:0a673c671a56 207 /* Sets the background color value */
ebrus 0:0a673c671a56 208 tmp = ((uint32_t)(hltdc->Init.Backcolor.Green) << 8);
ebrus 0:0a673c671a56 209 tmp1 = ((uint32_t)(hltdc->Init.Backcolor.Red) << 16);
ebrus 0:0a673c671a56 210 hltdc->Instance->BCCR &= ~(LTDC_BCCR_BCBLUE | LTDC_BCCR_BCGREEN | LTDC_BCCR_BCRED);
ebrus 0:0a673c671a56 211 hltdc->Instance->BCCR |= (tmp1 | tmp | hltdc->Init.Backcolor.Blue);
ebrus 0:0a673c671a56 212
ebrus 0:0a673c671a56 213 /* Enable the transfer Error interrupt */
ebrus 0:0a673c671a56 214 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_TE);
ebrus 0:0a673c671a56 215
ebrus 0:0a673c671a56 216 /* Enable the FIFO underrun interrupt */
ebrus 0:0a673c671a56 217 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_FU);
ebrus 0:0a673c671a56 218
ebrus 0:0a673c671a56 219 /* Enable LTDC by setting LTDCEN bit */
ebrus 0:0a673c671a56 220 __HAL_LTDC_ENABLE(hltdc);
ebrus 0:0a673c671a56 221
ebrus 0:0a673c671a56 222 /* Initialise the error code */
ebrus 0:0a673c671a56 223 hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
ebrus 0:0a673c671a56 224
ebrus 0:0a673c671a56 225 /* Initialize the LTDC state*/
ebrus 0:0a673c671a56 226 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 227
ebrus 0:0a673c671a56 228 return HAL_OK;
ebrus 0:0a673c671a56 229 }
ebrus 0:0a673c671a56 230
ebrus 0:0a673c671a56 231 /**
ebrus 0:0a673c671a56 232 * @brief Deinitializes the LTDC peripheral registers to their default reset
ebrus 0:0a673c671a56 233 * values.
ebrus 0:0a673c671a56 234 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 235 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 236 * @retval None
ebrus 0:0a673c671a56 237 */
ebrus 0:0a673c671a56 238
ebrus 0:0a673c671a56 239 HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc)
ebrus 0:0a673c671a56 240 {
ebrus 0:0a673c671a56 241 /* DeInit the low level hardware */
ebrus 0:0a673c671a56 242 HAL_LTDC_MspDeInit(hltdc);
ebrus 0:0a673c671a56 243
ebrus 0:0a673c671a56 244 /* Initialise the error code */
ebrus 0:0a673c671a56 245 hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
ebrus 0:0a673c671a56 246
ebrus 0:0a673c671a56 247 /* Initialize the LTDC state*/
ebrus 0:0a673c671a56 248 hltdc->State = HAL_LTDC_STATE_RESET;
ebrus 0:0a673c671a56 249
ebrus 0:0a673c671a56 250 /* Release Lock */
ebrus 0:0a673c671a56 251 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 252
ebrus 0:0a673c671a56 253 return HAL_OK;
ebrus 0:0a673c671a56 254 }
ebrus 0:0a673c671a56 255
ebrus 0:0a673c671a56 256 /**
ebrus 0:0a673c671a56 257 * @brief Initializes the LTDC MSP.
ebrus 0:0a673c671a56 258 * @param hltdc : pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 259 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 260 * @retval None
ebrus 0:0a673c671a56 261 */
ebrus 0:0a673c671a56 262 __weak void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc)
ebrus 0:0a673c671a56 263 {
ebrus 0:0a673c671a56 264 /* NOTE : This function Should not be modified, when the callback is needed,
ebrus 0:0a673c671a56 265 the HAL_LTDC_MspInit could be implemented in the user file
ebrus 0:0a673c671a56 266 */
ebrus 0:0a673c671a56 267 }
ebrus 0:0a673c671a56 268
ebrus 0:0a673c671a56 269 /**
ebrus 0:0a673c671a56 270 * @brief DeInitializes the LTDC MSP.
ebrus 0:0a673c671a56 271 * @param hltdc : pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 272 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 273 * @retval None
ebrus 0:0a673c671a56 274 */
ebrus 0:0a673c671a56 275 __weak void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc)
ebrus 0:0a673c671a56 276 {
ebrus 0:0a673c671a56 277 /* NOTE : This function Should not be modified, when the callback is needed,
ebrus 0:0a673c671a56 278 the HAL_LTDC_MspDeInit could be implemented in the user file
ebrus 0:0a673c671a56 279 */
ebrus 0:0a673c671a56 280 }
ebrus 0:0a673c671a56 281
ebrus 0:0a673c671a56 282 /**
ebrus 0:0a673c671a56 283 * @}
ebrus 0:0a673c671a56 284 */
ebrus 0:0a673c671a56 285
ebrus 0:0a673c671a56 286 /** @defgroup LTDC_Group2 IO operation functions
ebrus 0:0a673c671a56 287 * @brief IO operation functions
ebrus 0:0a673c671a56 288 *
ebrus 0:0a673c671a56 289 @verbatim
ebrus 0:0a673c671a56 290 ===============================================================================
ebrus 0:0a673c671a56 291 ##### IO operation functions #####
ebrus 0:0a673c671a56 292 ===============================================================================
ebrus 0:0a673c671a56 293 [..] This section provides function allowing to:
ebrus 0:0a673c671a56 294 (+) Handle LTDC interrupt request
ebrus 0:0a673c671a56 295
ebrus 0:0a673c671a56 296 @endverbatim
ebrus 0:0a673c671a56 297 * @{
ebrus 0:0a673c671a56 298 */
ebrus 0:0a673c671a56 299 /**
ebrus 0:0a673c671a56 300 * @brief Handles LTDC interrupt request.
ebrus 0:0a673c671a56 301 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 302 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 303 * @retval HAL status
ebrus 0:0a673c671a56 304 */
ebrus 0:0a673c671a56 305 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc)
ebrus 0:0a673c671a56 306 {
ebrus 0:0a673c671a56 307 /* Transfer Error Interrupt management ***************************************/
ebrus 0:0a673c671a56 308 if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_TE) != RESET)
ebrus 0:0a673c671a56 309 {
ebrus 0:0a673c671a56 310 if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_TE) != RESET)
ebrus 0:0a673c671a56 311 {
ebrus 0:0a673c671a56 312 /* Disable the transfer Error interrupt */
ebrus 0:0a673c671a56 313 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_TE);
ebrus 0:0a673c671a56 314
ebrus 0:0a673c671a56 315 /* Clear the transfer error flag */
ebrus 0:0a673c671a56 316 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_TE);
ebrus 0:0a673c671a56 317
ebrus 0:0a673c671a56 318 /* Update error code */
ebrus 0:0a673c671a56 319 hltdc->ErrorCode |= HAL_LTDC_ERROR_TE;
ebrus 0:0a673c671a56 320
ebrus 0:0a673c671a56 321 /* Change LTDC state */
ebrus 0:0a673c671a56 322 hltdc->State = HAL_LTDC_STATE_ERROR;
ebrus 0:0a673c671a56 323
ebrus 0:0a673c671a56 324 /* Process unlocked */
ebrus 0:0a673c671a56 325 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 326
ebrus 0:0a673c671a56 327 /* Transfer error Callback */
ebrus 0:0a673c671a56 328 HAL_LTDC_ErrorCallback(hltdc);
ebrus 0:0a673c671a56 329 }
ebrus 0:0a673c671a56 330 }
ebrus 0:0a673c671a56 331 /* FIFO underrun Interrupt management ***************************************/
ebrus 0:0a673c671a56 332 if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_FU) != RESET)
ebrus 0:0a673c671a56 333 {
ebrus 0:0a673c671a56 334 if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_FU) != RESET)
ebrus 0:0a673c671a56 335 {
ebrus 0:0a673c671a56 336 /* Disable the FIFO underrun interrupt */
ebrus 0:0a673c671a56 337 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_FU);
ebrus 0:0a673c671a56 338
ebrus 0:0a673c671a56 339 /* Clear the FIFO underrun flag */
ebrus 0:0a673c671a56 340 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_FU);
ebrus 0:0a673c671a56 341
ebrus 0:0a673c671a56 342 /* Update error code */
ebrus 0:0a673c671a56 343 hltdc->ErrorCode |= HAL_LTDC_ERROR_FU;
ebrus 0:0a673c671a56 344
ebrus 0:0a673c671a56 345 /* Change LTDC state */
ebrus 0:0a673c671a56 346 hltdc->State = HAL_LTDC_STATE_ERROR;
ebrus 0:0a673c671a56 347
ebrus 0:0a673c671a56 348 /* Process unlocked */
ebrus 0:0a673c671a56 349 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 350
ebrus 0:0a673c671a56 351 /* Transfer error Callback */
ebrus 0:0a673c671a56 352 HAL_LTDC_ErrorCallback(hltdc);
ebrus 0:0a673c671a56 353 }
ebrus 0:0a673c671a56 354 }
ebrus 0:0a673c671a56 355 /* Line Interrupt management ************************************************/
ebrus 0:0a673c671a56 356 if(__HAL_LTDC_GET_FLAG(hltdc, LTDC_FLAG_LI) != RESET)
ebrus 0:0a673c671a56 357 {
ebrus 0:0a673c671a56 358 if(__HAL_LTDC_GET_IT_SOURCE(hltdc, LTDC_IT_LI) != RESET)
ebrus 0:0a673c671a56 359 {
ebrus 0:0a673c671a56 360 /* Disable the Line interrupt */
ebrus 0:0a673c671a56 361 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
ebrus 0:0a673c671a56 362
ebrus 0:0a673c671a56 363 /* Clear the Line interrupt flag */
ebrus 0:0a673c671a56 364 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_LI);
ebrus 0:0a673c671a56 365
ebrus 0:0a673c671a56 366 /* Change LTDC state */
ebrus 0:0a673c671a56 367 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 368
ebrus 0:0a673c671a56 369 /* Process unlocked */
ebrus 0:0a673c671a56 370 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 371
ebrus 0:0a673c671a56 372 /* Line interrupt Callback */
ebrus 0:0a673c671a56 373 HAL_LTDC_LineEvenCallback(hltdc);
ebrus 0:0a673c671a56 374 }
ebrus 0:0a673c671a56 375 }
ebrus 0:0a673c671a56 376 }
ebrus 0:0a673c671a56 377
ebrus 0:0a673c671a56 378 /**
ebrus 0:0a673c671a56 379 * @brief Error LTDC callback.
ebrus 0:0a673c671a56 380 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 381 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 382 * @retval None
ebrus 0:0a673c671a56 383 */
ebrus 0:0a673c671a56 384 __weak void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc)
ebrus 0:0a673c671a56 385 {
ebrus 0:0a673c671a56 386 /* NOTE : This function Should not be modified, when the callback is needed,
ebrus 0:0a673c671a56 387 the HAL_LTDC_ErrorCallback could be implemented in the user file
ebrus 0:0a673c671a56 388 */
ebrus 0:0a673c671a56 389 }
ebrus 0:0a673c671a56 390
ebrus 0:0a673c671a56 391 /**
ebrus 0:0a673c671a56 392 * @brief Line Event callback.
ebrus 0:0a673c671a56 393 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 394 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 395 * @retval None
ebrus 0:0a673c671a56 396 */
ebrus 0:0a673c671a56 397 __weak void HAL_LTDC_LineEvenCallback(LTDC_HandleTypeDef *hltdc)
ebrus 0:0a673c671a56 398 {
ebrus 0:0a673c671a56 399 /* NOTE : This function Should not be modified, when the callback is needed,
ebrus 0:0a673c671a56 400 the HAL_LTDC_LineEvenCallback could be implemented in the user file
ebrus 0:0a673c671a56 401 */
ebrus 0:0a673c671a56 402 }
ebrus 0:0a673c671a56 403
ebrus 0:0a673c671a56 404 /**
ebrus 0:0a673c671a56 405 * @}
ebrus 0:0a673c671a56 406 */
ebrus 0:0a673c671a56 407
ebrus 0:0a673c671a56 408 /** @defgroup LTDC_Group3 Peripheral Control functions
ebrus 0:0a673c671a56 409 * @brief Peripheral Control functions
ebrus 0:0a673c671a56 410 *
ebrus 0:0a673c671a56 411 @verbatim
ebrus 0:0a673c671a56 412 ===============================================================================
ebrus 0:0a673c671a56 413 ##### Peripheral Control functions #####
ebrus 0:0a673c671a56 414 ===============================================================================
ebrus 0:0a673c671a56 415 [..] This section provides functions allowing to:
ebrus 0:0a673c671a56 416 (+) Configure the LTDC foreground or/and background parameters.
ebrus 0:0a673c671a56 417 (+) Set the active layer.
ebrus 0:0a673c671a56 418 (+) Configure the color keying.
ebrus 0:0a673c671a56 419 (+) Configure the C-LUT.
ebrus 0:0a673c671a56 420 (+) Enable / Disable the color keying.
ebrus 0:0a673c671a56 421 (+) Enable / Disable the C-LUT.
ebrus 0:0a673c671a56 422 (+) Update the layer position.
ebrus 0:0a673c671a56 423 (+) Update the layer size.
ebrus 0:0a673c671a56 424 (+) Update pixel format on the fly.
ebrus 0:0a673c671a56 425 (+) Update transparency on the fly.
ebrus 0:0a673c671a56 426 (+) Update address on the fly.
ebrus 0:0a673c671a56 427
ebrus 0:0a673c671a56 428 @endverbatim
ebrus 0:0a673c671a56 429 * @{
ebrus 0:0a673c671a56 430 */
ebrus 0:0a673c671a56 431
ebrus 0:0a673c671a56 432 /**
ebrus 0:0a673c671a56 433 * @brief Configure the LTDC Layer according to the specified
ebrus 0:0a673c671a56 434 * parameters in the LTDC_InitTypeDef and create the associated handle.
ebrus 0:0a673c671a56 435 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 436 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 437 * @param pLayerCfg: pointer to a LTDC_LayerCfgTypeDef structure that contains
ebrus 0:0a673c671a56 438 * the configuration information for the Layer.
ebrus 0:0a673c671a56 439 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 440 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 441 * 0 or 1
ebrus 0:0a673c671a56 442 * @retval HAL status
ebrus 0:0a673c671a56 443 */
ebrus 0:0a673c671a56 444 HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
ebrus 0:0a673c671a56 445 {
ebrus 0:0a673c671a56 446 /* Process locked */
ebrus 0:0a673c671a56 447 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 448
ebrus 0:0a673c671a56 449 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 450 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 451
ebrus 0:0a673c671a56 452 /* Check the parameters */
ebrus 0:0a673c671a56 453 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 454 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
ebrus 0:0a673c671a56 455 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
ebrus 0:0a673c671a56 456 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
ebrus 0:0a673c671a56 457 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
ebrus 0:0a673c671a56 458 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
ebrus 0:0a673c671a56 459 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
ebrus 0:0a673c671a56 460 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
ebrus 0:0a673c671a56 461 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
ebrus 0:0a673c671a56 462 assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
ebrus 0:0a673c671a56 463 assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
ebrus 0:0a673c671a56 464
ebrus 0:0a673c671a56 465 /* Copy new layer configuration into handle structure */
ebrus 0:0a673c671a56 466 hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
ebrus 0:0a673c671a56 467
ebrus 0:0a673c671a56 468 /* Configure the LTDC Layer */
ebrus 0:0a673c671a56 469 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
ebrus 0:0a673c671a56 470
ebrus 0:0a673c671a56 471 /* Sets the Reload type */
ebrus 0:0a673c671a56 472 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 473
ebrus 0:0a673c671a56 474 /* Initialize the LTDC state*/
ebrus 0:0a673c671a56 475 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 476
ebrus 0:0a673c671a56 477 /* Process unlocked */
ebrus 0:0a673c671a56 478 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 479
ebrus 0:0a673c671a56 480 return HAL_OK;
ebrus 0:0a673c671a56 481 }
ebrus 0:0a673c671a56 482
ebrus 0:0a673c671a56 483 /**
ebrus 0:0a673c671a56 484 * @brief Configure the color keying.
ebrus 0:0a673c671a56 485 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 486 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 487 * @param RGBValue: the color key value
ebrus 0:0a673c671a56 488 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 489 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 490 * 0 or 1
ebrus 0:0a673c671a56 491 * @retval HAL status
ebrus 0:0a673c671a56 492 */
ebrus 0:0a673c671a56 493 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
ebrus 0:0a673c671a56 494 {
ebrus 0:0a673c671a56 495 /* Process locked */
ebrus 0:0a673c671a56 496 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 497
ebrus 0:0a673c671a56 498 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 499 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 500
ebrus 0:0a673c671a56 501 /* Check the parameters */
ebrus 0:0a673c671a56 502 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 503
ebrus 0:0a673c671a56 504 /* Configures the default color values */
ebrus 0:0a673c671a56 505 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
ebrus 0:0a673c671a56 506 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
ebrus 0:0a673c671a56 507
ebrus 0:0a673c671a56 508 /* Sets the Reload type */
ebrus 0:0a673c671a56 509 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 510
ebrus 0:0a673c671a56 511 /* Change the LTDC state*/
ebrus 0:0a673c671a56 512 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 513
ebrus 0:0a673c671a56 514 /* Process unlocked */
ebrus 0:0a673c671a56 515 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 516
ebrus 0:0a673c671a56 517 return HAL_OK;
ebrus 0:0a673c671a56 518 }
ebrus 0:0a673c671a56 519
ebrus 0:0a673c671a56 520 /**
ebrus 0:0a673c671a56 521 * @brief Load the color lookup table.
ebrus 0:0a673c671a56 522 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 523 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 524 * @param pCLUT: pointer to the color lookup table address.
ebrus 0:0a673c671a56 525 * @param CLUTSize: the color lookup table size.
ebrus 0:0a673c671a56 526 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 527 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 528 * 0 or 1
ebrus 0:0a673c671a56 529 * @retval HAL status
ebrus 0:0a673c671a56 530 */
ebrus 0:0a673c671a56 531 HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx)
ebrus 0:0a673c671a56 532 {
ebrus 0:0a673c671a56 533 uint32_t tmp = 0;
ebrus 0:0a673c671a56 534 uint32_t counter = 0;
ebrus 0:0a673c671a56 535 uint32_t pcounter = 0;
ebrus 0:0a673c671a56 536
ebrus 0:0a673c671a56 537 /* Process locked */
ebrus 0:0a673c671a56 538 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 539
ebrus 0:0a673c671a56 540 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 541 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 542
ebrus 0:0a673c671a56 543 /* Check the parameters */
ebrus 0:0a673c671a56 544 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 545
ebrus 0:0a673c671a56 546 for(counter = 0; (counter < CLUTSize); counter++)
ebrus 0:0a673c671a56 547 {
ebrus 0:0a673c671a56 548 tmp = ((counter << 24) | ((uint32_t)(*pCLUT) & 0xFF) | ((uint32_t)(*pCLUT) & 0xFF00) | ((uint32_t)(*pCLUT) & 0xFF0000));
ebrus 0:0a673c671a56 549 pcounter = (uint32_t)pCLUT + sizeof(*pCLUT);
ebrus 0:0a673c671a56 550 pCLUT = (uint32_t *)pcounter;
ebrus 0:0a673c671a56 551
ebrus 0:0a673c671a56 552 /* Specifies the C-LUT address and RGB value */
ebrus 0:0a673c671a56 553 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CLUTWR = tmp;
ebrus 0:0a673c671a56 554 }
ebrus 0:0a673c671a56 555
ebrus 0:0a673c671a56 556 /* Change the LTDC state*/
ebrus 0:0a673c671a56 557 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 558
ebrus 0:0a673c671a56 559 /* Process unlocked */
ebrus 0:0a673c671a56 560 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 561
ebrus 0:0a673c671a56 562 return HAL_OK;
ebrus 0:0a673c671a56 563 }
ebrus 0:0a673c671a56 564
ebrus 0:0a673c671a56 565 /**
ebrus 0:0a673c671a56 566 * @brief Enable the color keying.
ebrus 0:0a673c671a56 567 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 568 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 569 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 570 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 571 * 0 or 1
ebrus 0:0a673c671a56 572 * @retval HAL status
ebrus 0:0a673c671a56 573 */
ebrus 0:0a673c671a56 574 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
ebrus 0:0a673c671a56 575 {
ebrus 0:0a673c671a56 576 /* Process locked */
ebrus 0:0a673c671a56 577 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 578
ebrus 0:0a673c671a56 579 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 580 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 581
ebrus 0:0a673c671a56 582 /* Check the parameters */
ebrus 0:0a673c671a56 583 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 584
ebrus 0:0a673c671a56 585 /* Enable LTDC color keying by setting COLKEN bit */
ebrus 0:0a673c671a56 586 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
ebrus 0:0a673c671a56 587
ebrus 0:0a673c671a56 588 /* Sets the Reload type */
ebrus 0:0a673c671a56 589 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 590
ebrus 0:0a673c671a56 591 /* Change the LTDC state*/
ebrus 0:0a673c671a56 592 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 593
ebrus 0:0a673c671a56 594 /* Process unlocked */
ebrus 0:0a673c671a56 595 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 596
ebrus 0:0a673c671a56 597 return HAL_OK;
ebrus 0:0a673c671a56 598 }
ebrus 0:0a673c671a56 599
ebrus 0:0a673c671a56 600 /**
ebrus 0:0a673c671a56 601 * @brief Disable the color keying.
ebrus 0:0a673c671a56 602 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 603 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 604 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 605 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 606 * 0 or 1
ebrus 0:0a673c671a56 607 * @retval HAL status
ebrus 0:0a673c671a56 608 */
ebrus 0:0a673c671a56 609 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
ebrus 0:0a673c671a56 610 {
ebrus 0:0a673c671a56 611 /* Process locked */
ebrus 0:0a673c671a56 612 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 613
ebrus 0:0a673c671a56 614 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 615 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 616
ebrus 0:0a673c671a56 617 /* Check the parameters */
ebrus 0:0a673c671a56 618 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 619
ebrus 0:0a673c671a56 620 /* Disable LTDC color keying by setting COLKEN bit */
ebrus 0:0a673c671a56 621 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
ebrus 0:0a673c671a56 622
ebrus 0:0a673c671a56 623 /* Sets the Reload type */
ebrus 0:0a673c671a56 624 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 625
ebrus 0:0a673c671a56 626 /* Change the LTDC state*/
ebrus 0:0a673c671a56 627 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 628
ebrus 0:0a673c671a56 629 /* Process unlocked */
ebrus 0:0a673c671a56 630 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 631
ebrus 0:0a673c671a56 632 return HAL_OK;
ebrus 0:0a673c671a56 633 }
ebrus 0:0a673c671a56 634
ebrus 0:0a673c671a56 635 /**
ebrus 0:0a673c671a56 636 * @brief Enable the color lookup table.
ebrus 0:0a673c671a56 637 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 638 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 639 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 640 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 641 * 0 or 1
ebrus 0:0a673c671a56 642 * @retval HAL status
ebrus 0:0a673c671a56 643 */
ebrus 0:0a673c671a56 644 HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
ebrus 0:0a673c671a56 645 {
ebrus 0:0a673c671a56 646
ebrus 0:0a673c671a56 647 /* Process locked */
ebrus 0:0a673c671a56 648 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 649
ebrus 0:0a673c671a56 650 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 651 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 652
ebrus 0:0a673c671a56 653 /* Check the parameters */
ebrus 0:0a673c671a56 654 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 655
ebrus 0:0a673c671a56 656 /* Disable LTDC color lookup table by setting CLUTEN bit */
ebrus 0:0a673c671a56 657 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
ebrus 0:0a673c671a56 658
ebrus 0:0a673c671a56 659 /* Sets the Reload type */
ebrus 0:0a673c671a56 660 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 661
ebrus 0:0a673c671a56 662 /* Change the LTDC state*/
ebrus 0:0a673c671a56 663 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 664
ebrus 0:0a673c671a56 665 /* Process unlocked */
ebrus 0:0a673c671a56 666 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 667
ebrus 0:0a673c671a56 668 return HAL_OK;
ebrus 0:0a673c671a56 669 }
ebrus 0:0a673c671a56 670
ebrus 0:0a673c671a56 671 /**
ebrus 0:0a673c671a56 672 * @brief Disable the color lookup table.
ebrus 0:0a673c671a56 673 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 674 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 675 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 676 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 677 * 0 or 1
ebrus 0:0a673c671a56 678 * @retval HAL status
ebrus 0:0a673c671a56 679 */
ebrus 0:0a673c671a56 680 HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
ebrus 0:0a673c671a56 681 {
ebrus 0:0a673c671a56 682
ebrus 0:0a673c671a56 683 /* Process locked */
ebrus 0:0a673c671a56 684 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 685
ebrus 0:0a673c671a56 686 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 687 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 688
ebrus 0:0a673c671a56 689 /* Check the parameters */
ebrus 0:0a673c671a56 690 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 691
ebrus 0:0a673c671a56 692 /* Disable LTDC color lookup table by setting CLUTEN bit */
ebrus 0:0a673c671a56 693 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
ebrus 0:0a673c671a56 694
ebrus 0:0a673c671a56 695 /* Sets the Reload type */
ebrus 0:0a673c671a56 696 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 697
ebrus 0:0a673c671a56 698 /* Change the LTDC state*/
ebrus 0:0a673c671a56 699 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 700
ebrus 0:0a673c671a56 701 /* Process unlocked */
ebrus 0:0a673c671a56 702 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 703
ebrus 0:0a673c671a56 704 return HAL_OK;
ebrus 0:0a673c671a56 705 }
ebrus 0:0a673c671a56 706
ebrus 0:0a673c671a56 707 /**
ebrus 0:0a673c671a56 708 * @brief Enables Dither.
ebrus 0:0a673c671a56 709 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 710 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 711 * @retval HAL status
ebrus 0:0a673c671a56 712 */
ebrus 0:0a673c671a56 713
ebrus 0:0a673c671a56 714 HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc)
ebrus 0:0a673c671a56 715 {
ebrus 0:0a673c671a56 716 /* Process locked */
ebrus 0:0a673c671a56 717 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 718
ebrus 0:0a673c671a56 719 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 720 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 721
ebrus 0:0a673c671a56 722 /* Enable Dither by setting DTEN bit */
ebrus 0:0a673c671a56 723 LTDC->GCR |= (uint32_t)LTDC_GCR_DTEN;
ebrus 0:0a673c671a56 724
ebrus 0:0a673c671a56 725 /* Change the LTDC state*/
ebrus 0:0a673c671a56 726 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 727
ebrus 0:0a673c671a56 728 /* Process unlocked */
ebrus 0:0a673c671a56 729 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 730
ebrus 0:0a673c671a56 731 return HAL_OK;
ebrus 0:0a673c671a56 732 }
ebrus 0:0a673c671a56 733
ebrus 0:0a673c671a56 734 /**
ebrus 0:0a673c671a56 735 * @brief Disables Dither.
ebrus 0:0a673c671a56 736 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 737 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 738 * @retval HAL status
ebrus 0:0a673c671a56 739 */
ebrus 0:0a673c671a56 740
ebrus 0:0a673c671a56 741 HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc)
ebrus 0:0a673c671a56 742 {
ebrus 0:0a673c671a56 743 /* Process locked */
ebrus 0:0a673c671a56 744 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 745
ebrus 0:0a673c671a56 746 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 747 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 748
ebrus 0:0a673c671a56 749 /* Disable Dither by setting DTEN bit */
ebrus 0:0a673c671a56 750 LTDC->GCR &= ~(uint32_t)LTDC_GCR_DTEN;
ebrus 0:0a673c671a56 751
ebrus 0:0a673c671a56 752 /* Change the LTDC state*/
ebrus 0:0a673c671a56 753 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 754
ebrus 0:0a673c671a56 755 /* Process unlocked */
ebrus 0:0a673c671a56 756 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 757
ebrus 0:0a673c671a56 758 return HAL_OK;
ebrus 0:0a673c671a56 759 }
ebrus 0:0a673c671a56 760
ebrus 0:0a673c671a56 761 /**
ebrus 0:0a673c671a56 762 * @brief Set the LTDC window size.
ebrus 0:0a673c671a56 763 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 764 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 765 * @param XSize: LTDC Pixel per line
ebrus 0:0a673c671a56 766 * @param YSize: LTDC Line number
ebrus 0:0a673c671a56 767 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 768 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 769 * 0 or 1
ebrus 0:0a673c671a56 770 * @retval HAL status
ebrus 0:0a673c671a56 771 */
ebrus 0:0a673c671a56 772 HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
ebrus 0:0a673c671a56 773 {
ebrus 0:0a673c671a56 774 LTDC_LayerCfgTypeDef *pLayerCfg;
ebrus 0:0a673c671a56 775
ebrus 0:0a673c671a56 776 /* Process locked */
ebrus 0:0a673c671a56 777 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 778
ebrus 0:0a673c671a56 779 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 780 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 781
ebrus 0:0a673c671a56 782 /* Get layer configuration from handle structure */
ebrus 0:0a673c671a56 783 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
ebrus 0:0a673c671a56 784
ebrus 0:0a673c671a56 785 /* Check the parameters (Layers parameters)*/
ebrus 0:0a673c671a56 786 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 787 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
ebrus 0:0a673c671a56 788 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
ebrus 0:0a673c671a56 789 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
ebrus 0:0a673c671a56 790 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
ebrus 0:0a673c671a56 791 assert_param(IS_LTDC_CFBLL(XSize));
ebrus 0:0a673c671a56 792 assert_param(IS_LTDC_CFBLNBR(YSize));
ebrus 0:0a673c671a56 793
ebrus 0:0a673c671a56 794 /* update horizontal start/stop */
ebrus 0:0a673c671a56 795 pLayerCfg->WindowX0 = 0;
ebrus 0:0a673c671a56 796 pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
ebrus 0:0a673c671a56 797
ebrus 0:0a673c671a56 798 /* update vertical start/stop */
ebrus 0:0a673c671a56 799 pLayerCfg->WindowY0 = 0;
ebrus 0:0a673c671a56 800 pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
ebrus 0:0a673c671a56 801
ebrus 0:0a673c671a56 802 /* Reconfigures the color frame buffer pitch in byte */
ebrus 0:0a673c671a56 803 pLayerCfg->ImageWidth = XSize;
ebrus 0:0a673c671a56 804
ebrus 0:0a673c671a56 805 /* Reconfigures the frame buffer line number */
ebrus 0:0a673c671a56 806 pLayerCfg->ImageHeight = YSize;
ebrus 0:0a673c671a56 807
ebrus 0:0a673c671a56 808 /* Set LTDC parameters */
ebrus 0:0a673c671a56 809 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
ebrus 0:0a673c671a56 810
ebrus 0:0a673c671a56 811 /* Sets the Reload type */
ebrus 0:0a673c671a56 812 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 813
ebrus 0:0a673c671a56 814 /* Change the LTDC state*/
ebrus 0:0a673c671a56 815 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 816
ebrus 0:0a673c671a56 817 /* Process unlocked */
ebrus 0:0a673c671a56 818 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 819
ebrus 0:0a673c671a56 820 return HAL_OK;
ebrus 0:0a673c671a56 821 }
ebrus 0:0a673c671a56 822
ebrus 0:0a673c671a56 823 /**
ebrus 0:0a673c671a56 824 * @brief Set the LTDC window position.
ebrus 0:0a673c671a56 825 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 826 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 827 * @param X0: LTDC window X offset
ebrus 0:0a673c671a56 828 * @param Y0: LTDC window Y offset
ebrus 0:0a673c671a56 829 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 830 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 831 * 0 or 1
ebrus 0:0a673c671a56 832 * @retval HAL status
ebrus 0:0a673c671a56 833 */
ebrus 0:0a673c671a56 834 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
ebrus 0:0a673c671a56 835 {
ebrus 0:0a673c671a56 836 LTDC_LayerCfgTypeDef *pLayerCfg;
ebrus 0:0a673c671a56 837
ebrus 0:0a673c671a56 838 /* Process locked */
ebrus 0:0a673c671a56 839 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 840
ebrus 0:0a673c671a56 841 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 842 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 843
ebrus 0:0a673c671a56 844 /* Get layer configuration from handle structure */
ebrus 0:0a673c671a56 845 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
ebrus 0:0a673c671a56 846
ebrus 0:0a673c671a56 847 /* Check the parameters */
ebrus 0:0a673c671a56 848 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 849 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
ebrus 0:0a673c671a56 850 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
ebrus 0:0a673c671a56 851 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
ebrus 0:0a673c671a56 852 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
ebrus 0:0a673c671a56 853
ebrus 0:0a673c671a56 854 /* update horizontal start/stop */
ebrus 0:0a673c671a56 855 pLayerCfg->WindowX0 = X0;
ebrus 0:0a673c671a56 856 pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
ebrus 0:0a673c671a56 857
ebrus 0:0a673c671a56 858 /* update vertical start/stop */
ebrus 0:0a673c671a56 859 pLayerCfg->WindowY0 = Y0;
ebrus 0:0a673c671a56 860 pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
ebrus 0:0a673c671a56 861
ebrus 0:0a673c671a56 862 /* Set LTDC parameters */
ebrus 0:0a673c671a56 863 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
ebrus 0:0a673c671a56 864
ebrus 0:0a673c671a56 865 /* Sets the Reload type */
ebrus 0:0a673c671a56 866 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 867
ebrus 0:0a673c671a56 868 /* Change the LTDC state*/
ebrus 0:0a673c671a56 869 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 870
ebrus 0:0a673c671a56 871 /* Process unlocked */
ebrus 0:0a673c671a56 872 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 873
ebrus 0:0a673c671a56 874 return HAL_OK;
ebrus 0:0a673c671a56 875 }
ebrus 0:0a673c671a56 876
ebrus 0:0a673c671a56 877 /**
ebrus 0:0a673c671a56 878 * @brief Reconfigure the pixel format.
ebrus 0:0a673c671a56 879 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 880 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 881 * @param Pixelformat: new pixel format value.
ebrus 0:0a673c671a56 882 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 883 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 884 * 0 or 1.
ebrus 0:0a673c671a56 885 * @retval HAL status
ebrus 0:0a673c671a56 886 */
ebrus 0:0a673c671a56 887 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
ebrus 0:0a673c671a56 888 {
ebrus 0:0a673c671a56 889 LTDC_LayerCfgTypeDef *pLayerCfg;
ebrus 0:0a673c671a56 890
ebrus 0:0a673c671a56 891 /* Process locked */
ebrus 0:0a673c671a56 892 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 893
ebrus 0:0a673c671a56 894 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 895 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 896
ebrus 0:0a673c671a56 897 /* Check the parameters */
ebrus 0:0a673c671a56 898 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 899 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
ebrus 0:0a673c671a56 900
ebrus 0:0a673c671a56 901 /* Get layer configuration from handle structure */
ebrus 0:0a673c671a56 902 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
ebrus 0:0a673c671a56 903
ebrus 0:0a673c671a56 904 /* Reconfigure the pixel format */
ebrus 0:0a673c671a56 905 pLayerCfg->PixelFormat = Pixelformat;
ebrus 0:0a673c671a56 906
ebrus 0:0a673c671a56 907 /* Set LTDC parameters */
ebrus 0:0a673c671a56 908 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
ebrus 0:0a673c671a56 909
ebrus 0:0a673c671a56 910 /* Sets the Reload type */
ebrus 0:0a673c671a56 911 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 912
ebrus 0:0a673c671a56 913 /* Change the LTDC state*/
ebrus 0:0a673c671a56 914 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 915
ebrus 0:0a673c671a56 916 /* Process unlocked */
ebrus 0:0a673c671a56 917 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 918
ebrus 0:0a673c671a56 919 return HAL_OK;
ebrus 0:0a673c671a56 920 }
ebrus 0:0a673c671a56 921
ebrus 0:0a673c671a56 922 /**
ebrus 0:0a673c671a56 923 * @brief Reconfigure the layer alpha value.
ebrus 0:0a673c671a56 924 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 925 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 926 * @param Alpha: new alpha value.
ebrus 0:0a673c671a56 927 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 928 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 929 * 0 or 1
ebrus 0:0a673c671a56 930 * @retval HAL status
ebrus 0:0a673c671a56 931 */
ebrus 0:0a673c671a56 932 HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
ebrus 0:0a673c671a56 933 {
ebrus 0:0a673c671a56 934 LTDC_LayerCfgTypeDef *pLayerCfg;
ebrus 0:0a673c671a56 935
ebrus 0:0a673c671a56 936 /* Process locked */
ebrus 0:0a673c671a56 937 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 938
ebrus 0:0a673c671a56 939 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 940 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 941
ebrus 0:0a673c671a56 942 /* Check the parameters */
ebrus 0:0a673c671a56 943 assert_param(IS_LTDC_ALPHA(Alpha));
ebrus 0:0a673c671a56 944 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 945
ebrus 0:0a673c671a56 946 /* Get layer configuration from handle structure */
ebrus 0:0a673c671a56 947 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
ebrus 0:0a673c671a56 948
ebrus 0:0a673c671a56 949 /* Reconfigure the Alpha value */
ebrus 0:0a673c671a56 950 pLayerCfg->Alpha = Alpha;
ebrus 0:0a673c671a56 951
ebrus 0:0a673c671a56 952 /* Set LTDC parameters */
ebrus 0:0a673c671a56 953 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
ebrus 0:0a673c671a56 954
ebrus 0:0a673c671a56 955 /* Sets the Reload type */
ebrus 0:0a673c671a56 956 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 957
ebrus 0:0a673c671a56 958 /* Change the LTDC state*/
ebrus 0:0a673c671a56 959 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 960
ebrus 0:0a673c671a56 961 /* Process unlocked */
ebrus 0:0a673c671a56 962 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 963
ebrus 0:0a673c671a56 964 return HAL_OK;
ebrus 0:0a673c671a56 965 }
ebrus 0:0a673c671a56 966 /**
ebrus 0:0a673c671a56 967 * @brief Reconfigure the frame buffer Address.
ebrus 0:0a673c671a56 968 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 969 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 970 * @param Address: new address value.
ebrus 0:0a673c671a56 971 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 972 * This parameter can be one of the following values:
ebrus 0:0a673c671a56 973 * 0 or 1.
ebrus 0:0a673c671a56 974 * @retval HAL status
ebrus 0:0a673c671a56 975 */
ebrus 0:0a673c671a56 976 HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
ebrus 0:0a673c671a56 977 {
ebrus 0:0a673c671a56 978 LTDC_LayerCfgTypeDef *pLayerCfg;
ebrus 0:0a673c671a56 979
ebrus 0:0a673c671a56 980 /* Process locked */
ebrus 0:0a673c671a56 981 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 982
ebrus 0:0a673c671a56 983 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 984 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 985
ebrus 0:0a673c671a56 986 /* Check the parameters */
ebrus 0:0a673c671a56 987 assert_param(IS_LTDC_LAYER(LayerIdx));
ebrus 0:0a673c671a56 988
ebrus 0:0a673c671a56 989 /* Get layer configuration from handle structure */
ebrus 0:0a673c671a56 990 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
ebrus 0:0a673c671a56 991
ebrus 0:0a673c671a56 992 /* Reconfigure the Address */
ebrus 0:0a673c671a56 993 pLayerCfg->FBStartAdress = Address;
ebrus 0:0a673c671a56 994
ebrus 0:0a673c671a56 995 /* Set LTDC parameters */
ebrus 0:0a673c671a56 996 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
ebrus 0:0a673c671a56 997
ebrus 0:0a673c671a56 998 /* Sets the Reload type */
ebrus 0:0a673c671a56 999 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
ebrus 0:0a673c671a56 1000
ebrus 0:0a673c671a56 1001 /* Change the LTDC state*/
ebrus 0:0a673c671a56 1002 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 1003
ebrus 0:0a673c671a56 1004 /* Process unlocked */
ebrus 0:0a673c671a56 1005 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 1006
ebrus 0:0a673c671a56 1007 return HAL_OK;
ebrus 0:0a673c671a56 1008 }
ebrus 0:0a673c671a56 1009
ebrus 0:0a673c671a56 1010 /**
ebrus 0:0a673c671a56 1011 * @brief Define the position of the line interrupt .
ebrus 0:0a673c671a56 1012 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 1013 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 1014 * @param Line: Line Interrupt Position.
ebrus 0:0a673c671a56 1015 * @retval HAL status
ebrus 0:0a673c671a56 1016 */
ebrus 0:0a673c671a56 1017 HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line)
ebrus 0:0a673c671a56 1018 {
ebrus 0:0a673c671a56 1019 /* Process locked */
ebrus 0:0a673c671a56 1020 __HAL_LOCK(hltdc);
ebrus 0:0a673c671a56 1021
ebrus 0:0a673c671a56 1022 /* Change LTDC peripheral state */
ebrus 0:0a673c671a56 1023 hltdc->State = HAL_LTDC_STATE_BUSY;
ebrus 0:0a673c671a56 1024
ebrus 0:0a673c671a56 1025 /* Check the parameters */
ebrus 0:0a673c671a56 1026 assert_param(IS_LTDC_LIPOS(Line));
ebrus 0:0a673c671a56 1027
ebrus 0:0a673c671a56 1028 /* Enable the Line interrupt */
ebrus 0:0a673c671a56 1029 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_LI);
ebrus 0:0a673c671a56 1030
ebrus 0:0a673c671a56 1031 /* Sets the Line Interrupt position */
ebrus 0:0a673c671a56 1032 LTDC->LIPCR = (uint32_t)Line;
ebrus 0:0a673c671a56 1033
ebrus 0:0a673c671a56 1034 /* Change the LTDC state*/
ebrus 0:0a673c671a56 1035 hltdc->State = HAL_LTDC_STATE_READY;
ebrus 0:0a673c671a56 1036
ebrus 0:0a673c671a56 1037 /* Process unlocked */
ebrus 0:0a673c671a56 1038 __HAL_UNLOCK(hltdc);
ebrus 0:0a673c671a56 1039
ebrus 0:0a673c671a56 1040 return HAL_OK;
ebrus 0:0a673c671a56 1041 }
ebrus 0:0a673c671a56 1042
ebrus 0:0a673c671a56 1043 /**
ebrus 0:0a673c671a56 1044 * @}
ebrus 0:0a673c671a56 1045 */
ebrus 0:0a673c671a56 1046
ebrus 0:0a673c671a56 1047 /** @defgroup LTDC_Group4 Peripheral State and Errors functions
ebrus 0:0a673c671a56 1048 * @brief Peripheral State and Errors functions
ebrus 0:0a673c671a56 1049 *
ebrus 0:0a673c671a56 1050 @verbatim
ebrus 0:0a673c671a56 1051 ===============================================================================
ebrus 0:0a673c671a56 1052 ##### Peripheral State and Errors functions #####
ebrus 0:0a673c671a56 1053 ===============================================================================
ebrus 0:0a673c671a56 1054 [..]
ebrus 0:0a673c671a56 1055 This subsection provides functions allowing to
ebrus 0:0a673c671a56 1056 (+) Check the LTDC state.
ebrus 0:0a673c671a56 1057 (+) Get error code.
ebrus 0:0a673c671a56 1058
ebrus 0:0a673c671a56 1059 @endverbatim
ebrus 0:0a673c671a56 1060 * @{
ebrus 0:0a673c671a56 1061 */
ebrus 0:0a673c671a56 1062
ebrus 0:0a673c671a56 1063 /**
ebrus 0:0a673c671a56 1064 * @brief Return the LTDC state
ebrus 0:0a673c671a56 1065 * @param hltdc: pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 1066 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 1067 * @retval HAL state
ebrus 0:0a673c671a56 1068 */
ebrus 0:0a673c671a56 1069 HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc)
ebrus 0:0a673c671a56 1070 {
ebrus 0:0a673c671a56 1071 return hltdc->State;
ebrus 0:0a673c671a56 1072 }
ebrus 0:0a673c671a56 1073
ebrus 0:0a673c671a56 1074 /**
ebrus 0:0a673c671a56 1075 * @brief Return the LTDC error code
ebrus 0:0a673c671a56 1076 * @param hltdc : pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 1077 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 1078 * @retval LTDC Error Code
ebrus 0:0a673c671a56 1079 */
ebrus 0:0a673c671a56 1080 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc)
ebrus 0:0a673c671a56 1081 {
ebrus 0:0a673c671a56 1082 return hltdc->ErrorCode;
ebrus 0:0a673c671a56 1083 }
ebrus 0:0a673c671a56 1084
ebrus 0:0a673c671a56 1085 /**
ebrus 0:0a673c671a56 1086 * @}
ebrus 0:0a673c671a56 1087 */
ebrus 0:0a673c671a56 1088
ebrus 0:0a673c671a56 1089 /**
ebrus 0:0a673c671a56 1090 * @brief Configures the LTDC peripheral
ebrus 0:0a673c671a56 1091 * @param hltdc : Pointer to a LTDC_HandleTypeDef structure that contains
ebrus 0:0a673c671a56 1092 * the configuration information for the LTDC.
ebrus 0:0a673c671a56 1093 * @param pLayerCfg: Pointer LTDC Layer Configuration strusture
ebrus 0:0a673c671a56 1094 * @param LayerIdx: LTDC Layer index.
ebrus 0:0a673c671a56 1095 * This parameter can be one of the following values: 0 or 1
ebrus 0:0a673c671a56 1096 * @retval None
ebrus 0:0a673c671a56 1097 */
ebrus 0:0a673c671a56 1098 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
ebrus 0:0a673c671a56 1099 {
ebrus 0:0a673c671a56 1100 uint32_t tmp = 0;
ebrus 0:0a673c671a56 1101 uint32_t tmp1 = 0;
ebrus 0:0a673c671a56 1102 uint32_t tmp2 = 0;
ebrus 0:0a673c671a56 1103
ebrus 0:0a673c671a56 1104 /* Configures the horizontal start and stop position */
ebrus 0:0a673c671a56 1105 tmp = ((pLayerCfg->WindowX1 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16)) << 16);
ebrus 0:0a673c671a56 1106 __HAL_LTDC_LAYER(hltdc, LayerIdx)->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
ebrus 0:0a673c671a56 1107 __HAL_LTDC_LAYER(hltdc, LayerIdx)->WHPCR = ((pLayerCfg->WindowX0 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16) + 1) | tmp);
ebrus 0:0a673c671a56 1108
ebrus 0:0a673c671a56 1109 /* Configures the vertical start and stop position */
ebrus 0:0a673c671a56 1110 tmp = ((pLayerCfg->WindowY1 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP)) << 16);
ebrus 0:0a673c671a56 1111 __HAL_LTDC_LAYER(hltdc, LayerIdx)->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
ebrus 0:0a673c671a56 1112 __HAL_LTDC_LAYER(hltdc, LayerIdx)->WVPCR = ((pLayerCfg->WindowY0 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP) + 1) | tmp);
ebrus 0:0a673c671a56 1113
ebrus 0:0a673c671a56 1114 /* Specifies the pixel format */
ebrus 0:0a673c671a56 1115 __HAL_LTDC_LAYER(hltdc, LayerIdx)->PFCR &= ~(LTDC_LxPFCR_PF);
ebrus 0:0a673c671a56 1116 __HAL_LTDC_LAYER(hltdc, LayerIdx)->PFCR = (pLayerCfg->PixelFormat);
ebrus 0:0a673c671a56 1117
ebrus 0:0a673c671a56 1118 /* Configures the default color values */
ebrus 0:0a673c671a56 1119 tmp = ((uint32_t)(pLayerCfg->Backcolor.Green) << 8);
ebrus 0:0a673c671a56 1120 tmp1 = ((uint32_t)(pLayerCfg->Backcolor.Red) << 16);
ebrus 0:0a673c671a56 1121 tmp2 = (pLayerCfg->Alpha0 << 24);
ebrus 0:0a673c671a56 1122 __HAL_LTDC_LAYER(hltdc, LayerIdx)->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA);
ebrus 0:0a673c671a56 1123 __HAL_LTDC_LAYER(hltdc, LayerIdx)->DCCR = (pLayerCfg->Backcolor.Blue | tmp | tmp1 | tmp2);
ebrus 0:0a673c671a56 1124
ebrus 0:0a673c671a56 1125 /* Specifies the constant alpha value */
ebrus 0:0a673c671a56 1126 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CACR &= ~(LTDC_LxCACR_CONSTA);
ebrus 0:0a673c671a56 1127 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CACR = (pLayerCfg->Alpha);
ebrus 0:0a673c671a56 1128
ebrus 0:0a673c671a56 1129 /* Specifies the blending factors */
ebrus 0:0a673c671a56 1130 __HAL_LTDC_LAYER(hltdc, LayerIdx)->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
ebrus 0:0a673c671a56 1131 __HAL_LTDC_LAYER(hltdc, LayerIdx)->BFCR = (pLayerCfg->BlendingFactor1 | pLayerCfg->BlendingFactor2);
ebrus 0:0a673c671a56 1132
ebrus 0:0a673c671a56 1133 /* Configures the color frame buffer start address */
ebrus 0:0a673c671a56 1134 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
ebrus 0:0a673c671a56 1135 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBAR = (pLayerCfg->FBStartAdress);
ebrus 0:0a673c671a56 1136
ebrus 0:0a673c671a56 1137 if(pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
ebrus 0:0a673c671a56 1138 {
ebrus 0:0a673c671a56 1139 tmp = 4;
ebrus 0:0a673c671a56 1140 }
ebrus 0:0a673c671a56 1141 else if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
ebrus 0:0a673c671a56 1142 {
ebrus 0:0a673c671a56 1143 tmp = 3;
ebrus 0:0a673c671a56 1144 }
ebrus 0:0a673c671a56 1145 else if((pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
ebrus 0:0a673c671a56 1146 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
ebrus 0:0a673c671a56 1147 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
ebrus 0:0a673c671a56 1148 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_AL88))
ebrus 0:0a673c671a56 1149 {
ebrus 0:0a673c671a56 1150 tmp = 2;
ebrus 0:0a673c671a56 1151 }
ebrus 0:0a673c671a56 1152 else
ebrus 0:0a673c671a56 1153 {
ebrus 0:0a673c671a56 1154 tmp = 1;
ebrus 0:0a673c671a56 1155 }
ebrus 0:0a673c671a56 1156
ebrus 0:0a673c671a56 1157 /* Configures the color frame buffer pitch in byte */
ebrus 0:0a673c671a56 1158 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
ebrus 0:0a673c671a56 1159 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBLR = (((pLayerCfg->ImageWidth * tmp) << 16) | ((pLayerCfg->ImageWidth * tmp) + 3));
ebrus 0:0a673c671a56 1160
ebrus 0:0a673c671a56 1161 /* Configures the frame buffer line number */
ebrus 0:0a673c671a56 1162 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR);
ebrus 0:0a673c671a56 1163 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CFBLNR = (pLayerCfg->ImageHeight);
ebrus 0:0a673c671a56 1164
ebrus 0:0a673c671a56 1165 /* Enable LTDC_Layer by setting LEN bit */
ebrus 0:0a673c671a56 1166 __HAL_LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_LEN;
ebrus 0:0a673c671a56 1167 }
ebrus 0:0a673c671a56 1168
ebrus 0:0a673c671a56 1169 /**
ebrus 0:0a673c671a56 1170 * @}
ebrus 0:0a673c671a56 1171 */
ebrus 0:0a673c671a56 1172 #endif /* STM32F429xx || STM32F439xx */
ebrus 0:0a673c671a56 1173 #endif /* HAL_LTDC_MODULE_ENABLED */
ebrus 0:0a673c671a56 1174 /**
ebrus 0:0a673c671a56 1175 * @}
ebrus 0:0a673c671a56 1176 */
ebrus 0:0a673c671a56 1177
ebrus 0:0a673c671a56 1178 /**
ebrus 0:0a673c671a56 1179 * @}
ebrus 0:0a673c671a56 1180 */
ebrus 0:0a673c671a56 1181
ebrus 0:0a673c671a56 1182 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/