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