inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NYX 0:85b3fd62ea1a 1 /**
NYX 0:85b3fd62ea1a 2 ******************************************************************************
NYX 0:85b3fd62ea1a 3 * @file stm32f4xx_hal_ltdc.c
NYX 0:85b3fd62ea1a 4 * @author MCD Application Team
NYX 0:85b3fd62ea1a 5 * @version V1.7.1
NYX 0:85b3fd62ea1a 6 * @date 14-April-2017
NYX 0:85b3fd62ea1a 7 * @brief LTDC HAL module driver.
NYX 0:85b3fd62ea1a 8 * This file provides firmware functions to manage the following
NYX 0:85b3fd62ea1a 9 * functionalities of the LTDC peripheral:
NYX 0:85b3fd62ea1a 10 * + Initialization and de-initialization functions
NYX 0:85b3fd62ea1a 11 * + IO operation functions
NYX 0:85b3fd62ea1a 12 * + Peripheral Control functions
NYX 0:85b3fd62ea1a 13 * + Peripheral State and Errors functions
NYX 0:85b3fd62ea1a 14 *
NYX 0:85b3fd62ea1a 15 @verbatim
NYX 0:85b3fd62ea1a 16 ==============================================================================
NYX 0:85b3fd62ea1a 17 ##### How to use this driver #####
NYX 0:85b3fd62ea1a 18 ==============================================================================
NYX 0:85b3fd62ea1a 19 [..]
NYX 0:85b3fd62ea1a 20 (#) Program the required configuration through the following parameters:
NYX 0:85b3fd62ea1a 21 the LTDC timing, the horizontal and vertical polarity,
NYX 0:85b3fd62ea1a 22 the pixel clock polarity, Data Enable polarity and the LTDC background color value
NYX 0:85b3fd62ea1a 23 using HAL_LTDC_Init() function
NYX 0:85b3fd62ea1a 24
NYX 0:85b3fd62ea1a 25 (#) Program the required configuration through the following parameters:
NYX 0:85b3fd62ea1a 26 the pixel format, the blending factors, input alpha value, the window size
NYX 0:85b3fd62ea1a 27 and the image size using HAL_LTDC_ConfigLayer() function for foreground
NYX 0:85b3fd62ea1a 28 or/and background layer.
NYX 0:85b3fd62ea1a 29
NYX 0:85b3fd62ea1a 30 (#) Optionally, configure and enable the CLUT using HAL_LTDC_ConfigCLUT() and
NYX 0:85b3fd62ea1a 31 HAL_LTDC_EnableCLUT functions.
NYX 0:85b3fd62ea1a 32
NYX 0:85b3fd62ea1a 33 (#) Optionally, enable the Dither using HAL_LTDC_EnableDither().
NYX 0:85b3fd62ea1a 34
NYX 0:85b3fd62ea1a 35 (#) Optionally, configure and enable the Color keying using HAL_LTDC_ConfigColorKeying()
NYX 0:85b3fd62ea1a 36 and HAL_LTDC_EnableColorKeying functions.
NYX 0:85b3fd62ea1a 37
NYX 0:85b3fd62ea1a 38 (#) Optionally, configure LineInterrupt using HAL_LTDC_ProgramLineEvent()
NYX 0:85b3fd62ea1a 39 function
NYX 0:85b3fd62ea1a 40
NYX 0:85b3fd62ea1a 41 (#) If needed, reconfigure and change the pixel format value, the alpha value
NYX 0:85b3fd62ea1a 42 value, the window size, the window position and the layer start address
NYX 0:85b3fd62ea1a 43 for foreground or/and background layer using respectively the following
NYX 0:85b3fd62ea1a 44 functions: HAL_LTDC_SetPixelFormat(), HAL_LTDC_SetAlpha(), HAL_LTDC_SetWindowSize(),
NYX 0:85b3fd62ea1a 45 HAL_LTDC_SetWindowPosition(), HAL_LTDC_SetAddress.
NYX 0:85b3fd62ea1a 46
NYX 0:85b3fd62ea1a 47 (#) Variant functions with “_NoReload” post fix allows to set the LTDC configuration/settings without immediate reload.
NYX 0:85b3fd62ea1a 48 This is useful in case when the program requires to modify serval LTDC settings (on one or both layers)
NYX 0:85b3fd62ea1a 49 then applying(reload) these settings in one shot by calling the function “HAL_LTDC_Reload”
NYX 0:85b3fd62ea1a 50
NYX 0:85b3fd62ea1a 51 After calling the “_NoReload” functions to set different color/format/layer settings,
NYX 0:85b3fd62ea1a 52 the program can call the function “HAL_LTDC_Reload” To apply(Reload) these settings.
NYX 0:85b3fd62ea1a 53 Function “HAL_LTDC_Reload” can be called with the parameter “ReloadType”
NYX 0:85b3fd62ea1a 54 set to LTDC_RELOAD_IMMEDIATE if an immediate reload is required.
NYX 0:85b3fd62ea1a 55 Function “HAL_LTDC_Reload” can be called with the parameter “ReloadType”
NYX 0:85b3fd62ea1a 56 set to LTDC_RELOAD_VERTICAL_BLANKING if the reload should be done in the next vertical blanking period,
NYX 0:85b3fd62ea1a 57 this option allows to avoid display flicker by applying the new settings during the vertical blanking period.
NYX 0:85b3fd62ea1a 58
NYX 0:85b3fd62ea1a 59
NYX 0:85b3fd62ea1a 60 (#) To control LTDC state you can use the following function: HAL_LTDC_GetState()
NYX 0:85b3fd62ea1a 61
NYX 0:85b3fd62ea1a 62 *** LTDC HAL driver macros list ***
NYX 0:85b3fd62ea1a 63 =============================================
NYX 0:85b3fd62ea1a 64 [..]
NYX 0:85b3fd62ea1a 65 Below the list of most used macros in LTDC HAL driver.
NYX 0:85b3fd62ea1a 66
NYX 0:85b3fd62ea1a 67 (+) __HAL_LTDC_ENABLE: Enable the LTDC.
NYX 0:85b3fd62ea1a 68 (+) __HAL_LTDC_DISABLE: Disable the LTDC.
NYX 0:85b3fd62ea1a 69 (+) __HAL_LTDC_LAYER_ENABLE: Enable a LTDC Layer.
NYX 0:85b3fd62ea1a 70 (+) __HAL_LTDC_LAYER_DISABLE: Disable a LTDC Layer.
NYX 0:85b3fd62ea1a 71 (+) __HAL_LTDC_CLEAR_FLAG: Clear the LTDC pending flags.
NYX 0:85b3fd62ea1a 72 (+) __HAL_LTDC_ENABLE_IT: Enable the specified LTDC interrupts.
NYX 0:85b3fd62ea1a 73 (+) __HAL_LTDC_DISABLE_IT: Disable the specified LTDC interrupts.
NYX 0:85b3fd62ea1a 74
NYX 0:85b3fd62ea1a 75 [..]
NYX 0:85b3fd62ea1a 76 (@) You can refer to the LTDC HAL driver header file for more useful macros
NYX 0:85b3fd62ea1a 77
NYX 0:85b3fd62ea1a 78 @endverbatim
NYX 0:85b3fd62ea1a 79 ******************************************************************************
NYX 0:85b3fd62ea1a 80 * @attention
NYX 0:85b3fd62ea1a 81 *
NYX 0:85b3fd62ea1a 82 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
NYX 0:85b3fd62ea1a 83 *
NYX 0:85b3fd62ea1a 84 * Redistribution and use in source and binary forms, with or without modification,
NYX 0:85b3fd62ea1a 85 * are permitted provided that the following conditions are met:
NYX 0:85b3fd62ea1a 86 * 1. Redistributions of source code must retain the above copyright notice,
NYX 0:85b3fd62ea1a 87 * this list of conditions and the following disclaimer.
NYX 0:85b3fd62ea1a 88 * 2. Redistributions in binary form must reproduce the above copyright notice,
NYX 0:85b3fd62ea1a 89 * this list of conditions and the following disclaimer in the documentation
NYX 0:85b3fd62ea1a 90 * and/or other materials provided with the distribution.
NYX 0:85b3fd62ea1a 91 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NYX 0:85b3fd62ea1a 92 * may be used to endorse or promote products derived from this software
NYX 0:85b3fd62ea1a 93 * without specific prior written permission.
NYX 0:85b3fd62ea1a 94 *
NYX 0:85b3fd62ea1a 95 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NYX 0:85b3fd62ea1a 96 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NYX 0:85b3fd62ea1a 97 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NYX 0:85b3fd62ea1a 98 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NYX 0:85b3fd62ea1a 99 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NYX 0:85b3fd62ea1a 100 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NYX 0:85b3fd62ea1a 101 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NYX 0:85b3fd62ea1a 102 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NYX 0:85b3fd62ea1a 103 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NYX 0:85b3fd62ea1a 104 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NYX 0:85b3fd62ea1a 105 *
NYX 0:85b3fd62ea1a 106 ******************************************************************************
NYX 0:85b3fd62ea1a 107 */
NYX 0:85b3fd62ea1a 108
NYX 0:85b3fd62ea1a 109 /* Includes ------------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 110 #include "stm32f4xx_hal.h"
NYX 0:85b3fd62ea1a 111
NYX 0:85b3fd62ea1a 112 /** @addtogroup STM32F4xx_HAL_Driver
NYX 0:85b3fd62ea1a 113 * @{
NYX 0:85b3fd62ea1a 114 */
NYX 0:85b3fd62ea1a 115 /** @defgroup LTDC LTDC
NYX 0:85b3fd62ea1a 116 * @brief LTDC HAL module driver
NYX 0:85b3fd62ea1a 117 * @{
NYX 0:85b3fd62ea1a 118 */
NYX 0:85b3fd62ea1a 119
NYX 0:85b3fd62ea1a 120 #ifdef HAL_LTDC_MODULE_ENABLED
NYX 0:85b3fd62ea1a 121
NYX 0:85b3fd62ea1a 122 #if defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
NYX 0:85b3fd62ea1a 123
NYX 0:85b3fd62ea1a 124 /* Private typedef -----------------------------------------------------------*/
NYX 0:85b3fd62ea1a 125 /* Private define ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 126 /* Private macro -------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 127 /* Private variables ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 128 /* Private function prototypes -----------------------------------------------*/
NYX 0:85b3fd62ea1a 129 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx);
NYX 0:85b3fd62ea1a 130 /* Private functions ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 131
NYX 0:85b3fd62ea1a 132 /** @defgroup LTDC_Exported_Functions LTDC Exported Functions
NYX 0:85b3fd62ea1a 133 * @{
NYX 0:85b3fd62ea1a 134 */
NYX 0:85b3fd62ea1a 135
NYX 0:85b3fd62ea1a 136 /** @defgroup LTDC_Exported_Functions_Group1 Initialization and Configuration functions
NYX 0:85b3fd62ea1a 137 * @brief Initialization and Configuration functions
NYX 0:85b3fd62ea1a 138 *
NYX 0:85b3fd62ea1a 139 @verbatim
NYX 0:85b3fd62ea1a 140 ===============================================================================
NYX 0:85b3fd62ea1a 141 ##### Initialization and Configuration functions #####
NYX 0:85b3fd62ea1a 142 ===============================================================================
NYX 0:85b3fd62ea1a 143 [..] This section provides functions allowing to:
NYX 0:85b3fd62ea1a 144 (+) Initialize and configure the LTDC
NYX 0:85b3fd62ea1a 145 (+) De-initialize the LTDC
NYX 0:85b3fd62ea1a 146
NYX 0:85b3fd62ea1a 147 @endverbatim
NYX 0:85b3fd62ea1a 148 * @{
NYX 0:85b3fd62ea1a 149 */
NYX 0:85b3fd62ea1a 150
NYX 0:85b3fd62ea1a 151 /**
NYX 0:85b3fd62ea1a 152 * @brief Initialize the LTDC according to the specified parameters in the LTDC_InitTypeDef.
NYX 0:85b3fd62ea1a 153 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 154 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 155 * @retval HAL status
NYX 0:85b3fd62ea1a 156 */
NYX 0:85b3fd62ea1a 157 HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 158 {
NYX 0:85b3fd62ea1a 159 uint32_t tmp = 0U, tmp1 = 0U;
NYX 0:85b3fd62ea1a 160
NYX 0:85b3fd62ea1a 161 /* Check the LTDC peripheral state */
NYX 0:85b3fd62ea1a 162 if(hltdc == NULL)
NYX 0:85b3fd62ea1a 163 {
NYX 0:85b3fd62ea1a 164 return HAL_ERROR;
NYX 0:85b3fd62ea1a 165 }
NYX 0:85b3fd62ea1a 166
NYX 0:85b3fd62ea1a 167 /* Check function parameters */
NYX 0:85b3fd62ea1a 168 assert_param(IS_LTDC_ALL_INSTANCE(hltdc->Instance));
NYX 0:85b3fd62ea1a 169 assert_param(IS_LTDC_HSYNC(hltdc->Init.HorizontalSync));
NYX 0:85b3fd62ea1a 170 assert_param(IS_LTDC_VSYNC(hltdc->Init.VerticalSync));
NYX 0:85b3fd62ea1a 171 assert_param(IS_LTDC_AHBP(hltdc->Init.AccumulatedHBP));
NYX 0:85b3fd62ea1a 172 assert_param(IS_LTDC_AVBP(hltdc->Init.AccumulatedVBP));
NYX 0:85b3fd62ea1a 173 assert_param(IS_LTDC_AAH(hltdc->Init.AccumulatedActiveH));
NYX 0:85b3fd62ea1a 174 assert_param(IS_LTDC_AAW(hltdc->Init.AccumulatedActiveW));
NYX 0:85b3fd62ea1a 175 assert_param(IS_LTDC_TOTALH(hltdc->Init.TotalHeigh));
NYX 0:85b3fd62ea1a 176 assert_param(IS_LTDC_TOTALW(hltdc->Init.TotalWidth));
NYX 0:85b3fd62ea1a 177 assert_param(IS_LTDC_HSPOL(hltdc->Init.HSPolarity));
NYX 0:85b3fd62ea1a 178 assert_param(IS_LTDC_VSPOL(hltdc->Init.VSPolarity));
NYX 0:85b3fd62ea1a 179 assert_param(IS_LTDC_DEPOL(hltdc->Init.DEPolarity));
NYX 0:85b3fd62ea1a 180 assert_param(IS_LTDC_PCPOL(hltdc->Init.PCPolarity));
NYX 0:85b3fd62ea1a 181
NYX 0:85b3fd62ea1a 182 if(hltdc->State == HAL_LTDC_STATE_RESET)
NYX 0:85b3fd62ea1a 183 {
NYX 0:85b3fd62ea1a 184 /* Allocate lock resource and initialize it */
NYX 0:85b3fd62ea1a 185 hltdc->Lock = HAL_UNLOCKED;
NYX 0:85b3fd62ea1a 186 /* Init the low level hardware */
NYX 0:85b3fd62ea1a 187 HAL_LTDC_MspInit(hltdc);
NYX 0:85b3fd62ea1a 188 }
NYX 0:85b3fd62ea1a 189
NYX 0:85b3fd62ea1a 190 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 191 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 192
NYX 0:85b3fd62ea1a 193 /* Configure the HS, VS, DE and PC polarity */
NYX 0:85b3fd62ea1a 194 hltdc->Instance->GCR &= ~(LTDC_GCR_HSPOL | LTDC_GCR_VSPOL | LTDC_GCR_DEPOL | LTDC_GCR_PCPOL);
NYX 0:85b3fd62ea1a 195 hltdc->Instance->GCR |= (uint32_t)(hltdc->Init.HSPolarity | hltdc->Init.VSPolarity | \
NYX 0:85b3fd62ea1a 196 hltdc->Init.DEPolarity | hltdc->Init.PCPolarity);
NYX 0:85b3fd62ea1a 197
NYX 0:85b3fd62ea1a 198 /* Set Synchronization size */
NYX 0:85b3fd62ea1a 199 hltdc->Instance->SSCR &= ~(LTDC_SSCR_VSH | LTDC_SSCR_HSW);
NYX 0:85b3fd62ea1a 200 tmp = (hltdc->Init.HorizontalSync << 16U);
NYX 0:85b3fd62ea1a 201 hltdc->Instance->SSCR |= (tmp | hltdc->Init.VerticalSync);
NYX 0:85b3fd62ea1a 202
NYX 0:85b3fd62ea1a 203 /* Set Accumulated Back porch */
NYX 0:85b3fd62ea1a 204 hltdc->Instance->BPCR &= ~(LTDC_BPCR_AVBP | LTDC_BPCR_AHBP);
NYX 0:85b3fd62ea1a 205 tmp = (hltdc->Init.AccumulatedHBP << 16U);
NYX 0:85b3fd62ea1a 206 hltdc->Instance->BPCR |= (tmp | hltdc->Init.AccumulatedVBP);
NYX 0:85b3fd62ea1a 207
NYX 0:85b3fd62ea1a 208 /* Set Accumulated Active Width */
NYX 0:85b3fd62ea1a 209 hltdc->Instance->AWCR &= ~(LTDC_AWCR_AAH | LTDC_AWCR_AAW);
NYX 0:85b3fd62ea1a 210 tmp = (hltdc->Init.AccumulatedActiveW << 16U);
NYX 0:85b3fd62ea1a 211 hltdc->Instance->AWCR |= (tmp | hltdc->Init.AccumulatedActiveH);
NYX 0:85b3fd62ea1a 212
NYX 0:85b3fd62ea1a 213 /* Set Total Width */
NYX 0:85b3fd62ea1a 214 hltdc->Instance->TWCR &= ~(LTDC_TWCR_TOTALH | LTDC_TWCR_TOTALW);
NYX 0:85b3fd62ea1a 215 tmp = (hltdc->Init.TotalWidth << 16U);
NYX 0:85b3fd62ea1a 216 hltdc->Instance->TWCR |= (tmp | hltdc->Init.TotalHeigh);
NYX 0:85b3fd62ea1a 217
NYX 0:85b3fd62ea1a 218 /* Set the background color value */
NYX 0:85b3fd62ea1a 219 tmp = ((uint32_t)(hltdc->Init.Backcolor.Green) << 8U);
NYX 0:85b3fd62ea1a 220 tmp1 = ((uint32_t)(hltdc->Init.Backcolor.Red) << 16U);
NYX 0:85b3fd62ea1a 221 hltdc->Instance->BCCR &= ~(LTDC_BCCR_BCBLUE | LTDC_BCCR_BCGREEN | LTDC_BCCR_BCRED);
NYX 0:85b3fd62ea1a 222 hltdc->Instance->BCCR |= (tmp1 | tmp | hltdc->Init.Backcolor.Blue);
NYX 0:85b3fd62ea1a 223
NYX 0:85b3fd62ea1a 224 /* Enable the Transfer Error and FIFO underrun interrupts */
NYX 0:85b3fd62ea1a 225 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_TE | LTDC_IT_FU);
NYX 0:85b3fd62ea1a 226
NYX 0:85b3fd62ea1a 227 /* Enable LTDC by setting LTDCEN bit */
NYX 0:85b3fd62ea1a 228 __HAL_LTDC_ENABLE(hltdc);
NYX 0:85b3fd62ea1a 229
NYX 0:85b3fd62ea1a 230 /* Initialize the error code */
NYX 0:85b3fd62ea1a 231 hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
NYX 0:85b3fd62ea1a 232
NYX 0:85b3fd62ea1a 233 /* Initialize the LTDC state*/
NYX 0:85b3fd62ea1a 234 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 235
NYX 0:85b3fd62ea1a 236 return HAL_OK;
NYX 0:85b3fd62ea1a 237 }
NYX 0:85b3fd62ea1a 238
NYX 0:85b3fd62ea1a 239 /**
NYX 0:85b3fd62ea1a 240 * @brief De-initialize the LTDC peripheral.
NYX 0:85b3fd62ea1a 241 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 242 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 243 * @retval None
NYX 0:85b3fd62ea1a 244 */
NYX 0:85b3fd62ea1a 245
NYX 0:85b3fd62ea1a 246 HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 247 {
NYX 0:85b3fd62ea1a 248 /* DeInit the low level hardware */
NYX 0:85b3fd62ea1a 249 HAL_LTDC_MspDeInit(hltdc);
NYX 0:85b3fd62ea1a 250
NYX 0:85b3fd62ea1a 251 /* Initialize the error code */
NYX 0:85b3fd62ea1a 252 hltdc->ErrorCode = HAL_LTDC_ERROR_NONE;
NYX 0:85b3fd62ea1a 253
NYX 0:85b3fd62ea1a 254 /* Initialize the LTDC state*/
NYX 0:85b3fd62ea1a 255 hltdc->State = HAL_LTDC_STATE_RESET;
NYX 0:85b3fd62ea1a 256
NYX 0:85b3fd62ea1a 257 /* Release Lock */
NYX 0:85b3fd62ea1a 258 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 259
NYX 0:85b3fd62ea1a 260 return HAL_OK;
NYX 0:85b3fd62ea1a 261 }
NYX 0:85b3fd62ea1a 262
NYX 0:85b3fd62ea1a 263 /**
NYX 0:85b3fd62ea1a 264 * @brief Initialize the LTDC MSP.
NYX 0:85b3fd62ea1a 265 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 266 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 267 * @retval None
NYX 0:85b3fd62ea1a 268 */
NYX 0:85b3fd62ea1a 269 __weak void HAL_LTDC_MspInit(LTDC_HandleTypeDef* hltdc)
NYX 0:85b3fd62ea1a 270 {
NYX 0:85b3fd62ea1a 271 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 272 UNUSED(hltdc);
NYX 0:85b3fd62ea1a 273
NYX 0:85b3fd62ea1a 274 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 275 the HAL_LTDC_MspInit could be implemented in the user file
NYX 0:85b3fd62ea1a 276 */
NYX 0:85b3fd62ea1a 277 }
NYX 0:85b3fd62ea1a 278
NYX 0:85b3fd62ea1a 279 /**
NYX 0:85b3fd62ea1a 280 * @brief De-initialize the LTDC MSP.
NYX 0:85b3fd62ea1a 281 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 282 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 283 * @retval None
NYX 0:85b3fd62ea1a 284 */
NYX 0:85b3fd62ea1a 285 __weak void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* hltdc)
NYX 0:85b3fd62ea1a 286 {
NYX 0:85b3fd62ea1a 287 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 288 UNUSED(hltdc);
NYX 0:85b3fd62ea1a 289
NYX 0:85b3fd62ea1a 290 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 291 the HAL_LTDC_MspDeInit could be implemented in the user file
NYX 0:85b3fd62ea1a 292 */
NYX 0:85b3fd62ea1a 293 }
NYX 0:85b3fd62ea1a 294
NYX 0:85b3fd62ea1a 295 /**
NYX 0:85b3fd62ea1a 296 * @}
NYX 0:85b3fd62ea1a 297 */
NYX 0:85b3fd62ea1a 298
NYX 0:85b3fd62ea1a 299 /** @defgroup LTDC_Exported_Functions_Group2 IO operation functions
NYX 0:85b3fd62ea1a 300 * @brief IO operation functions
NYX 0:85b3fd62ea1a 301 *
NYX 0:85b3fd62ea1a 302 @verbatim
NYX 0:85b3fd62ea1a 303 ===============================================================================
NYX 0:85b3fd62ea1a 304 ##### IO operation functions #####
NYX 0:85b3fd62ea1a 305 ===============================================================================
NYX 0:85b3fd62ea1a 306 [..] This section provides function allowing to:
NYX 0:85b3fd62ea1a 307 (+) Handle LTDC interrupt request
NYX 0:85b3fd62ea1a 308
NYX 0:85b3fd62ea1a 309 @endverbatim
NYX 0:85b3fd62ea1a 310 * @{
NYX 0:85b3fd62ea1a 311 */
NYX 0:85b3fd62ea1a 312 /**
NYX 0:85b3fd62ea1a 313 * @brief Handle LTDC interrupt request.
NYX 0:85b3fd62ea1a 314 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 315 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 316 * @retval HAL status
NYX 0:85b3fd62ea1a 317 */
NYX 0:85b3fd62ea1a 318 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 319 {
NYX 0:85b3fd62ea1a 320 uint32_t isrflags = READ_REG(hltdc->Instance->ISR);
NYX 0:85b3fd62ea1a 321 uint32_t itsources = READ_REG(hltdc->Instance->IER);
NYX 0:85b3fd62ea1a 322
NYX 0:85b3fd62ea1a 323 /* Transfer Error Interrupt management ***************************************/
NYX 0:85b3fd62ea1a 324 if(((isrflags & LTDC_ISR_TERRIF) != RESET) && ((itsources & LTDC_IER_TERRIE) != RESET))
NYX 0:85b3fd62ea1a 325 {
NYX 0:85b3fd62ea1a 326 /* Disable the transfer Error interrupt */
NYX 0:85b3fd62ea1a 327 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_TE);
NYX 0:85b3fd62ea1a 328
NYX 0:85b3fd62ea1a 329 /* Clear the transfer error flag */
NYX 0:85b3fd62ea1a 330 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_TE);
NYX 0:85b3fd62ea1a 331
NYX 0:85b3fd62ea1a 332 /* Update error code */
NYX 0:85b3fd62ea1a 333 hltdc->ErrorCode |= HAL_LTDC_ERROR_TE;
NYX 0:85b3fd62ea1a 334
NYX 0:85b3fd62ea1a 335 /* Change LTDC state */
NYX 0:85b3fd62ea1a 336 hltdc->State = HAL_LTDC_STATE_ERROR;
NYX 0:85b3fd62ea1a 337
NYX 0:85b3fd62ea1a 338 /* Process unlocked */
NYX 0:85b3fd62ea1a 339 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 340
NYX 0:85b3fd62ea1a 341 /* Transfer error Callback */
NYX 0:85b3fd62ea1a 342 HAL_LTDC_ErrorCallback(hltdc);
NYX 0:85b3fd62ea1a 343 }
NYX 0:85b3fd62ea1a 344
NYX 0:85b3fd62ea1a 345 /* FIFO underrun Interrupt management ***************************************/
NYX 0:85b3fd62ea1a 346 if(((isrflags & LTDC_ISR_FUIF) != RESET) && ((itsources & LTDC_IER_FUIE) != RESET))
NYX 0:85b3fd62ea1a 347 {
NYX 0:85b3fd62ea1a 348 /* Disable the FIFO underrun interrupt */
NYX 0:85b3fd62ea1a 349 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_FU);
NYX 0:85b3fd62ea1a 350
NYX 0:85b3fd62ea1a 351 /* Clear the FIFO underrun flag */
NYX 0:85b3fd62ea1a 352 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_FU);
NYX 0:85b3fd62ea1a 353
NYX 0:85b3fd62ea1a 354 /* Update error code */
NYX 0:85b3fd62ea1a 355 hltdc->ErrorCode |= HAL_LTDC_ERROR_FU;
NYX 0:85b3fd62ea1a 356
NYX 0:85b3fd62ea1a 357 /* Change LTDC state */
NYX 0:85b3fd62ea1a 358 hltdc->State = HAL_LTDC_STATE_ERROR;
NYX 0:85b3fd62ea1a 359
NYX 0:85b3fd62ea1a 360 /* Process unlocked */
NYX 0:85b3fd62ea1a 361 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 362
NYX 0:85b3fd62ea1a 363 /* Transfer error Callback */
NYX 0:85b3fd62ea1a 364 HAL_LTDC_ErrorCallback(hltdc);
NYX 0:85b3fd62ea1a 365 }
NYX 0:85b3fd62ea1a 366
NYX 0:85b3fd62ea1a 367 /* Line Interrupt management ************************************************/
NYX 0:85b3fd62ea1a 368 if(((isrflags & LTDC_ISR_LIF) != RESET) && ((itsources & LTDC_IER_LIE) != RESET))
NYX 0:85b3fd62ea1a 369 {
NYX 0:85b3fd62ea1a 370 /* Disable the Line interrupt */
NYX 0:85b3fd62ea1a 371 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
NYX 0:85b3fd62ea1a 372
NYX 0:85b3fd62ea1a 373 /* Clear the Line interrupt flag */
NYX 0:85b3fd62ea1a 374 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_LI);
NYX 0:85b3fd62ea1a 375
NYX 0:85b3fd62ea1a 376 /* Change LTDC state */
NYX 0:85b3fd62ea1a 377 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 378
NYX 0:85b3fd62ea1a 379 /* Process unlocked */
NYX 0:85b3fd62ea1a 380 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 381
NYX 0:85b3fd62ea1a 382 /* Line interrupt Callback */
NYX 0:85b3fd62ea1a 383 HAL_LTDC_LineEventCallback(hltdc);
NYX 0:85b3fd62ea1a 384 }
NYX 0:85b3fd62ea1a 385
NYX 0:85b3fd62ea1a 386 /* Register reload Interrupt management ***************************************/
NYX 0:85b3fd62ea1a 387 if(((isrflags & LTDC_ISR_RRIF) != RESET) && ((itsources & LTDC_IER_RRIE) != RESET))
NYX 0:85b3fd62ea1a 388 {
NYX 0:85b3fd62ea1a 389 /* Disable the register reload interrupt */
NYX 0:85b3fd62ea1a 390 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_RR);
NYX 0:85b3fd62ea1a 391
NYX 0:85b3fd62ea1a 392 /* Clear the register reload flag */
NYX 0:85b3fd62ea1a 393 __HAL_LTDC_CLEAR_FLAG(hltdc, LTDC_FLAG_RR);
NYX 0:85b3fd62ea1a 394
NYX 0:85b3fd62ea1a 395 /* Change LTDC state */
NYX 0:85b3fd62ea1a 396 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 397
NYX 0:85b3fd62ea1a 398 /* Process unlocked */
NYX 0:85b3fd62ea1a 399 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 400
NYX 0:85b3fd62ea1a 401 /* Register reload interrupt Callback */
NYX 0:85b3fd62ea1a 402 HAL_LTDC_ReloadEventCallback(hltdc);
NYX 0:85b3fd62ea1a 403 }
NYX 0:85b3fd62ea1a 404 }
NYX 0:85b3fd62ea1a 405
NYX 0:85b3fd62ea1a 406 /**
NYX 0:85b3fd62ea1a 407 * @brief Error LTDC callback.
NYX 0:85b3fd62ea1a 408 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 409 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 410 * @retval None
NYX 0:85b3fd62ea1a 411 */
NYX 0:85b3fd62ea1a 412 __weak void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 413 {
NYX 0:85b3fd62ea1a 414 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 415 UNUSED(hltdc);
NYX 0:85b3fd62ea1a 416
NYX 0:85b3fd62ea1a 417 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 418 the HAL_LTDC_ErrorCallback could be implemented in the user file
NYX 0:85b3fd62ea1a 419 */
NYX 0:85b3fd62ea1a 420 }
NYX 0:85b3fd62ea1a 421
NYX 0:85b3fd62ea1a 422 /**
NYX 0:85b3fd62ea1a 423 * @brief Line Event callback.
NYX 0:85b3fd62ea1a 424 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 425 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 426 * @retval None
NYX 0:85b3fd62ea1a 427 */
NYX 0:85b3fd62ea1a 428 __weak void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 429 {
NYX 0:85b3fd62ea1a 430 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 431 UNUSED(hltdc);
NYX 0:85b3fd62ea1a 432
NYX 0:85b3fd62ea1a 433 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 434 the HAL_LTDC_LineEventCallback could be implemented in the user file
NYX 0:85b3fd62ea1a 435 */
NYX 0:85b3fd62ea1a 436 }
NYX 0:85b3fd62ea1a 437
NYX 0:85b3fd62ea1a 438 /**
NYX 0:85b3fd62ea1a 439 * @brief Reload Event callback.
NYX 0:85b3fd62ea1a 440 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 441 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 442 * @retval None
NYX 0:85b3fd62ea1a 443 */
NYX 0:85b3fd62ea1a 444 __weak void HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 445 {
NYX 0:85b3fd62ea1a 446 /* Prevent unused argument(s) compilation warning */
NYX 0:85b3fd62ea1a 447 UNUSED(hltdc);
NYX 0:85b3fd62ea1a 448
NYX 0:85b3fd62ea1a 449 /* NOTE : This function should not be modified, when the callback is needed,
NYX 0:85b3fd62ea1a 450 the HAL_LTDC_ReloadEvenCallback could be implemented in the user file
NYX 0:85b3fd62ea1a 451 */
NYX 0:85b3fd62ea1a 452 }
NYX 0:85b3fd62ea1a 453
NYX 0:85b3fd62ea1a 454 /**
NYX 0:85b3fd62ea1a 455 * @}
NYX 0:85b3fd62ea1a 456 */
NYX 0:85b3fd62ea1a 457
NYX 0:85b3fd62ea1a 458 /** @defgroup LTDC_Exported_Functions_Group3 Peripheral Control functions
NYX 0:85b3fd62ea1a 459 * @brief Peripheral Control functions
NYX 0:85b3fd62ea1a 460 *
NYX 0:85b3fd62ea1a 461 @verbatim
NYX 0:85b3fd62ea1a 462 ===============================================================================
NYX 0:85b3fd62ea1a 463 ##### Peripheral Control functions #####
NYX 0:85b3fd62ea1a 464 ===============================================================================
NYX 0:85b3fd62ea1a 465 [..] This section provides functions allowing to:
NYX 0:85b3fd62ea1a 466 (+) Configure the LTDC foreground or/and background parameters.
NYX 0:85b3fd62ea1a 467 (+) Set the active layer.
NYX 0:85b3fd62ea1a 468 (+) Configure the color keying.
NYX 0:85b3fd62ea1a 469 (+) Configure the C-LUT.
NYX 0:85b3fd62ea1a 470 (+) Enable / Disable the color keying.
NYX 0:85b3fd62ea1a 471 (+) Enable / Disable the C-LUT.
NYX 0:85b3fd62ea1a 472 (+) Update the layer position.
NYX 0:85b3fd62ea1a 473 (+) Update the layer size.
NYX 0:85b3fd62ea1a 474 (+) Update pixel format on the fly.
NYX 0:85b3fd62ea1a 475 (+) Update transparency on the fly.
NYX 0:85b3fd62ea1a 476 (+) Update address on the fly.
NYX 0:85b3fd62ea1a 477
NYX 0:85b3fd62ea1a 478 @endverbatim
NYX 0:85b3fd62ea1a 479 * @{
NYX 0:85b3fd62ea1a 480 */
NYX 0:85b3fd62ea1a 481
NYX 0:85b3fd62ea1a 482 /**
NYX 0:85b3fd62ea1a 483 * @brief Configure the LTDC Layer according to the specified
NYX 0:85b3fd62ea1a 484 * parameters in the LTDC_InitTypeDef and create the associated handle.
NYX 0:85b3fd62ea1a 485 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 486 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 487 * @param pLayerCfg pointer to a LTDC_LayerCfgTypeDef structure that contains
NYX 0:85b3fd62ea1a 488 * the configuration information for the Layer.
NYX 0:85b3fd62ea1a 489 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 490 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 491 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 492 * @retval HAL status
NYX 0:85b3fd62ea1a 493 */
NYX 0:85b3fd62ea1a 494 HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 495 {
NYX 0:85b3fd62ea1a 496 /* Check the parameters */
NYX 0:85b3fd62ea1a 497 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 498 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
NYX 0:85b3fd62ea1a 499 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
NYX 0:85b3fd62ea1a 500 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
NYX 0:85b3fd62ea1a 501 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
NYX 0:85b3fd62ea1a 502 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
NYX 0:85b3fd62ea1a 503 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha));
NYX 0:85b3fd62ea1a 504 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
NYX 0:85b3fd62ea1a 505 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
NYX 0:85b3fd62ea1a 506 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
NYX 0:85b3fd62ea1a 507 assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
NYX 0:85b3fd62ea1a 508 assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
NYX 0:85b3fd62ea1a 509
NYX 0:85b3fd62ea1a 510 /* Process locked */
NYX 0:85b3fd62ea1a 511 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 512
NYX 0:85b3fd62ea1a 513 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 514 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 515
NYX 0:85b3fd62ea1a 516 /* Copy new layer configuration into handle structure */
NYX 0:85b3fd62ea1a 517 hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
NYX 0:85b3fd62ea1a 518
NYX 0:85b3fd62ea1a 519 /* Configure the LTDC Layer */
NYX 0:85b3fd62ea1a 520 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 521
NYX 0:85b3fd62ea1a 522 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 523 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 524
NYX 0:85b3fd62ea1a 525 /* Initialize the LTDC state*/
NYX 0:85b3fd62ea1a 526 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 527
NYX 0:85b3fd62ea1a 528 /* Process unlocked */
NYX 0:85b3fd62ea1a 529 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 530
NYX 0:85b3fd62ea1a 531 return HAL_OK;
NYX 0:85b3fd62ea1a 532 }
NYX 0:85b3fd62ea1a 533
NYX 0:85b3fd62ea1a 534 /**
NYX 0:85b3fd62ea1a 535 * @brief Configure the color keying.
NYX 0:85b3fd62ea1a 536 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 537 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 538 * @param RGBValue the color key value
NYX 0:85b3fd62ea1a 539 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 540 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 541 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 542 * @retval HAL status
NYX 0:85b3fd62ea1a 543 */
NYX 0:85b3fd62ea1a 544 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 545 {
NYX 0:85b3fd62ea1a 546 /* Check the parameters */
NYX 0:85b3fd62ea1a 547 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 548
NYX 0:85b3fd62ea1a 549 /* Process locked */
NYX 0:85b3fd62ea1a 550 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 551
NYX 0:85b3fd62ea1a 552 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 553 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 554
NYX 0:85b3fd62ea1a 555 /* Configure the default color values */
NYX 0:85b3fd62ea1a 556 LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
NYX 0:85b3fd62ea1a 557 LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
NYX 0:85b3fd62ea1a 558
NYX 0:85b3fd62ea1a 559 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 560 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 561
NYX 0:85b3fd62ea1a 562 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 563 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 564
NYX 0:85b3fd62ea1a 565 /* Process unlocked */
NYX 0:85b3fd62ea1a 566 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 567
NYX 0:85b3fd62ea1a 568 return HAL_OK;
NYX 0:85b3fd62ea1a 569 }
NYX 0:85b3fd62ea1a 570
NYX 0:85b3fd62ea1a 571 /**
NYX 0:85b3fd62ea1a 572 * @brief Load the color lookup table.
NYX 0:85b3fd62ea1a 573 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 574 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 575 * @param pCLUT pointer to the color lookup table address.
NYX 0:85b3fd62ea1a 576 * @param CLUTSize the color lookup table size.
NYX 0:85b3fd62ea1a 577 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 578 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 579 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 580 * @retval HAL status
NYX 0:85b3fd62ea1a 581 */
NYX 0:85b3fd62ea1a 582 HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 583 {
NYX 0:85b3fd62ea1a 584 uint32_t tmp = 0U;
NYX 0:85b3fd62ea1a 585 uint32_t counter = 0U;
NYX 0:85b3fd62ea1a 586 uint32_t pcounter = 0U;
NYX 0:85b3fd62ea1a 587
NYX 0:85b3fd62ea1a 588 /* Check the parameters */
NYX 0:85b3fd62ea1a 589 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 590
NYX 0:85b3fd62ea1a 591 /* Process locked */
NYX 0:85b3fd62ea1a 592 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 593
NYX 0:85b3fd62ea1a 594 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 595 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 596
NYX 0:85b3fd62ea1a 597 for(counter = 0U; (counter < CLUTSize); counter++)
NYX 0:85b3fd62ea1a 598 {
NYX 0:85b3fd62ea1a 599 if(hltdc->LayerCfg[LayerIdx].PixelFormat == LTDC_PIXEL_FORMAT_AL44)
NYX 0:85b3fd62ea1a 600 {
NYX 0:85b3fd62ea1a 601 tmp = (((counter + 16U*counter) << 24U) | ((uint32_t)(*pCLUT) & 0xFFU) | ((uint32_t)(*pCLUT) & 0xFF00U) | ((uint32_t)(*pCLUT) & 0xFF0000U));
NYX 0:85b3fd62ea1a 602 }
NYX 0:85b3fd62ea1a 603 else
NYX 0:85b3fd62ea1a 604 {
NYX 0:85b3fd62ea1a 605 tmp = ((counter << 24U) | ((uint32_t)(*pCLUT) & 0xFFU) | ((uint32_t)(*pCLUT) & 0xFF00U) | ((uint32_t)(*pCLUT) & 0xFF0000U));
NYX 0:85b3fd62ea1a 606 }
NYX 0:85b3fd62ea1a 607 pcounter = (uint32_t)pCLUT + sizeof(*pCLUT);
NYX 0:85b3fd62ea1a 608 pCLUT = (uint32_t *)pcounter;
NYX 0:85b3fd62ea1a 609
NYX 0:85b3fd62ea1a 610 /* Specifies the C-LUT address and RGB value */
NYX 0:85b3fd62ea1a 611 LTDC_LAYER(hltdc, LayerIdx)->CLUTWR = tmp;
NYX 0:85b3fd62ea1a 612 }
NYX 0:85b3fd62ea1a 613
NYX 0:85b3fd62ea1a 614 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 615 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 616
NYX 0:85b3fd62ea1a 617 /* Process unlocked */
NYX 0:85b3fd62ea1a 618 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 619
NYX 0:85b3fd62ea1a 620 return HAL_OK;
NYX 0:85b3fd62ea1a 621 }
NYX 0:85b3fd62ea1a 622
NYX 0:85b3fd62ea1a 623 /**
NYX 0:85b3fd62ea1a 624 * @brief Enable the color keying.
NYX 0:85b3fd62ea1a 625 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 626 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 627 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 628 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 629 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 630 * @retval HAL status
NYX 0:85b3fd62ea1a 631 */
NYX 0:85b3fd62ea1a 632 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 633 {
NYX 0:85b3fd62ea1a 634 /* Check the parameters */
NYX 0:85b3fd62ea1a 635 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 636
NYX 0:85b3fd62ea1a 637 /* Process locked */
NYX 0:85b3fd62ea1a 638 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 639
NYX 0:85b3fd62ea1a 640 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 641 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 642
NYX 0:85b3fd62ea1a 643 /* Enable LTDC color keying by setting COLKEN bit */
NYX 0:85b3fd62ea1a 644 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
NYX 0:85b3fd62ea1a 645
NYX 0:85b3fd62ea1a 646 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 647 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 648
NYX 0:85b3fd62ea1a 649 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 650 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 651
NYX 0:85b3fd62ea1a 652 /* Process unlocked */
NYX 0:85b3fd62ea1a 653 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 654
NYX 0:85b3fd62ea1a 655 return HAL_OK;
NYX 0:85b3fd62ea1a 656 }
NYX 0:85b3fd62ea1a 657
NYX 0:85b3fd62ea1a 658 /**
NYX 0:85b3fd62ea1a 659 * @brief Disable the color keying.
NYX 0:85b3fd62ea1a 660 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 661 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 662 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 663 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 664 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 665 * @retval HAL status
NYX 0:85b3fd62ea1a 666 */
NYX 0:85b3fd62ea1a 667 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 668 {
NYX 0:85b3fd62ea1a 669 /* Check the parameters */
NYX 0:85b3fd62ea1a 670 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 671
NYX 0:85b3fd62ea1a 672 /* Process locked */
NYX 0:85b3fd62ea1a 673 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 674
NYX 0:85b3fd62ea1a 675 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 676 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 677
NYX 0:85b3fd62ea1a 678 /* Disable LTDC color keying by setting COLKEN bit */
NYX 0:85b3fd62ea1a 679 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
NYX 0:85b3fd62ea1a 680
NYX 0:85b3fd62ea1a 681 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 682 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 683
NYX 0:85b3fd62ea1a 684 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 685 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 686
NYX 0:85b3fd62ea1a 687 /* Process unlocked */
NYX 0:85b3fd62ea1a 688 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 689
NYX 0:85b3fd62ea1a 690 return HAL_OK;
NYX 0:85b3fd62ea1a 691 }
NYX 0:85b3fd62ea1a 692
NYX 0:85b3fd62ea1a 693 /**
NYX 0:85b3fd62ea1a 694 * @brief Enable the color lookup table.
NYX 0:85b3fd62ea1a 695 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 696 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 697 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 698 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 699 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 700 * @retval HAL status
NYX 0:85b3fd62ea1a 701 */
NYX 0:85b3fd62ea1a 702 HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 703 {
NYX 0:85b3fd62ea1a 704 /* Check the parameters */
NYX 0:85b3fd62ea1a 705 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 706
NYX 0:85b3fd62ea1a 707 /* Process locked */
NYX 0:85b3fd62ea1a 708 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 709
NYX 0:85b3fd62ea1a 710 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 711 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 712
NYX 0:85b3fd62ea1a 713 /* Enable LTDC color lookup table by setting CLUTEN bit */
NYX 0:85b3fd62ea1a 714 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
NYX 0:85b3fd62ea1a 715
NYX 0:85b3fd62ea1a 716 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 717 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 718
NYX 0:85b3fd62ea1a 719 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 720 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 721
NYX 0:85b3fd62ea1a 722 /* Process unlocked */
NYX 0:85b3fd62ea1a 723 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 724
NYX 0:85b3fd62ea1a 725 return HAL_OK;
NYX 0:85b3fd62ea1a 726 }
NYX 0:85b3fd62ea1a 727
NYX 0:85b3fd62ea1a 728 /**
NYX 0:85b3fd62ea1a 729 * @brief Disable the color lookup table.
NYX 0:85b3fd62ea1a 730 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 731 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 732 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 733 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 734 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 735 * @retval HAL status
NYX 0:85b3fd62ea1a 736 */
NYX 0:85b3fd62ea1a 737 HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 738 {
NYX 0:85b3fd62ea1a 739 /* Check the parameters */
NYX 0:85b3fd62ea1a 740 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 741
NYX 0:85b3fd62ea1a 742 /* Process locked */
NYX 0:85b3fd62ea1a 743 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 744
NYX 0:85b3fd62ea1a 745 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 746 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 747
NYX 0:85b3fd62ea1a 748 /* Disable LTDC color lookup table by setting CLUTEN bit */
NYX 0:85b3fd62ea1a 749 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
NYX 0:85b3fd62ea1a 750
NYX 0:85b3fd62ea1a 751 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 752 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 753
NYX 0:85b3fd62ea1a 754 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 755 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 756
NYX 0:85b3fd62ea1a 757 /* Process unlocked */
NYX 0:85b3fd62ea1a 758 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 759
NYX 0:85b3fd62ea1a 760 return HAL_OK;
NYX 0:85b3fd62ea1a 761 }
NYX 0:85b3fd62ea1a 762
NYX 0:85b3fd62ea1a 763 /**
NYX 0:85b3fd62ea1a 764 * @brief Enable Dither.
NYX 0:85b3fd62ea1a 765 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 766 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 767 * @retval HAL status
NYX 0:85b3fd62ea1a 768 */
NYX 0:85b3fd62ea1a 769
NYX 0:85b3fd62ea1a 770 HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 771 {
NYX 0:85b3fd62ea1a 772 /* Process locked */
NYX 0:85b3fd62ea1a 773 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 774
NYX 0:85b3fd62ea1a 775 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 776 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 777
NYX 0:85b3fd62ea1a 778 /* Enable Dither by setting DTEN bit */
NYX 0:85b3fd62ea1a 779 LTDC->GCR |= (uint32_t)LTDC_GCR_DEN;
NYX 0:85b3fd62ea1a 780
NYX 0:85b3fd62ea1a 781 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 782 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 783
NYX 0:85b3fd62ea1a 784 /* Process unlocked */
NYX 0:85b3fd62ea1a 785 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 786
NYX 0:85b3fd62ea1a 787 return HAL_OK;
NYX 0:85b3fd62ea1a 788 }
NYX 0:85b3fd62ea1a 789
NYX 0:85b3fd62ea1a 790 /**
NYX 0:85b3fd62ea1a 791 * @brief Disable Dither.
NYX 0:85b3fd62ea1a 792 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 793 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 794 * @retval HAL status
NYX 0:85b3fd62ea1a 795 */
NYX 0:85b3fd62ea1a 796
NYX 0:85b3fd62ea1a 797 HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 798 {
NYX 0:85b3fd62ea1a 799 /* Process locked */
NYX 0:85b3fd62ea1a 800 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 801
NYX 0:85b3fd62ea1a 802 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 803 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 804
NYX 0:85b3fd62ea1a 805 /* Disable Dither by setting DTEN bit */
NYX 0:85b3fd62ea1a 806 LTDC->GCR &= ~(uint32_t)LTDC_GCR_DEN;
NYX 0:85b3fd62ea1a 807
NYX 0:85b3fd62ea1a 808 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 809 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 810
NYX 0:85b3fd62ea1a 811 /* Process unlocked */
NYX 0:85b3fd62ea1a 812 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 813
NYX 0:85b3fd62ea1a 814 return HAL_OK;
NYX 0:85b3fd62ea1a 815 }
NYX 0:85b3fd62ea1a 816
NYX 0:85b3fd62ea1a 817 /**
NYX 0:85b3fd62ea1a 818 * @brief Set the LTDC window size.
NYX 0:85b3fd62ea1a 819 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 820 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 821 * @param XSize LTDC Pixel per line
NYX 0:85b3fd62ea1a 822 * @param YSize LTDC Line number
NYX 0:85b3fd62ea1a 823 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 824 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 825 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 826 * @retval HAL status
NYX 0:85b3fd62ea1a 827 */
NYX 0:85b3fd62ea1a 828 HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 829 {
NYX 0:85b3fd62ea1a 830 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 831
NYX 0:85b3fd62ea1a 832 /* Check the parameters (Layers parameters)*/
NYX 0:85b3fd62ea1a 833 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 834 assert_param(IS_LTDC_CFBLL(XSize));
NYX 0:85b3fd62ea1a 835 assert_param(IS_LTDC_CFBLNBR(YSize));
NYX 0:85b3fd62ea1a 836
NYX 0:85b3fd62ea1a 837 /* Process locked */
NYX 0:85b3fd62ea1a 838 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 839
NYX 0:85b3fd62ea1a 840 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 841 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 842
NYX 0:85b3fd62ea1a 843 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 844 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 845
NYX 0:85b3fd62ea1a 846 /* update horizontal stop */
NYX 0:85b3fd62ea1a 847 pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
NYX 0:85b3fd62ea1a 848
NYX 0:85b3fd62ea1a 849 /* update vertical stop */
NYX 0:85b3fd62ea1a 850 pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
NYX 0:85b3fd62ea1a 851
NYX 0:85b3fd62ea1a 852 /* Reconfigures the color frame buffer pitch in byte */
NYX 0:85b3fd62ea1a 853 pLayerCfg->ImageWidth = XSize;
NYX 0:85b3fd62ea1a 854
NYX 0:85b3fd62ea1a 855 /* Reconfigures the frame buffer line number */
NYX 0:85b3fd62ea1a 856 pLayerCfg->ImageHeight = YSize;
NYX 0:85b3fd62ea1a 857
NYX 0:85b3fd62ea1a 858 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 859 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 860
NYX 0:85b3fd62ea1a 861 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 862 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 863
NYX 0:85b3fd62ea1a 864 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 865 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 866
NYX 0:85b3fd62ea1a 867 /* Process unlocked */
NYX 0:85b3fd62ea1a 868 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 869
NYX 0:85b3fd62ea1a 870 return HAL_OK;
NYX 0:85b3fd62ea1a 871 }
NYX 0:85b3fd62ea1a 872
NYX 0:85b3fd62ea1a 873 /**
NYX 0:85b3fd62ea1a 874 * @brief Set the LTDC window position.
NYX 0:85b3fd62ea1a 875 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 876 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 877 * @param X0 LTDC window X offset
NYX 0:85b3fd62ea1a 878 * @param Y0 LTDC window Y offset
NYX 0:85b3fd62ea1a 879 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 880 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 881 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 882 * @retval HAL status
NYX 0:85b3fd62ea1a 883 */
NYX 0:85b3fd62ea1a 884 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 885 {
NYX 0:85b3fd62ea1a 886 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 887
NYX 0:85b3fd62ea1a 888 /* Check the parameters */
NYX 0:85b3fd62ea1a 889 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 890 assert_param(IS_LTDC_CFBLL(X0));
NYX 0:85b3fd62ea1a 891 assert_param(IS_LTDC_CFBLNBR(Y0));
NYX 0:85b3fd62ea1a 892
NYX 0:85b3fd62ea1a 893 /* Process locked */
NYX 0:85b3fd62ea1a 894 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 895
NYX 0:85b3fd62ea1a 896 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 897 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 898
NYX 0:85b3fd62ea1a 899 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 900 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 901
NYX 0:85b3fd62ea1a 902 /* update horizontal start/stop */
NYX 0:85b3fd62ea1a 903 pLayerCfg->WindowX0 = X0;
NYX 0:85b3fd62ea1a 904 pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
NYX 0:85b3fd62ea1a 905
NYX 0:85b3fd62ea1a 906 /* update vertical start/stop */
NYX 0:85b3fd62ea1a 907 pLayerCfg->WindowY0 = Y0;
NYX 0:85b3fd62ea1a 908 pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
NYX 0:85b3fd62ea1a 909
NYX 0:85b3fd62ea1a 910 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 911 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 912
NYX 0:85b3fd62ea1a 913 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 914 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 915
NYX 0:85b3fd62ea1a 916 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 917 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 918
NYX 0:85b3fd62ea1a 919 /* Process unlocked */
NYX 0:85b3fd62ea1a 920 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 921
NYX 0:85b3fd62ea1a 922 return HAL_OK;
NYX 0:85b3fd62ea1a 923 }
NYX 0:85b3fd62ea1a 924
NYX 0:85b3fd62ea1a 925 /**
NYX 0:85b3fd62ea1a 926 * @brief Reconfigure the pixel format.
NYX 0:85b3fd62ea1a 927 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 928 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 929 * @param Pixelformat new pixel format value.
NYX 0:85b3fd62ea1a 930 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 931 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 932 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
NYX 0:85b3fd62ea1a 933 * @retval HAL status
NYX 0:85b3fd62ea1a 934 */
NYX 0:85b3fd62ea1a 935 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 936 {
NYX 0:85b3fd62ea1a 937 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 938
NYX 0:85b3fd62ea1a 939 /* Check the parameters */
NYX 0:85b3fd62ea1a 940 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
NYX 0:85b3fd62ea1a 941 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 942
NYX 0:85b3fd62ea1a 943 /* Process locked */
NYX 0:85b3fd62ea1a 944 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 945
NYX 0:85b3fd62ea1a 946 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 947 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 948
NYX 0:85b3fd62ea1a 949 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 950 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 951
NYX 0:85b3fd62ea1a 952 /* Reconfigure the pixel format */
NYX 0:85b3fd62ea1a 953 pLayerCfg->PixelFormat = Pixelformat;
NYX 0:85b3fd62ea1a 954
NYX 0:85b3fd62ea1a 955 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 956 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 957
NYX 0:85b3fd62ea1a 958 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 959 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 960
NYX 0:85b3fd62ea1a 961 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 962 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 963
NYX 0:85b3fd62ea1a 964 /* Process unlocked */
NYX 0:85b3fd62ea1a 965 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 966
NYX 0:85b3fd62ea1a 967 return HAL_OK;
NYX 0:85b3fd62ea1a 968 }
NYX 0:85b3fd62ea1a 969
NYX 0:85b3fd62ea1a 970 /**
NYX 0:85b3fd62ea1a 971 * @brief Reconfigure the layer alpha value.
NYX 0:85b3fd62ea1a 972 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 973 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 974 * @param Alpha new alpha value.
NYX 0:85b3fd62ea1a 975 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 976 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 977 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 978 * @retval HAL status
NYX 0:85b3fd62ea1a 979 */
NYX 0:85b3fd62ea1a 980 HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 981 {
NYX 0:85b3fd62ea1a 982 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 983
NYX 0:85b3fd62ea1a 984 /* Check the parameters */
NYX 0:85b3fd62ea1a 985 assert_param(IS_LTDC_ALPHA(Alpha));
NYX 0:85b3fd62ea1a 986 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 987
NYX 0:85b3fd62ea1a 988 /* Process locked */
NYX 0:85b3fd62ea1a 989 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 990
NYX 0:85b3fd62ea1a 991 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 992 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 993
NYX 0:85b3fd62ea1a 994 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 995 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 996
NYX 0:85b3fd62ea1a 997 /* Reconfigure the Alpha value */
NYX 0:85b3fd62ea1a 998 pLayerCfg->Alpha = Alpha;
NYX 0:85b3fd62ea1a 999
NYX 0:85b3fd62ea1a 1000 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 1001 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 1002
NYX 0:85b3fd62ea1a 1003 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 1004 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 1005
NYX 0:85b3fd62ea1a 1006 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1007 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1008
NYX 0:85b3fd62ea1a 1009 /* Process unlocked */
NYX 0:85b3fd62ea1a 1010 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1011
NYX 0:85b3fd62ea1a 1012 return HAL_OK;
NYX 0:85b3fd62ea1a 1013 }
NYX 0:85b3fd62ea1a 1014 /**
NYX 0:85b3fd62ea1a 1015 * @brief Reconfigure the frame buffer Address.
NYX 0:85b3fd62ea1a 1016 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1017 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1018 * @param Address new address value.
NYX 0:85b3fd62ea1a 1019 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1020 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1021 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
NYX 0:85b3fd62ea1a 1022 * @retval HAL status
NYX 0:85b3fd62ea1a 1023 */
NYX 0:85b3fd62ea1a 1024 HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1025 {
NYX 0:85b3fd62ea1a 1026 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 1027
NYX 0:85b3fd62ea1a 1028 /* Check the parameters */
NYX 0:85b3fd62ea1a 1029 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1030
NYX 0:85b3fd62ea1a 1031 /* Process locked */
NYX 0:85b3fd62ea1a 1032 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1033
NYX 0:85b3fd62ea1a 1034 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1035 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1036
NYX 0:85b3fd62ea1a 1037 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 1038 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 1039
NYX 0:85b3fd62ea1a 1040 /* Reconfigure the Address */
NYX 0:85b3fd62ea1a 1041 pLayerCfg->FBStartAdress = Address;
NYX 0:85b3fd62ea1a 1042
NYX 0:85b3fd62ea1a 1043 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 1044 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 1045
NYX 0:85b3fd62ea1a 1046 /* Set the Immediate Reload type */
NYX 0:85b3fd62ea1a 1047 hltdc->Instance->SRCR = LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 1048
NYX 0:85b3fd62ea1a 1049 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1050 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1051
NYX 0:85b3fd62ea1a 1052 /* Process unlocked */
NYX 0:85b3fd62ea1a 1053 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1054
NYX 0:85b3fd62ea1a 1055 return HAL_OK;
NYX 0:85b3fd62ea1a 1056 }
NYX 0:85b3fd62ea1a 1057
NYX 0:85b3fd62ea1a 1058 /**
NYX 0:85b3fd62ea1a 1059 * @brief Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width that is
NYX 0:85b3fd62ea1a 1060 * larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to layer for which we
NYX 0:85b3fd62ea1a 1061 * want to read and display on screen only a portion 320x240 taken in the center of the buffer. The pitch in pixels
NYX 0:85b3fd62ea1a 1062 * will be in that case 800 pixels and not 320 pixels as initially configured by previous call to HAL_LTDC_ConfigLayer().
NYX 0:85b3fd62ea1a 1063 * @note This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default pitch
NYX 0:85b3fd62ea1a 1064 * configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
NYX 0:85b3fd62ea1a 1065 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1066 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1067 * @param LinePitchInPixels New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
NYX 0:85b3fd62ea1a 1068 * @param LayerIdx LTDC layer index concerned by the modification of line pitch.
NYX 0:85b3fd62ea1a 1069 * @retval HAL status
NYX 0:85b3fd62ea1a 1070 */
NYX 0:85b3fd62ea1a 1071 HAL_StatusTypeDef HAL_LTDC_SetPitch(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1072 {
NYX 0:85b3fd62ea1a 1073 uint32_t tmp = 0U;
NYX 0:85b3fd62ea1a 1074 uint32_t pitchUpdate = 0U;
NYX 0:85b3fd62ea1a 1075 uint32_t pixelFormat = 0U;
NYX 0:85b3fd62ea1a 1076
NYX 0:85b3fd62ea1a 1077 /* Check the parameters */
NYX 0:85b3fd62ea1a 1078 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1079
NYX 0:85b3fd62ea1a 1080 /* Process locked */
NYX 0:85b3fd62ea1a 1081 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1082
NYX 0:85b3fd62ea1a 1083 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1084 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1085
NYX 0:85b3fd62ea1a 1086 /* get LayerIdx used pixel format */
NYX 0:85b3fd62ea1a 1087 pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
NYX 0:85b3fd62ea1a 1088
NYX 0:85b3fd62ea1a 1089 if(pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
NYX 0:85b3fd62ea1a 1090 {
NYX 0:85b3fd62ea1a 1091 tmp = 4U;
NYX 0:85b3fd62ea1a 1092 }
NYX 0:85b3fd62ea1a 1093 else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
NYX 0:85b3fd62ea1a 1094 {
NYX 0:85b3fd62ea1a 1095 tmp = 3U;
NYX 0:85b3fd62ea1a 1096 }
NYX 0:85b3fd62ea1a 1097 else if((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
NYX 0:85b3fd62ea1a 1098 (pixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
NYX 0:85b3fd62ea1a 1099 (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
NYX 0:85b3fd62ea1a 1100 (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
NYX 0:85b3fd62ea1a 1101 {
NYX 0:85b3fd62ea1a 1102 tmp = 2U;
NYX 0:85b3fd62ea1a 1103 }
NYX 0:85b3fd62ea1a 1104 else
NYX 0:85b3fd62ea1a 1105 {
NYX 0:85b3fd62ea1a 1106 tmp = 1U;
NYX 0:85b3fd62ea1a 1107 }
NYX 0:85b3fd62ea1a 1108
NYX 0:85b3fd62ea1a 1109 pitchUpdate = ((LinePitchInPixels * tmp) << 16U);
NYX 0:85b3fd62ea1a 1110
NYX 0:85b3fd62ea1a 1111 /* Clear previously set standard pitch */
NYX 0:85b3fd62ea1a 1112 LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
NYX 0:85b3fd62ea1a 1113
NYX 0:85b3fd62ea1a 1114 /* Set the Reload type as immediate update of LTDC pitch configured above */
NYX 0:85b3fd62ea1a 1115 LTDC->SRCR |= LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 1116
NYX 0:85b3fd62ea1a 1117 /* Set new line pitch value */
NYX 0:85b3fd62ea1a 1118 LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
NYX 0:85b3fd62ea1a 1119
NYX 0:85b3fd62ea1a 1120 /* Set the Reload type as immediate update of LTDC pitch configured above */
NYX 0:85b3fd62ea1a 1121 LTDC->SRCR |= LTDC_SRCR_IMR;
NYX 0:85b3fd62ea1a 1122
NYX 0:85b3fd62ea1a 1123 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1124 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1125
NYX 0:85b3fd62ea1a 1126 /* Process unlocked */
NYX 0:85b3fd62ea1a 1127 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1128
NYX 0:85b3fd62ea1a 1129 return HAL_OK;
NYX 0:85b3fd62ea1a 1130 }
NYX 0:85b3fd62ea1a 1131
NYX 0:85b3fd62ea1a 1132 /**
NYX 0:85b3fd62ea1a 1133 * @brief Define the position of the line interrupt.
NYX 0:85b3fd62ea1a 1134 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1135 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1136 * @param Line Line Interrupt Position.
NYX 0:85b3fd62ea1a 1137 * @note User application may resort to HAL_LTDC_LineEventCallback() at line interrupt generation.
NYX 0:85b3fd62ea1a 1138 * @retval HAL status
NYX 0:85b3fd62ea1a 1139 */
NYX 0:85b3fd62ea1a 1140 HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line)
NYX 0:85b3fd62ea1a 1141 {
NYX 0:85b3fd62ea1a 1142 /* Check the parameters */
NYX 0:85b3fd62ea1a 1143 assert_param(IS_LTDC_LIPOS(Line));
NYX 0:85b3fd62ea1a 1144
NYX 0:85b3fd62ea1a 1145 /* Process locked */
NYX 0:85b3fd62ea1a 1146 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1147
NYX 0:85b3fd62ea1a 1148 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1149 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1150
NYX 0:85b3fd62ea1a 1151 /* Disable the Line interrupt */
NYX 0:85b3fd62ea1a 1152 __HAL_LTDC_DISABLE_IT(hltdc, LTDC_IT_LI);
NYX 0:85b3fd62ea1a 1153
NYX 0:85b3fd62ea1a 1154 /* Set the Line Interrupt position */
NYX 0:85b3fd62ea1a 1155 LTDC->LIPCR = (uint32_t)Line;
NYX 0:85b3fd62ea1a 1156
NYX 0:85b3fd62ea1a 1157 /* Enable the Line interrupt */
NYX 0:85b3fd62ea1a 1158 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_LI);
NYX 0:85b3fd62ea1a 1159
NYX 0:85b3fd62ea1a 1160 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1161 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1162
NYX 0:85b3fd62ea1a 1163 /* Process unlocked */
NYX 0:85b3fd62ea1a 1164 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1165
NYX 0:85b3fd62ea1a 1166 return HAL_OK;
NYX 0:85b3fd62ea1a 1167 }
NYX 0:85b3fd62ea1a 1168
NYX 0:85b3fd62ea1a 1169 /**
NYX 0:85b3fd62ea1a 1170 * @brief Reload LTDC Layers configuration.
NYX 0:85b3fd62ea1a 1171 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1172 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1173 * @param ReloadType This parameter can be one of the following values :
NYX 0:85b3fd62ea1a 1174 * LTDC_RELOAD_IMMEDIATE : Immediate Reload
NYX 0:85b3fd62ea1a 1175 * LTDC_RELOAD_VERTICAL_BLANKING : Reload in the next Vertical Blanking
NYX 0:85b3fd62ea1a 1176 * @note User application may resort to HAL_LTDC_ReloadEventCallback() at reload interrupt generation.
NYX 0:85b3fd62ea1a 1177 * @retval HAL status
NYX 0:85b3fd62ea1a 1178 */
NYX 0:85b3fd62ea1a 1179 HAL_StatusTypeDef HAL_LTDC_Reload(LTDC_HandleTypeDef *hltdc, uint32_t ReloadType)
NYX 0:85b3fd62ea1a 1180 {
NYX 0:85b3fd62ea1a 1181 /* Check the parameters */
NYX 0:85b3fd62ea1a 1182 assert_param(IS_LTDC_RELOAD(ReloadType));
NYX 0:85b3fd62ea1a 1183
NYX 0:85b3fd62ea1a 1184 /* Process locked */
NYX 0:85b3fd62ea1a 1185 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1186
NYX 0:85b3fd62ea1a 1187 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1188 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1189
NYX 0:85b3fd62ea1a 1190 /* Enable the Reload interrupt */
NYX 0:85b3fd62ea1a 1191 __HAL_LTDC_ENABLE_IT(hltdc, LTDC_IT_RR);
NYX 0:85b3fd62ea1a 1192
NYX 0:85b3fd62ea1a 1193 /* Apply Reload type */
NYX 0:85b3fd62ea1a 1194 hltdc->Instance->SRCR = ReloadType;
NYX 0:85b3fd62ea1a 1195
NYX 0:85b3fd62ea1a 1196 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1197 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1198
NYX 0:85b3fd62ea1a 1199 /* Process unlocked */
NYX 0:85b3fd62ea1a 1200 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1201
NYX 0:85b3fd62ea1a 1202 return HAL_OK;
NYX 0:85b3fd62ea1a 1203 }
NYX 0:85b3fd62ea1a 1204
NYX 0:85b3fd62ea1a 1205 /**
NYX 0:85b3fd62ea1a 1206 * @brief Configure the LTDC Layer according to the specified without reloading
NYX 0:85b3fd62ea1a 1207 * parameters in the LTDC_InitTypeDef and create the associated handle.
NYX 0:85b3fd62ea1a 1208 * Variant of the function HAL_LTDC_ConfigLayer without immediate reload.
NYX 0:85b3fd62ea1a 1209 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1210 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1211 * @param pLayerCfg pointer to a LTDC_LayerCfgTypeDef structure that contains
NYX 0:85b3fd62ea1a 1212 * the configuration information for the Layer.
NYX 0:85b3fd62ea1a 1213 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1214 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1215 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1216 * @retval HAL status
NYX 0:85b3fd62ea1a 1217 */
NYX 0:85b3fd62ea1a 1218 HAL_StatusTypeDef HAL_LTDC_ConfigLayer_NoReload(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1219 {
NYX 0:85b3fd62ea1a 1220 /* Check the parameters */
NYX 0:85b3fd62ea1a 1221 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1222 assert_param(IS_LTDC_HCONFIGST(pLayerCfg->WindowX0));
NYX 0:85b3fd62ea1a 1223 assert_param(IS_LTDC_HCONFIGSP(pLayerCfg->WindowX1));
NYX 0:85b3fd62ea1a 1224 assert_param(IS_LTDC_VCONFIGST(pLayerCfg->WindowY0));
NYX 0:85b3fd62ea1a 1225 assert_param(IS_LTDC_VCONFIGSP(pLayerCfg->WindowY1));
NYX 0:85b3fd62ea1a 1226 assert_param(IS_LTDC_PIXEL_FORMAT(pLayerCfg->PixelFormat));
NYX 0:85b3fd62ea1a 1227 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha));
NYX 0:85b3fd62ea1a 1228 assert_param(IS_LTDC_ALPHA(pLayerCfg->Alpha0));
NYX 0:85b3fd62ea1a 1229 assert_param(IS_LTDC_BLENDING_FACTOR1(pLayerCfg->BlendingFactor1));
NYX 0:85b3fd62ea1a 1230 assert_param(IS_LTDC_BLENDING_FACTOR2(pLayerCfg->BlendingFactor2));
NYX 0:85b3fd62ea1a 1231 assert_param(IS_LTDC_CFBLL(pLayerCfg->ImageWidth));
NYX 0:85b3fd62ea1a 1232 assert_param(IS_LTDC_CFBLNBR(pLayerCfg->ImageHeight));
NYX 0:85b3fd62ea1a 1233
NYX 0:85b3fd62ea1a 1234 /* Process locked */
NYX 0:85b3fd62ea1a 1235 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1236
NYX 0:85b3fd62ea1a 1237 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1238 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1239
NYX 0:85b3fd62ea1a 1240 /* Copy new layer configuration into handle structure */
NYX 0:85b3fd62ea1a 1241 hltdc->LayerCfg[LayerIdx] = *pLayerCfg;
NYX 0:85b3fd62ea1a 1242
NYX 0:85b3fd62ea1a 1243 /* Configure the LTDC Layer */
NYX 0:85b3fd62ea1a 1244 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 1245
NYX 0:85b3fd62ea1a 1246 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1247
NYX 0:85b3fd62ea1a 1248 /* Initialize the LTDC state*/
NYX 0:85b3fd62ea1a 1249 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1250
NYX 0:85b3fd62ea1a 1251 /* Process unlocked */
NYX 0:85b3fd62ea1a 1252 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1253
NYX 0:85b3fd62ea1a 1254 return HAL_OK;
NYX 0:85b3fd62ea1a 1255 }
NYX 0:85b3fd62ea1a 1256
NYX 0:85b3fd62ea1a 1257 /**
NYX 0:85b3fd62ea1a 1258 * @brief Set the LTDC window size without reloading.
NYX 0:85b3fd62ea1a 1259 * Variant of the function HAL_LTDC_SetWindowSize without immediate reload.
NYX 0:85b3fd62ea1a 1260 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1261 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1262 * @param XSize LTDC Pixel per line
NYX 0:85b3fd62ea1a 1263 * @param YSize LTDC Line number
NYX 0:85b3fd62ea1a 1264 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1265 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1266 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1267 * @retval HAL status
NYX 0:85b3fd62ea1a 1268 */
NYX 0:85b3fd62ea1a 1269 HAL_StatusTypeDef HAL_LTDC_SetWindowSize_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1270 {
NYX 0:85b3fd62ea1a 1271 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 1272
NYX 0:85b3fd62ea1a 1273 /* Check the parameters (Layers parameters)*/
NYX 0:85b3fd62ea1a 1274 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1275 assert_param(IS_LTDC_CFBLL(XSize));
NYX 0:85b3fd62ea1a 1276 assert_param(IS_LTDC_CFBLNBR(YSize));
NYX 0:85b3fd62ea1a 1277
NYX 0:85b3fd62ea1a 1278 /* Process locked */
NYX 0:85b3fd62ea1a 1279 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1280
NYX 0:85b3fd62ea1a 1281 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1282 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1283
NYX 0:85b3fd62ea1a 1284 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 1285 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 1286
NYX 0:85b3fd62ea1a 1287 /* update horizontal stop */
NYX 0:85b3fd62ea1a 1288 pLayerCfg->WindowX1 = XSize + pLayerCfg->WindowX0;
NYX 0:85b3fd62ea1a 1289
NYX 0:85b3fd62ea1a 1290 /* update vertical stop */
NYX 0:85b3fd62ea1a 1291 pLayerCfg->WindowY1 = YSize + pLayerCfg->WindowY0;
NYX 0:85b3fd62ea1a 1292
NYX 0:85b3fd62ea1a 1293 /* Reconfigures the color frame buffer pitch in byte */
NYX 0:85b3fd62ea1a 1294 pLayerCfg->ImageWidth = XSize;
NYX 0:85b3fd62ea1a 1295
NYX 0:85b3fd62ea1a 1296 /* Reconfigures the frame buffer line number */
NYX 0:85b3fd62ea1a 1297 pLayerCfg->ImageHeight = YSize;
NYX 0:85b3fd62ea1a 1298
NYX 0:85b3fd62ea1a 1299 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 1300 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 1301
NYX 0:85b3fd62ea1a 1302 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1303
NYX 0:85b3fd62ea1a 1304 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1305 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1306
NYX 0:85b3fd62ea1a 1307 /* Process unlocked */
NYX 0:85b3fd62ea1a 1308 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1309
NYX 0:85b3fd62ea1a 1310 return HAL_OK;
NYX 0:85b3fd62ea1a 1311 }
NYX 0:85b3fd62ea1a 1312
NYX 0:85b3fd62ea1a 1313 /**
NYX 0:85b3fd62ea1a 1314 * @brief Set the LTDC window position without reloading.
NYX 0:85b3fd62ea1a 1315 * Variant of the function HAL_LTDC_SetWindowPosition without immediate reload.
NYX 0:85b3fd62ea1a 1316 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1317 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1318 * @param X0 LTDC window X offset
NYX 0:85b3fd62ea1a 1319 * @param Y0 LTDC window Y offset
NYX 0:85b3fd62ea1a 1320 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1321 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1322 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1323 * @retval HAL status
NYX 0:85b3fd62ea1a 1324 */
NYX 0:85b3fd62ea1a 1325 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1326 {
NYX 0:85b3fd62ea1a 1327 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 1328
NYX 0:85b3fd62ea1a 1329 /* Check the parameters */
NYX 0:85b3fd62ea1a 1330 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1331 assert_param(IS_LTDC_CFBLL(X0));
NYX 0:85b3fd62ea1a 1332 assert_param(IS_LTDC_CFBLNBR(Y0));
NYX 0:85b3fd62ea1a 1333
NYX 0:85b3fd62ea1a 1334 /* Process locked */
NYX 0:85b3fd62ea1a 1335 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1336
NYX 0:85b3fd62ea1a 1337 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1338 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1339
NYX 0:85b3fd62ea1a 1340 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 1341 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 1342
NYX 0:85b3fd62ea1a 1343 /* update horizontal start/stop */
NYX 0:85b3fd62ea1a 1344 pLayerCfg->WindowX0 = X0;
NYX 0:85b3fd62ea1a 1345 pLayerCfg->WindowX1 = X0 + pLayerCfg->ImageWidth;
NYX 0:85b3fd62ea1a 1346
NYX 0:85b3fd62ea1a 1347 /* update vertical start/stop */
NYX 0:85b3fd62ea1a 1348 pLayerCfg->WindowY0 = Y0;
NYX 0:85b3fd62ea1a 1349 pLayerCfg->WindowY1 = Y0 + pLayerCfg->ImageHeight;
NYX 0:85b3fd62ea1a 1350
NYX 0:85b3fd62ea1a 1351 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 1352 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 1353
NYX 0:85b3fd62ea1a 1354 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1355
NYX 0:85b3fd62ea1a 1356 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1357 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1358
NYX 0:85b3fd62ea1a 1359 /* Process unlocked */
NYX 0:85b3fd62ea1a 1360 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1361
NYX 0:85b3fd62ea1a 1362 return HAL_OK;
NYX 0:85b3fd62ea1a 1363 }
NYX 0:85b3fd62ea1a 1364
NYX 0:85b3fd62ea1a 1365 /**
NYX 0:85b3fd62ea1a 1366 * @brief Reconfigure the pixel format without reloading.
NYX 0:85b3fd62ea1a 1367 * Variant of the function HAL_LTDC_SetPixelFormat without immediate reload.
NYX 0:85b3fd62ea1a 1368 * @param hltdc pointer to a LTDC_HandleTypeDfef structure that contains
NYX 0:85b3fd62ea1a 1369 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1370 * @param Pixelformat new pixel format value.
NYX 0:85b3fd62ea1a 1371 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1372 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1373 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
NYX 0:85b3fd62ea1a 1374 * @retval HAL status
NYX 0:85b3fd62ea1a 1375 */
NYX 0:85b3fd62ea1a 1376 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1377 {
NYX 0:85b3fd62ea1a 1378 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 1379
NYX 0:85b3fd62ea1a 1380 /* Check the parameters */
NYX 0:85b3fd62ea1a 1381 assert_param(IS_LTDC_PIXEL_FORMAT(Pixelformat));
NYX 0:85b3fd62ea1a 1382 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1383
NYX 0:85b3fd62ea1a 1384 /* Process locked */
NYX 0:85b3fd62ea1a 1385 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1386
NYX 0:85b3fd62ea1a 1387 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1388 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1389
NYX 0:85b3fd62ea1a 1390 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 1391 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 1392
NYX 0:85b3fd62ea1a 1393 /* Reconfigure the pixel format */
NYX 0:85b3fd62ea1a 1394 pLayerCfg->PixelFormat = Pixelformat;
NYX 0:85b3fd62ea1a 1395
NYX 0:85b3fd62ea1a 1396 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 1397 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 1398
NYX 0:85b3fd62ea1a 1399 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1400
NYX 0:85b3fd62ea1a 1401 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1402 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1403
NYX 0:85b3fd62ea1a 1404 /* Process unlocked */
NYX 0:85b3fd62ea1a 1405 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1406
NYX 0:85b3fd62ea1a 1407 return HAL_OK;
NYX 0:85b3fd62ea1a 1408 }
NYX 0:85b3fd62ea1a 1409
NYX 0:85b3fd62ea1a 1410 /**
NYX 0:85b3fd62ea1a 1411 * @brief Reconfigure the layer alpha value without reloading.
NYX 0:85b3fd62ea1a 1412 * Variant of the function HAL_LTDC_SetAlpha without immediate reload.
NYX 0:85b3fd62ea1a 1413 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1414 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1415 * @param Alpha new alpha value.
NYX 0:85b3fd62ea1a 1416 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1417 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1418 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1419 * @retval HAL status
NYX 0:85b3fd62ea1a 1420 */
NYX 0:85b3fd62ea1a 1421 HAL_StatusTypeDef HAL_LTDC_SetAlpha_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1422 {
NYX 0:85b3fd62ea1a 1423 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 1424
NYX 0:85b3fd62ea1a 1425 /* Check the parameters */
NYX 0:85b3fd62ea1a 1426 assert_param(IS_LTDC_ALPHA(Alpha));
NYX 0:85b3fd62ea1a 1427 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1428
NYX 0:85b3fd62ea1a 1429 /* Process locked */
NYX 0:85b3fd62ea1a 1430 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1431
NYX 0:85b3fd62ea1a 1432 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1433 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1434
NYX 0:85b3fd62ea1a 1435 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 1436 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 1437
NYX 0:85b3fd62ea1a 1438 /* Reconfigure the Alpha value */
NYX 0:85b3fd62ea1a 1439 pLayerCfg->Alpha = Alpha;
NYX 0:85b3fd62ea1a 1440
NYX 0:85b3fd62ea1a 1441 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 1442 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 1443
NYX 0:85b3fd62ea1a 1444 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1445
NYX 0:85b3fd62ea1a 1446 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1447 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1448
NYX 0:85b3fd62ea1a 1449 /* Process unlocked */
NYX 0:85b3fd62ea1a 1450 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1451
NYX 0:85b3fd62ea1a 1452 return HAL_OK;
NYX 0:85b3fd62ea1a 1453 }
NYX 0:85b3fd62ea1a 1454
NYX 0:85b3fd62ea1a 1455 /**
NYX 0:85b3fd62ea1a 1456 * @brief Reconfigure the frame buffer Address without reloading.
NYX 0:85b3fd62ea1a 1457 * Variant of the function HAL_LTDC_SetAddress without immediate reload.
NYX 0:85b3fd62ea1a 1458 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1459 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1460 * @param Address new address value.
NYX 0:85b3fd62ea1a 1461 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1462 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1463 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1).
NYX 0:85b3fd62ea1a 1464 * @retval HAL status
NYX 0:85b3fd62ea1a 1465 */
NYX 0:85b3fd62ea1a 1466 HAL_StatusTypeDef HAL_LTDC_SetAddress_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1467 {
NYX 0:85b3fd62ea1a 1468 LTDC_LayerCfgTypeDef *pLayerCfg;
NYX 0:85b3fd62ea1a 1469
NYX 0:85b3fd62ea1a 1470 /* Check the parameters */
NYX 0:85b3fd62ea1a 1471 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1472
NYX 0:85b3fd62ea1a 1473 /* Process locked */
NYX 0:85b3fd62ea1a 1474 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1475
NYX 0:85b3fd62ea1a 1476 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1477 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1478
NYX 0:85b3fd62ea1a 1479 /* Get layer configuration from handle structure */
NYX 0:85b3fd62ea1a 1480 pLayerCfg = &hltdc->LayerCfg[LayerIdx];
NYX 0:85b3fd62ea1a 1481
NYX 0:85b3fd62ea1a 1482 /* Reconfigure the Address */
NYX 0:85b3fd62ea1a 1483 pLayerCfg->FBStartAdress = Address;
NYX 0:85b3fd62ea1a 1484
NYX 0:85b3fd62ea1a 1485 /* Set LTDC parameters */
NYX 0:85b3fd62ea1a 1486 LTDC_SetConfig(hltdc, pLayerCfg, LayerIdx);
NYX 0:85b3fd62ea1a 1487
NYX 0:85b3fd62ea1a 1488 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1489
NYX 0:85b3fd62ea1a 1490 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1491 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1492
NYX 0:85b3fd62ea1a 1493 /* Process unlocked */
NYX 0:85b3fd62ea1a 1494 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1495
NYX 0:85b3fd62ea1a 1496 return HAL_OK;
NYX 0:85b3fd62ea1a 1497 }
NYX 0:85b3fd62ea1a 1498
NYX 0:85b3fd62ea1a 1499 /**
NYX 0:85b3fd62ea1a 1500 * @brief Function used to reconfigure the pitch for specific cases where the attached LayerIdx buffer have a width that is
NYX 0:85b3fd62ea1a 1501 * larger than the one intended to be displayed on screen. Example of a buffer 800x480 attached to layer for which we
NYX 0:85b3fd62ea1a 1502 * want to read and display on screen only a portion 320x240 taken in the center of the buffer. The pitch in pixels
NYX 0:85b3fd62ea1a 1503 * will be in that case 800 pixels and not 320 pixels as initially configured by previous call to HAL_LTDC_ConfigLayer().
NYX 0:85b3fd62ea1a 1504 * @note This function should be called only after a previous call to HAL_LTDC_ConfigLayer() to modify the default pitch
NYX 0:85b3fd62ea1a 1505 * configured by HAL_LTDC_ConfigLayer() when required (refer to example described just above).
NYX 0:85b3fd62ea1a 1506 * Variant of the function HAL_LTDC_SetPitch without immediate reload.
NYX 0:85b3fd62ea1a 1507 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1508 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1509 * @param LinePitchInPixels New line pitch in pixels to configure for LTDC layer 'LayerIdx'.
NYX 0:85b3fd62ea1a 1510 * @param LayerIdx LTDC layer index concerned by the modification of line pitch.
NYX 0:85b3fd62ea1a 1511 * @retval HAL status
NYX 0:85b3fd62ea1a 1512 */
NYX 0:85b3fd62ea1a 1513 HAL_StatusTypeDef HAL_LTDC_SetPitch_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1514 {
NYX 0:85b3fd62ea1a 1515 uint32_t tmp = 0U;
NYX 0:85b3fd62ea1a 1516 uint32_t pitchUpdate = 0U;
NYX 0:85b3fd62ea1a 1517 uint32_t pixelFormat = 0U;
NYX 0:85b3fd62ea1a 1518
NYX 0:85b3fd62ea1a 1519 /* Check the parameters */
NYX 0:85b3fd62ea1a 1520 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1521
NYX 0:85b3fd62ea1a 1522 /* Process locked */
NYX 0:85b3fd62ea1a 1523 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1524
NYX 0:85b3fd62ea1a 1525 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1526 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1527
NYX 0:85b3fd62ea1a 1528 /* get LayerIdx used pixel format */
NYX 0:85b3fd62ea1a 1529 pixelFormat = hltdc->LayerCfg[LayerIdx].PixelFormat;
NYX 0:85b3fd62ea1a 1530
NYX 0:85b3fd62ea1a 1531 if(pixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
NYX 0:85b3fd62ea1a 1532 {
NYX 0:85b3fd62ea1a 1533 tmp = 4U;
NYX 0:85b3fd62ea1a 1534 }
NYX 0:85b3fd62ea1a 1535 else if (pixelFormat == LTDC_PIXEL_FORMAT_RGB888)
NYX 0:85b3fd62ea1a 1536 {
NYX 0:85b3fd62ea1a 1537 tmp = 3U;
NYX 0:85b3fd62ea1a 1538 }
NYX 0:85b3fd62ea1a 1539 else if((pixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
NYX 0:85b3fd62ea1a 1540 (pixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
NYX 0:85b3fd62ea1a 1541 (pixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
NYX 0:85b3fd62ea1a 1542 (pixelFormat == LTDC_PIXEL_FORMAT_AL88))
NYX 0:85b3fd62ea1a 1543 {
NYX 0:85b3fd62ea1a 1544 tmp = 2U;
NYX 0:85b3fd62ea1a 1545 }
NYX 0:85b3fd62ea1a 1546 else
NYX 0:85b3fd62ea1a 1547 {
NYX 0:85b3fd62ea1a 1548 tmp = 1U;
NYX 0:85b3fd62ea1a 1549 }
NYX 0:85b3fd62ea1a 1550
NYX 0:85b3fd62ea1a 1551 pitchUpdate = ((LinePitchInPixels * tmp) << 16U);
NYX 0:85b3fd62ea1a 1552
NYX 0:85b3fd62ea1a 1553 /* Clear previously set standard pitch */
NYX 0:85b3fd62ea1a 1554 LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~LTDC_LxCFBLR_CFBP;
NYX 0:85b3fd62ea1a 1555
NYX 0:85b3fd62ea1a 1556 /* Set new line pitch value */
NYX 0:85b3fd62ea1a 1557 LTDC_LAYER(hltdc, LayerIdx)->CFBLR |= pitchUpdate;
NYX 0:85b3fd62ea1a 1558
NYX 0:85b3fd62ea1a 1559 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1560
NYX 0:85b3fd62ea1a 1561 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1562 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1563
NYX 0:85b3fd62ea1a 1564 /* Process unlocked */
NYX 0:85b3fd62ea1a 1565 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1566
NYX 0:85b3fd62ea1a 1567 return HAL_OK;
NYX 0:85b3fd62ea1a 1568 }
NYX 0:85b3fd62ea1a 1569
NYX 0:85b3fd62ea1a 1570
NYX 0:85b3fd62ea1a 1571 /**
NYX 0:85b3fd62ea1a 1572 * @brief Configure the color keying without reloading.
NYX 0:85b3fd62ea1a 1573 * Variant of the function HAL_LTDC_ConfigColorKeying without immediate reload.
NYX 0:85b3fd62ea1a 1574 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1575 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1576 * @param RGBValue the color key value
NYX 0:85b3fd62ea1a 1577 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1578 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1579 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1580 * @retval HAL status
NYX 0:85b3fd62ea1a 1581 */
NYX 0:85b3fd62ea1a 1582 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1583 {
NYX 0:85b3fd62ea1a 1584 /* Check the parameters */
NYX 0:85b3fd62ea1a 1585 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1586
NYX 0:85b3fd62ea1a 1587 /* Process locked */
NYX 0:85b3fd62ea1a 1588 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1589
NYX 0:85b3fd62ea1a 1590 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1591 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1592
NYX 0:85b3fd62ea1a 1593 /* Configure the default color values */
NYX 0:85b3fd62ea1a 1594 LTDC_LAYER(hltdc, LayerIdx)->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
NYX 0:85b3fd62ea1a 1595 LTDC_LAYER(hltdc, LayerIdx)->CKCR = RGBValue;
NYX 0:85b3fd62ea1a 1596
NYX 0:85b3fd62ea1a 1597 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1598
NYX 0:85b3fd62ea1a 1599 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1600 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1601
NYX 0:85b3fd62ea1a 1602 /* Process unlocked */
NYX 0:85b3fd62ea1a 1603 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1604
NYX 0:85b3fd62ea1a 1605 return HAL_OK;
NYX 0:85b3fd62ea1a 1606 }
NYX 0:85b3fd62ea1a 1607
NYX 0:85b3fd62ea1a 1608 /**
NYX 0:85b3fd62ea1a 1609 * @brief Enable the color keying without reloading.
NYX 0:85b3fd62ea1a 1610 * Variant of the function HAL_LTDC_EnableColorKeying without immediate reload.
NYX 0:85b3fd62ea1a 1611 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1612 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1613 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1614 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1615 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1616 * @retval HAL status
NYX 0:85b3fd62ea1a 1617 */
NYX 0:85b3fd62ea1a 1618 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1619 {
NYX 0:85b3fd62ea1a 1620 /* Check the parameters */
NYX 0:85b3fd62ea1a 1621 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1622
NYX 0:85b3fd62ea1a 1623 /* Process locked */
NYX 0:85b3fd62ea1a 1624 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1625
NYX 0:85b3fd62ea1a 1626 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1627 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1628
NYX 0:85b3fd62ea1a 1629 /* Enable LTDC color keying by setting COLKEN bit */
NYX 0:85b3fd62ea1a 1630 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_COLKEN;
NYX 0:85b3fd62ea1a 1631
NYX 0:85b3fd62ea1a 1632 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1633
NYX 0:85b3fd62ea1a 1634 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1635 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1636
NYX 0:85b3fd62ea1a 1637 /* Process unlocked */
NYX 0:85b3fd62ea1a 1638 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1639
NYX 0:85b3fd62ea1a 1640 return HAL_OK;
NYX 0:85b3fd62ea1a 1641 }
NYX 0:85b3fd62ea1a 1642
NYX 0:85b3fd62ea1a 1643 /**
NYX 0:85b3fd62ea1a 1644 * @brief Disable the color keying without reloading.
NYX 0:85b3fd62ea1a 1645 * Variant of the function HAL_LTDC_DisableColorKeying without immediate reload.
NYX 0:85b3fd62ea1a 1646 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1647 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1648 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1649 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1650 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1651 * @retval HAL status
NYX 0:85b3fd62ea1a 1652 */
NYX 0:85b3fd62ea1a 1653 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1654 {
NYX 0:85b3fd62ea1a 1655 /* Check the parameters */
NYX 0:85b3fd62ea1a 1656 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1657
NYX 0:85b3fd62ea1a 1658 /* Process locked */
NYX 0:85b3fd62ea1a 1659 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1660
NYX 0:85b3fd62ea1a 1661 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1662 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1663
NYX 0:85b3fd62ea1a 1664 /* Disable LTDC color keying by setting COLKEN bit */
NYX 0:85b3fd62ea1a 1665 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
NYX 0:85b3fd62ea1a 1666
NYX 0:85b3fd62ea1a 1667 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1668
NYX 0:85b3fd62ea1a 1669 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1670 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1671
NYX 0:85b3fd62ea1a 1672 /* Process unlocked */
NYX 0:85b3fd62ea1a 1673 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1674
NYX 0:85b3fd62ea1a 1675 return HAL_OK;
NYX 0:85b3fd62ea1a 1676 }
NYX 0:85b3fd62ea1a 1677
NYX 0:85b3fd62ea1a 1678 /**
NYX 0:85b3fd62ea1a 1679 * @brief Enable the color lookup table without reloading.
NYX 0:85b3fd62ea1a 1680 * Variant of the function HAL_LTDC_EnableCLUT without immediate reload.
NYX 0:85b3fd62ea1a 1681 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1682 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1683 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1684 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1685 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1686 * @retval HAL status
NYX 0:85b3fd62ea1a 1687 */
NYX 0:85b3fd62ea1a 1688 HAL_StatusTypeDef HAL_LTDC_EnableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1689 {
NYX 0:85b3fd62ea1a 1690 /* Check the parameters */
NYX 0:85b3fd62ea1a 1691 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1692
NYX 0:85b3fd62ea1a 1693 /* Process locked */
NYX 0:85b3fd62ea1a 1694 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1695
NYX 0:85b3fd62ea1a 1696 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1697 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1698
NYX 0:85b3fd62ea1a 1699 /* Disable LTDC color lookup table by setting CLUTEN bit */
NYX 0:85b3fd62ea1a 1700 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
NYX 0:85b3fd62ea1a 1701
NYX 0:85b3fd62ea1a 1702 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1703
NYX 0:85b3fd62ea1a 1704 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1705 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1706
NYX 0:85b3fd62ea1a 1707 /* Process unlocked */
NYX 0:85b3fd62ea1a 1708 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1709
NYX 0:85b3fd62ea1a 1710 return HAL_OK;
NYX 0:85b3fd62ea1a 1711 }
NYX 0:85b3fd62ea1a 1712
NYX 0:85b3fd62ea1a 1713 /**
NYX 0:85b3fd62ea1a 1714 * @brief Disable the color lookup table without reloading.
NYX 0:85b3fd62ea1a 1715 * Variant of the function HAL_LTDC_DisableCLUT without immediate reload.
NYX 0:85b3fd62ea1a 1716 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1717 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1718 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1719 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 1720 * LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1721 * @retval HAL status
NYX 0:85b3fd62ea1a 1722 */
NYX 0:85b3fd62ea1a 1723 HAL_StatusTypeDef HAL_LTDC_DisableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1724 {
NYX 0:85b3fd62ea1a 1725 /* Check the parameters */
NYX 0:85b3fd62ea1a 1726 assert_param(IS_LTDC_LAYER(LayerIdx));
NYX 0:85b3fd62ea1a 1727
NYX 0:85b3fd62ea1a 1728 /* Process locked */
NYX 0:85b3fd62ea1a 1729 __HAL_LOCK(hltdc);
NYX 0:85b3fd62ea1a 1730
NYX 0:85b3fd62ea1a 1731 /* Change LTDC peripheral state */
NYX 0:85b3fd62ea1a 1732 hltdc->State = HAL_LTDC_STATE_BUSY;
NYX 0:85b3fd62ea1a 1733
NYX 0:85b3fd62ea1a 1734 /* Disable LTDC color lookup table by setting CLUTEN bit */
NYX 0:85b3fd62ea1a 1735 LTDC_LAYER(hltdc, LayerIdx)->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
NYX 0:85b3fd62ea1a 1736
NYX 0:85b3fd62ea1a 1737 /* Do not set the Immediate Reload */
NYX 0:85b3fd62ea1a 1738
NYX 0:85b3fd62ea1a 1739 /* Change the LTDC state*/
NYX 0:85b3fd62ea1a 1740 hltdc->State = HAL_LTDC_STATE_READY;
NYX 0:85b3fd62ea1a 1741
NYX 0:85b3fd62ea1a 1742 /* Process unlocked */
NYX 0:85b3fd62ea1a 1743 __HAL_UNLOCK(hltdc);
NYX 0:85b3fd62ea1a 1744
NYX 0:85b3fd62ea1a 1745 return HAL_OK;
NYX 0:85b3fd62ea1a 1746 }
NYX 0:85b3fd62ea1a 1747
NYX 0:85b3fd62ea1a 1748 /**
NYX 0:85b3fd62ea1a 1749 * @}
NYX 0:85b3fd62ea1a 1750 */
NYX 0:85b3fd62ea1a 1751
NYX 0:85b3fd62ea1a 1752 /** @defgroup LTDC_Exported_Functions_Group4 Peripheral State and Errors functions
NYX 0:85b3fd62ea1a 1753 * @brief Peripheral State and Errors functions
NYX 0:85b3fd62ea1a 1754 *
NYX 0:85b3fd62ea1a 1755 @verbatim
NYX 0:85b3fd62ea1a 1756 ===============================================================================
NYX 0:85b3fd62ea1a 1757 ##### Peripheral State and Errors functions #####
NYX 0:85b3fd62ea1a 1758 ===============================================================================
NYX 0:85b3fd62ea1a 1759 [..]
NYX 0:85b3fd62ea1a 1760 This subsection provides functions allowing to
NYX 0:85b3fd62ea1a 1761 (+) Check the LTDC handle state.
NYX 0:85b3fd62ea1a 1762 (+) Get the LTDC handle error code.
NYX 0:85b3fd62ea1a 1763
NYX 0:85b3fd62ea1a 1764 @endverbatim
NYX 0:85b3fd62ea1a 1765 * @{
NYX 0:85b3fd62ea1a 1766 */
NYX 0:85b3fd62ea1a 1767
NYX 0:85b3fd62ea1a 1768 /**
NYX 0:85b3fd62ea1a 1769 * @brief Return the LTDC handle state.
NYX 0:85b3fd62ea1a 1770 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1771 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1772 * @retval HAL state
NYX 0:85b3fd62ea1a 1773 */
NYX 0:85b3fd62ea1a 1774 HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 1775 {
NYX 0:85b3fd62ea1a 1776 return hltdc->State;
NYX 0:85b3fd62ea1a 1777 }
NYX 0:85b3fd62ea1a 1778
NYX 0:85b3fd62ea1a 1779 /**
NYX 0:85b3fd62ea1a 1780 * @brief Return the LTDC handle error code.
NYX 0:85b3fd62ea1a 1781 * @param hltdc pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1782 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1783 * @retval LTDC Error Code
NYX 0:85b3fd62ea1a 1784 */
NYX 0:85b3fd62ea1a 1785 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc)
NYX 0:85b3fd62ea1a 1786 {
NYX 0:85b3fd62ea1a 1787 return hltdc->ErrorCode;
NYX 0:85b3fd62ea1a 1788 }
NYX 0:85b3fd62ea1a 1789
NYX 0:85b3fd62ea1a 1790 /**
NYX 0:85b3fd62ea1a 1791 * @}
NYX 0:85b3fd62ea1a 1792 */
NYX 0:85b3fd62ea1a 1793
NYX 0:85b3fd62ea1a 1794 /**
NYX 0:85b3fd62ea1a 1795 * @}
NYX 0:85b3fd62ea1a 1796 */
NYX 0:85b3fd62ea1a 1797
NYX 0:85b3fd62ea1a 1798 /** @defgroup LTDC_Private_Functions LTDC Private Functions
NYX 0:85b3fd62ea1a 1799 * @{
NYX 0:85b3fd62ea1a 1800 */
NYX 0:85b3fd62ea1a 1801
NYX 0:85b3fd62ea1a 1802 /**
NYX 0:85b3fd62ea1a 1803 * @brief Configure the LTDC peripheral
NYX 0:85b3fd62ea1a 1804 * @param hltdc Pointer to a LTDC_HandleTypeDef structure that contains
NYX 0:85b3fd62ea1a 1805 * the configuration information for the LTDC.
NYX 0:85b3fd62ea1a 1806 * @param pLayerCfg Pointer LTDC Layer Configuration structure
NYX 0:85b3fd62ea1a 1807 * @param LayerIdx LTDC Layer index.
NYX 0:85b3fd62ea1a 1808 * This parameter can be one of the following values: LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1)
NYX 0:85b3fd62ea1a 1809 * @retval None
NYX 0:85b3fd62ea1a 1810 */
NYX 0:85b3fd62ea1a 1811 static void LTDC_SetConfig(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx)
NYX 0:85b3fd62ea1a 1812 {
NYX 0:85b3fd62ea1a 1813 uint32_t tmp = 0U;
NYX 0:85b3fd62ea1a 1814 uint32_t tmp1 = 0U;
NYX 0:85b3fd62ea1a 1815 uint32_t tmp2 = 0U;
NYX 0:85b3fd62ea1a 1816
NYX 0:85b3fd62ea1a 1817 /* Configure the horizontal start and stop position */
NYX 0:85b3fd62ea1a 1818 tmp = ((pLayerCfg->WindowX1 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U)) << 16U);
NYX 0:85b3fd62ea1a 1819 LTDC_LAYER(hltdc, LayerIdx)->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
NYX 0:85b3fd62ea1a 1820 LTDC_LAYER(hltdc, LayerIdx)->WHPCR = ((pLayerCfg->WindowX0 + ((hltdc->Instance->BPCR & LTDC_BPCR_AHBP) >> 16U) + 1U) | tmp);
NYX 0:85b3fd62ea1a 1821
NYX 0:85b3fd62ea1a 1822 /* Configure the vertical start and stop position */
NYX 0:85b3fd62ea1a 1823 tmp = ((pLayerCfg->WindowY1 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP)) << 16U);
NYX 0:85b3fd62ea1a 1824 LTDC_LAYER(hltdc, LayerIdx)->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
NYX 0:85b3fd62ea1a 1825 LTDC_LAYER(hltdc, LayerIdx)->WVPCR = ((pLayerCfg->WindowY0 + (hltdc->Instance->BPCR & LTDC_BPCR_AVBP) + 1U) | tmp);
NYX 0:85b3fd62ea1a 1826
NYX 0:85b3fd62ea1a 1827 /* Specifies the pixel format */
NYX 0:85b3fd62ea1a 1828 LTDC_LAYER(hltdc, LayerIdx)->PFCR &= ~(LTDC_LxPFCR_PF);
NYX 0:85b3fd62ea1a 1829 LTDC_LAYER(hltdc, LayerIdx)->PFCR = (pLayerCfg->PixelFormat);
NYX 0:85b3fd62ea1a 1830
NYX 0:85b3fd62ea1a 1831 /* Configure the default color values */
NYX 0:85b3fd62ea1a 1832 tmp = ((uint32_t)(pLayerCfg->Backcolor.Green) << 8U);
NYX 0:85b3fd62ea1a 1833 tmp1 = ((uint32_t)(pLayerCfg->Backcolor.Red) << 16U);
NYX 0:85b3fd62ea1a 1834 tmp2 = (pLayerCfg->Alpha0 << 24U);
NYX 0:85b3fd62ea1a 1835 LTDC_LAYER(hltdc, LayerIdx)->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA);
NYX 0:85b3fd62ea1a 1836 LTDC_LAYER(hltdc, LayerIdx)->DCCR = (pLayerCfg->Backcolor.Blue | tmp | tmp1 | tmp2);
NYX 0:85b3fd62ea1a 1837
NYX 0:85b3fd62ea1a 1838 /* Specifies the constant alpha value */
NYX 0:85b3fd62ea1a 1839 LTDC_LAYER(hltdc, LayerIdx)->CACR &= ~(LTDC_LxCACR_CONSTA);
NYX 0:85b3fd62ea1a 1840 LTDC_LAYER(hltdc, LayerIdx)->CACR = (pLayerCfg->Alpha);
NYX 0:85b3fd62ea1a 1841
NYX 0:85b3fd62ea1a 1842 /* Specifies the blending factors */
NYX 0:85b3fd62ea1a 1843 LTDC_LAYER(hltdc, LayerIdx)->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
NYX 0:85b3fd62ea1a 1844 LTDC_LAYER(hltdc, LayerIdx)->BFCR = (pLayerCfg->BlendingFactor1 | pLayerCfg->BlendingFactor2);
NYX 0:85b3fd62ea1a 1845
NYX 0:85b3fd62ea1a 1846 /* Configure the color frame buffer start address */
NYX 0:85b3fd62ea1a 1847 LTDC_LAYER(hltdc, LayerIdx)->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
NYX 0:85b3fd62ea1a 1848 LTDC_LAYER(hltdc, LayerIdx)->CFBAR = (pLayerCfg->FBStartAdress);
NYX 0:85b3fd62ea1a 1849
NYX 0:85b3fd62ea1a 1850 if(pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB8888)
NYX 0:85b3fd62ea1a 1851 {
NYX 0:85b3fd62ea1a 1852 tmp = 4U;
NYX 0:85b3fd62ea1a 1853 }
NYX 0:85b3fd62ea1a 1854 else if (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB888)
NYX 0:85b3fd62ea1a 1855 {
NYX 0:85b3fd62ea1a 1856 tmp = 3U;
NYX 0:85b3fd62ea1a 1857 }
NYX 0:85b3fd62ea1a 1858 else if((pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB4444) || \
NYX 0:85b3fd62ea1a 1859 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_RGB565) || \
NYX 0:85b3fd62ea1a 1860 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_ARGB1555) || \
NYX 0:85b3fd62ea1a 1861 (pLayerCfg->PixelFormat == LTDC_PIXEL_FORMAT_AL88))
NYX 0:85b3fd62ea1a 1862 {
NYX 0:85b3fd62ea1a 1863 tmp = 2U;
NYX 0:85b3fd62ea1a 1864 }
NYX 0:85b3fd62ea1a 1865 else
NYX 0:85b3fd62ea1a 1866 {
NYX 0:85b3fd62ea1a 1867 tmp = 1U;
NYX 0:85b3fd62ea1a 1868 }
NYX 0:85b3fd62ea1a 1869
NYX 0:85b3fd62ea1a 1870 /* Configure the color frame buffer pitch in byte */
NYX 0:85b3fd62ea1a 1871 LTDC_LAYER(hltdc, LayerIdx)->CFBLR &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
NYX 0:85b3fd62ea1a 1872 LTDC_LAYER(hltdc, LayerIdx)->CFBLR = (((pLayerCfg->ImageWidth * tmp) << 16U) | (((pLayerCfg->WindowX1 - pLayerCfg->WindowX0) * tmp) + 3U));
NYX 0:85b3fd62ea1a 1873
NYX 0:85b3fd62ea1a 1874 /* Configure the frame buffer line number */
NYX 0:85b3fd62ea1a 1875 LTDC_LAYER(hltdc, LayerIdx)->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR);
NYX 0:85b3fd62ea1a 1876 LTDC_LAYER(hltdc, LayerIdx)->CFBLNR = (pLayerCfg->ImageHeight);
NYX 0:85b3fd62ea1a 1877
NYX 0:85b3fd62ea1a 1878 /* Enable LTDC_Layer by setting LEN bit */
NYX 0:85b3fd62ea1a 1879 LTDC_LAYER(hltdc, LayerIdx)->CR |= (uint32_t)LTDC_LxCR_LEN;
NYX 0:85b3fd62ea1a 1880 }
NYX 0:85b3fd62ea1a 1881
NYX 0:85b3fd62ea1a 1882 /**
NYX 0:85b3fd62ea1a 1883 * @}
NYX 0:85b3fd62ea1a 1884 */
NYX 0:85b3fd62ea1a 1885 #endif /* STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
NYX 0:85b3fd62ea1a 1886 #endif /* HAL_LTDC_MODULE_ENABLED */
NYX 0:85b3fd62ea1a 1887
NYX 0:85b3fd62ea1a 1888 /**
NYX 0:85b3fd62ea1a 1889 * @}
NYX 0:85b3fd62ea1a 1890 */
NYX 0:85b3fd62ea1a 1891
NYX 0:85b3fd62ea1a 1892 /**
NYX 0:85b3fd62ea1a 1893 * @}
NYX 0:85b3fd62ea1a 1894 */
NYX 0:85b3fd62ea1a 1895
NYX 0:85b3fd62ea1a 1896 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/