mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Sat Feb 08 19:45:06 2014 +0000
Revision:
87:085cde657901
Child:
106:ced8cbb51063
Synchronized with git revision 9272cdeb45ec7e6077641536509413da8fd2ebc2

Full URL: https://github.com/mbedmicro/mbed/commit/9272cdeb45ec7e6077641536509413da8fd2ebc2/

Add NUCLEO_F401RE, improvements

Who changed what in which revision?

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