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