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