1 /** 2 ****************************************************************************** 3 * @file stm32l4xx_hal_ltdc.h 4 * @author MCD Application Team 5 * @brief Header file of LTDC HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2017 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file 13 * in the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 * 16 ****************************************************************************** 17 */ 18 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef STM32L4xx_HAL_LTDC_H 21 #define STM32L4xx_HAL_LTDC_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32l4xx_hal_def.h" 29 30 #if defined (LTDC) 31 32 /** @addtogroup STM32L4xx_HAL_Driver 33 * @{ 34 */ 35 36 /** @defgroup LTDC LTDC 37 * @brief LTDC HAL module driver 38 * @{ 39 */ 40 41 /* Exported types ------------------------------------------------------------*/ 42 /** @defgroup LTDC_Exported_Types LTDC Exported Types 43 * @{ 44 */ 45 #if defined(LTDC_Layer2_BASE) 46 #define MAX_LAYER 2U 47 #elif defined(LTDC_Layer1_BASE) 48 #define MAX_LAYER 1U 49 #endif 50 51 /** 52 * @brief LTDC color structure definition 53 */ 54 typedef struct 55 { 56 uint8_t Blue; /*!< Configures the blue value. 57 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ 58 59 uint8_t Green; /*!< Configures the green value. 60 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ 61 62 uint8_t Red; /*!< Configures the red value. 63 This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */ 64 65 uint8_t Reserved; /*!< Reserved 0xFF */ 66 } LTDC_ColorTypeDef; 67 68 /** 69 * @brief LTDC Init structure definition 70 */ 71 typedef struct 72 { 73 uint32_t HSPolarity; /*!< configures the horizontal synchronization polarity. 74 This parameter can be one value of @ref LTDC_HS_POLARITY */ 75 76 uint32_t VSPolarity; /*!< configures the vertical synchronization polarity. 77 This parameter can be one value of @ref LTDC_VS_POLARITY */ 78 79 uint32_t DEPolarity; /*!< configures the data enable polarity. 80 This parameter can be one of value of @ref LTDC_DE_POLARITY */ 81 82 uint32_t PCPolarity; /*!< configures the pixel clock polarity. 83 This parameter can be one of value of @ref LTDC_PC_POLARITY */ 84 85 uint32_t HorizontalSync; /*!< configures the number of Horizontal synchronization width. 86 This parameter must be a number between 87 Min_Data = 0x000 and Max_Data = 0xFFF. */ 88 89 uint32_t VerticalSync; /*!< configures the number of Vertical synchronization height. 90 This parameter must be a number between 91 Min_Data = 0x000 and Max_Data = 0x7FF. */ 92 93 uint32_t AccumulatedHBP; /*!< configures the accumulated horizontal back porch width. 94 This parameter must be a number between 95 Min_Data = LTDC_HorizontalSync and Max_Data = 0xFFF. */ 96 97 uint32_t AccumulatedVBP; /*!< configures the accumulated vertical back porch height. 98 This parameter must be a number between 99 Min_Data = LTDC_VerticalSync and Max_Data = 0x7FF. */ 100 101 uint32_t AccumulatedActiveW; /*!< configures the accumulated active width. 102 This parameter must be a number between 103 Min_Data = LTDC_AccumulatedHBP and Max_Data = 0xFFF. */ 104 105 uint32_t AccumulatedActiveH; /*!< configures the accumulated active height. 106 This parameter must be a number between 107 Min_Data = LTDC_AccumulatedVBP and Max_Data = 0x7FF. */ 108 109 uint32_t TotalWidth; /*!< configures the total width. 110 This parameter must be a number between 111 Min_Data = LTDC_AccumulatedActiveW and Max_Data = 0xFFF. */ 112 113 uint32_t TotalHeigh; /*!< configures the total height. 114 This parameter must be a number between 115 Min_Data = LTDC_AccumulatedActiveH and Max_Data = 0x7FF. */ 116 117 LTDC_ColorTypeDef Backcolor; /*!< Configures the background color. */ 118 } LTDC_InitTypeDef; 119 120 /** 121 * @brief LTDC Layer structure definition 122 */ 123 typedef struct 124 { 125 uint32_t WindowX0; /*!< Configures the Window Horizontal Start Position. 126 This parameter must be a number between 127 Min_Data = 0x000 and Max_Data = 0xFFF. */ 128 129 uint32_t WindowX1; /*!< Configures the Window Horizontal Stop Position. 130 This parameter must be a number between 131 Min_Data = 0x000 and Max_Data = 0xFFF. */ 132 133 uint32_t WindowY0; /*!< Configures the Window vertical Start Position. 134 This parameter must be a number between 135 Min_Data = 0x000 and Max_Data = 0x7FF. */ 136 137 uint32_t WindowY1; /*!< Configures the Window vertical Stop Position. 138 This parameter must be a number between 139 Min_Data = 0x0000 and Max_Data = 0x7FF. */ 140 141 uint32_t PixelFormat; /*!< Specifies the pixel format. 142 This parameter can be one of value of @ref LTDC_Pixelformat */ 143 144 uint32_t Alpha; /*!< Specifies the constant alpha used for blending. 145 This parameter must be a number between 146 Min_Data = 0x00 and Max_Data = 0xFF. */ 147 148 uint32_t Alpha0; /*!< Configures the default alpha value. 149 This parameter must be a number between 150 Min_Data = 0x00 and Max_Data = 0xFF. */ 151 152 uint32_t BlendingFactor1; /*!< Select the blending factor 1. 153 This parameter can be one of value of @ref LTDC_BlendingFactor1 */ 154 155 uint32_t BlendingFactor2; /*!< Select the blending factor 2. 156 This parameter can be one of value of @ref LTDC_BlendingFactor2 */ 157 158 uint32_t FBStartAdress; /*!< Configures the color frame buffer address */ 159 160 uint32_t ImageWidth; /*!< Configures the color frame buffer line length. 161 This parameter must be a number between 162 Min_Data = 0x0000 and Max_Data = 0x1FFF. */ 163 164 uint32_t ImageHeight; /*!< Specifies the number of line in frame buffer. 165 This parameter must be a number between 166 Min_Data = 0x000 and Max_Data = 0x7FF. */ 167 168 LTDC_ColorTypeDef Backcolor; /*!< Configures the layer background color. */ 169 } LTDC_LayerCfgTypeDef; 170 171 /** 172 * @brief HAL LTDC State structures definition 173 */ 174 typedef enum 175 { 176 HAL_LTDC_STATE_RESET = 0x00U, /*!< LTDC not yet initialized or disabled */ 177 HAL_LTDC_STATE_READY = 0x01U, /*!< LTDC initialized and ready for use */ 178 HAL_LTDC_STATE_BUSY = 0x02U, /*!< LTDC internal process is ongoing */ 179 HAL_LTDC_STATE_TIMEOUT = 0x03U, /*!< LTDC Timeout state */ 180 HAL_LTDC_STATE_ERROR = 0x04U /*!< LTDC state error */ 181 } HAL_LTDC_StateTypeDef; 182 183 /** 184 * @brief LTDC handle Structure definition 185 */ 186 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) 187 typedef struct __LTDC_HandleTypeDef 188 #else 189 typedef struct 190 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */ 191 { 192 LTDC_TypeDef *Instance; /*!< LTDC Register base address */ 193 194 LTDC_InitTypeDef Init; /*!< LTDC parameters */ 195 196 LTDC_LayerCfgTypeDef LayerCfg[MAX_LAYER]; /*!< LTDC Layers parameters */ 197 198 HAL_LockTypeDef Lock; /*!< LTDC Lock */ 199 200 __IO HAL_LTDC_StateTypeDef State; /*!< LTDC state */ 201 202 __IO uint32_t ErrorCode; /*!< LTDC Error code */ 203 204 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) 205 void (* LineEventCallback)(struct __LTDC_HandleTypeDef *hltdc); /*!< LTDC Line Event Callback */ 206 void (* ReloadEventCallback)(struct __LTDC_HandleTypeDef *hltdc); /*!< LTDC Reload Event Callback */ 207 void (* ErrorCallback)(struct __LTDC_HandleTypeDef *hltdc); /*!< LTDC Error Callback */ 208 209 void (* MspInitCallback)(struct __LTDC_HandleTypeDef *hltdc); /*!< LTDC Msp Init callback */ 210 void (* MspDeInitCallback)(struct __LTDC_HandleTypeDef *hltdc); /*!< LTDC Msp DeInit callback */ 211 212 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */ 213 214 215 } LTDC_HandleTypeDef; 216 217 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) 218 /** 219 * @brief HAL LTDC Callback ID enumeration definition 220 */ 221 typedef enum 222 { 223 HAL_LTDC_MSPINIT_CB_ID = 0x00U, /*!< LTDC MspInit callback ID */ 224 HAL_LTDC_MSPDEINIT_CB_ID = 0x01U, /*!< LTDC MspDeInit callback ID */ 225 226 HAL_LTDC_LINE_EVENT_CB_ID = 0x02U, /*!< LTDC Line Event Callback ID */ 227 HAL_LTDC_RELOAD_EVENT_CB_ID = 0x03U, /*!< LTDC Reload Callback ID */ 228 HAL_LTDC_ERROR_CB_ID = 0x04U /*!< LTDC Error Callback ID */ 229 230 } HAL_LTDC_CallbackIDTypeDef; 231 232 /** 233 * @brief HAL LTDC Callback pointer definition 234 */ 235 typedef void (*pLTDC_CallbackTypeDef)(LTDC_HandleTypeDef *hltdc); /*!< pointer to an LTDC callback function */ 236 237 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */ 238 239 /** 240 * @} 241 */ 242 243 /* Exported constants --------------------------------------------------------*/ 244 /** @defgroup LTDC_Exported_Constants LTDC Exported Constants 245 * @{ 246 */ 247 248 /** @defgroup LTDC_Error_Code LTDC Error Code 249 * @{ 250 */ 251 #define HAL_LTDC_ERROR_NONE 0x00000000U /*!< LTDC No error */ 252 #define HAL_LTDC_ERROR_TE 0x00000001U /*!< LTDC Transfer error */ 253 #define HAL_LTDC_ERROR_FU 0x00000002U /*!< LTDC FIFO Underrun */ 254 #define HAL_LTDC_ERROR_TIMEOUT 0x00000020U /*!< LTDC Timeout error */ 255 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) 256 #define HAL_LTDC_ERROR_INVALID_CALLBACK 0x00000040U /*!< LTDC Invalid Callback error */ 257 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */ 258 /** 259 * @} 260 */ 261 262 /** @defgroup LTDC_Layer LTDC Layer 263 * @{ 264 */ 265 #if defined(LTDC_Layer1_BASE) 266 #define LTDC_LAYER_1 0x00000000U /*!< LTDC Layer 1 */ 267 #endif 268 #if defined(LTDC_Layer2_BASE) 269 #define LTDC_LAYER_2 0x00000001U /*!< LTDC Layer 2 */ 270 #endif 271 /** 272 * @} 273 */ 274 275 /** @defgroup LTDC_HS_POLARITY LTDC HS POLARITY 276 * @{ 277 */ 278 #define LTDC_HSPOLARITY_AL 0x00000000U /*!< Horizontal Synchronization is active low. */ 279 #define LTDC_HSPOLARITY_AH LTDC_GCR_HSPOL /*!< Horizontal Synchronization is active high. */ 280 /** 281 * @} 282 */ 283 284 /** @defgroup LTDC_VS_POLARITY LTDC VS POLARITY 285 * @{ 286 */ 287 #define LTDC_VSPOLARITY_AL 0x00000000U /*!< Vertical Synchronization is active low. */ 288 #define LTDC_VSPOLARITY_AH LTDC_GCR_VSPOL /*!< Vertical Synchronization is active high. */ 289 /** 290 * @} 291 */ 292 293 /** @defgroup LTDC_DE_POLARITY LTDC DE POLARITY 294 * @{ 295 */ 296 #define LTDC_DEPOLARITY_AL 0x00000000U /*!< Data Enable, is active low. */ 297 #define LTDC_DEPOLARITY_AH LTDC_GCR_DEPOL /*!< Data Enable, is active high. */ 298 /** 299 * @} 300 */ 301 302 /** @defgroup LTDC_PC_POLARITY LTDC PC POLARITY 303 * @{ 304 */ 305 #define LTDC_PCPOLARITY_IPC 0x00000000U /*!< input pixel clock. */ 306 #define LTDC_PCPOLARITY_IIPC LTDC_GCR_PCPOL /*!< inverted input pixel clock. */ 307 /** 308 * @} 309 */ 310 311 /** @defgroup LTDC_SYNC LTDC SYNC 312 * @{ 313 */ 314 #define LTDC_HORIZONTALSYNC (LTDC_SSCR_HSW >> 16U) /*!< Horizontal synchronization width. */ 315 #define LTDC_VERTICALSYNC LTDC_SSCR_VSH /*!< Vertical synchronization height. */ 316 /** 317 * @} 318 */ 319 320 /** @defgroup LTDC_BACK_COLOR LTDC BACK COLOR 321 * @{ 322 */ 323 #define LTDC_COLOR 0x000000FFU /*!< Color mask */ 324 /** 325 * @} 326 */ 327 328 /** @defgroup LTDC_BlendingFactor1 LTDC Blending Factor1 329 * @{ 330 */ 331 #define LTDC_BLENDING_FACTOR1_CA 0x00000400U /*!< Blending factor : Cte Alpha */ 332 #define LTDC_BLENDING_FACTOR1_PAxCA 0x00000600U /*!< Blending factor : Cte Alpha x Pixel Alpha*/ 333 /** 334 * @} 335 */ 336 337 /** @defgroup LTDC_BlendingFactor2 LTDC Blending Factor2 338 * @{ 339 */ 340 #define LTDC_BLENDING_FACTOR2_CA 0x00000005U /*!< Blending factor : Cte Alpha */ 341 #define LTDC_BLENDING_FACTOR2_PAxCA 0x00000007U /*!< Blending factor : Cte Alpha x Pixel Alpha*/ 342 /** 343 * @} 344 */ 345 346 /** @defgroup LTDC_Pixelformat LTDC Pixel format 347 * @{ 348 */ 349 #define LTDC_PIXEL_FORMAT_ARGB8888 0x00000000U /*!< ARGB8888 LTDC pixel format */ 350 #define LTDC_PIXEL_FORMAT_RGB888 0x00000001U /*!< RGB888 LTDC pixel format */ 351 #define LTDC_PIXEL_FORMAT_RGB565 0x00000002U /*!< RGB565 LTDC pixel format */ 352 #define LTDC_PIXEL_FORMAT_ARGB1555 0x00000003U /*!< ARGB1555 LTDC pixel format */ 353 #define LTDC_PIXEL_FORMAT_ARGB4444 0x00000004U /*!< ARGB4444 LTDC pixel format */ 354 #define LTDC_PIXEL_FORMAT_L8 0x00000005U /*!< L8 LTDC pixel format */ 355 #define LTDC_PIXEL_FORMAT_AL44 0x00000006U /*!< AL44 LTDC pixel format */ 356 #define LTDC_PIXEL_FORMAT_AL88 0x00000007U /*!< AL88 LTDC pixel format */ 357 /** 358 * @} 359 */ 360 361 /** @defgroup LTDC_Alpha LTDC Alpha 362 * @{ 363 */ 364 #define LTDC_ALPHA LTDC_LxCACR_CONSTA /*!< LTDC Constant Alpha mask */ 365 /** 366 * @} 367 */ 368 369 /** @defgroup LTDC_LAYER_Config LTDC LAYER Config 370 * @{ 371 */ 372 #define LTDC_STOPPOSITION (LTDC_LxWHPCR_WHSPPOS >> 16U) /*!< LTDC Layer stop position */ 373 #define LTDC_STARTPOSITION LTDC_LxWHPCR_WHSTPOS /*!< LTDC Layer start position */ 374 375 #define LTDC_COLOR_FRAME_BUFFER LTDC_LxCFBLR_CFBLL /*!< LTDC Layer Line length */ 376 #define LTDC_LINE_NUMBER LTDC_LxCFBLNR_CFBLNBR /*!< LTDC Layer Line number */ 377 /** 378 * @} 379 */ 380 381 /** @defgroup LTDC_Interrupts LTDC Interrupts 382 * @{ 383 */ 384 #define LTDC_IT_LI LTDC_IER_LIE /*!< LTDC Line Interrupt */ 385 #define LTDC_IT_FU LTDC_IER_FUIE /*!< LTDC FIFO Underrun Interrupt */ 386 #define LTDC_IT_TE LTDC_IER_TERRIE /*!< LTDC Transfer Error Interrupt */ 387 #define LTDC_IT_RR LTDC_IER_RRIE /*!< LTDC Register Reload Interrupt */ 388 /** 389 * @} 390 */ 391 392 /** @defgroup LTDC_Flags LTDC Flags 393 * @{ 394 */ 395 #define LTDC_FLAG_LI LTDC_ISR_LIF /*!< LTDC Line Interrupt Flag */ 396 #define LTDC_FLAG_FU LTDC_ISR_FUIF /*!< LTDC FIFO Underrun interrupt Flag */ 397 #define LTDC_FLAG_TE LTDC_ISR_TERRIF /*!< LTDC Transfer Error interrupt Flag */ 398 #define LTDC_FLAG_RR LTDC_ISR_RRIF /*!< LTDC Register Reload interrupt Flag */ 399 /** 400 * @} 401 */ 402 403 /** @defgroup LTDC_Reload_Type LTDC Reload Type 404 * @{ 405 */ 406 #define LTDC_RELOAD_IMMEDIATE LTDC_SRCR_IMR /*!< Immediate Reload */ 407 #define LTDC_RELOAD_VERTICAL_BLANKING LTDC_SRCR_VBR /*!< Vertical Blanking Reload */ 408 /** 409 * @} 410 */ 411 412 /** 413 * @} 414 */ 415 416 /* Exported macro ------------------------------------------------------------*/ 417 /** @defgroup LTDC_Exported_Macros LTDC Exported Macros 418 * @{ 419 */ 420 421 /** @brief Reset LTDC handle state. 422 * @param __HANDLE__ LTDC handle 423 * @retval None 424 */ 425 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) 426 #define __HAL_LTDC_RESET_HANDLE_STATE(__HANDLE__) do{ \ 427 (__HANDLE__)->State = HAL_LTDC_STATE_RESET; \ 428 (__HANDLE__)->MspInitCallback = NULL; \ 429 (__HANDLE__)->MspDeInitCallback = NULL; \ 430 } while(0) 431 #else 432 #define __HAL_LTDC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_LTDC_STATE_RESET) 433 #endif /*USE_HAL_LTDC_REGISTER_CALLBACKS */ 434 435 /** 436 * @brief Enable the LTDC. 437 * @param __HANDLE__ LTDC handle 438 * @retval None. 439 */ 440 #define __HAL_LTDC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->GCR |= LTDC_GCR_LTDCEN) 441 442 /** 443 * @brief Disable the LTDC. 444 * @param __HANDLE__ LTDC handle 445 * @retval None. 446 */ 447 #define __HAL_LTDC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->GCR &= ~(LTDC_GCR_LTDCEN)) 448 449 /** 450 * @brief Enable the LTDC Layer. 451 * @param __HANDLE__ LTDC handle 452 * @param __LAYER__ Specify the layer to be enabled. 453 * This parameter can be LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1). 454 * @retval None. 455 */ 456 #define __HAL_LTDC_LAYER_ENABLE(__HANDLE__, __LAYER__) ((LTDC_LAYER((__HANDLE__), (__LAYER__)))->CR\ 457 |= (uint32_t)LTDC_LxCR_LEN) 458 459 /** 460 * @brief Disable the LTDC Layer. 461 * @param __HANDLE__ LTDC handle 462 * @param __LAYER__ Specify the layer to be disabled. 463 * This parameter can be LTDC_LAYER_1 (0) or LTDC_LAYER_2 (1). 464 * @retval None. 465 */ 466 #define __HAL_LTDC_LAYER_DISABLE(__HANDLE__, __LAYER__) ((LTDC_LAYER((__HANDLE__), (__LAYER__)))->CR\ 467 &= ~(uint32_t)LTDC_LxCR_LEN) 468 469 /** 470 * @brief Reload immediately all LTDC Layers. 471 * @param __HANDLE__ LTDC handle 472 * @retval None. 473 */ 474 #define __HAL_LTDC_RELOAD_IMMEDIATE_CONFIG(__HANDLE__) ((__HANDLE__)->Instance->SRCR |= LTDC_SRCR_IMR) 475 476 /** 477 * @brief Reload during vertical blanking period all LTDC Layers. 478 * @param __HANDLE__ LTDC handle 479 * @retval None. 480 */ 481 #define __HAL_LTDC_VERTICAL_BLANKING_RELOAD_CONFIG(__HANDLE__) ((__HANDLE__)->Instance->SRCR |= LTDC_SRCR_VBR) 482 483 /* Interrupt & Flag management */ 484 /** 485 * @brief Get the LTDC pending flags. 486 * @param __HANDLE__ LTDC handle 487 * @param __FLAG__ Get the specified flag. 488 * This parameter can be any combination of the following values: 489 * @arg LTDC_FLAG_LI: Line Interrupt flag 490 * @arg LTDC_FLAG_FU: FIFO Underrun Interrupt flag 491 * @arg LTDC_FLAG_TE: Transfer Error interrupt flag 492 * @arg LTDC_FLAG_RR: Register Reload Interrupt Flag 493 * @retval The state of FLAG (SET or RESET). 494 */ 495 #define __HAL_LTDC_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR & (__FLAG__)) 496 497 /** 498 * @brief Clears the LTDC pending flags. 499 * @param __HANDLE__ LTDC handle 500 * @param __FLAG__ Specify the flag to clear. 501 * This parameter can be any combination of the following values: 502 * @arg LTDC_FLAG_LI: Line Interrupt flag 503 * @arg LTDC_FLAG_FU: FIFO Underrun Interrupt flag 504 * @arg LTDC_FLAG_TE: Transfer Error interrupt flag 505 * @arg LTDC_FLAG_RR: Register Reload Interrupt Flag 506 * @retval None 507 */ 508 #define __HAL_LTDC_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__)) 509 510 /** 511 * @brief Enables the specified LTDC interrupts. 512 * @param __HANDLE__ LTDC handle 513 * @param __INTERRUPT__ Specify the LTDC interrupt sources to be enabled. 514 * This parameter can be any combination of the following values: 515 * @arg LTDC_IT_LI: Line Interrupt flag 516 * @arg LTDC_IT_FU: FIFO Underrun Interrupt flag 517 * @arg LTDC_IT_TE: Transfer Error interrupt flag 518 * @arg LTDC_IT_RR: Register Reload Interrupt Flag 519 * @retval None 520 */ 521 #define __HAL_LTDC_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__)) 522 523 /** 524 * @brief Disables the specified LTDC interrupts. 525 * @param __HANDLE__ LTDC handle 526 * @param __INTERRUPT__ Specify the LTDC interrupt sources to be disabled. 527 * This parameter can be any combination of the following values: 528 * @arg LTDC_IT_LI: Line Interrupt flag 529 * @arg LTDC_IT_FU: FIFO Underrun Interrupt flag 530 * @arg LTDC_IT_TE: Transfer Error interrupt flag 531 * @arg LTDC_IT_RR: Register Reload Interrupt Flag 532 * @retval None 533 */ 534 #define __HAL_LTDC_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= ~(__INTERRUPT__)) 535 536 /** 537 * @brief Check whether the specified LTDC interrupt has occurred or not. 538 * @param __HANDLE__ LTDC handle 539 * @param __INTERRUPT__ Specify the LTDC interrupt source to check. 540 * This parameter can be one of the following values: 541 * @arg LTDC_IT_LI: Line Interrupt flag 542 * @arg LTDC_IT_FU: FIFO Underrun Interrupt flag 543 * @arg LTDC_IT_TE: Transfer Error interrupt flag 544 * @arg LTDC_IT_RR: Register Reload Interrupt Flag 545 * @retval The state of INTERRUPT (SET or RESET). 546 */ 547 #define __HAL_LTDC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER & (__INTERRUPT__)) 548 /** 549 * @} 550 */ 551 552 /* Include LTDC HAL Extension module */ 553 #include "stm32l4xx_hal_ltdc_ex.h" 554 555 /* Exported functions --------------------------------------------------------*/ 556 /** @addtogroup LTDC_Exported_Functions 557 * @{ 558 */ 559 /** @addtogroup LTDC_Exported_Functions_Group1 560 * @{ 561 */ 562 /* Initialization and de-initialization functions *****************************/ 563 HAL_StatusTypeDef HAL_LTDC_Init(LTDC_HandleTypeDef *hltdc); 564 HAL_StatusTypeDef HAL_LTDC_DeInit(LTDC_HandleTypeDef *hltdc); 565 void HAL_LTDC_MspInit(LTDC_HandleTypeDef *hltdc); 566 void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef *hltdc); 567 void HAL_LTDC_ErrorCallback(LTDC_HandleTypeDef *hltdc); 568 void HAL_LTDC_LineEventCallback(LTDC_HandleTypeDef *hltdc); 569 void HAL_LTDC_ReloadEventCallback(LTDC_HandleTypeDef *hltdc); 570 571 /* Callbacks Register/UnRegister functions ***********************************/ 572 #if (USE_HAL_LTDC_REGISTER_CALLBACKS == 1) 573 HAL_StatusTypeDef HAL_LTDC_RegisterCallback(LTDC_HandleTypeDef *hltdc, HAL_LTDC_CallbackIDTypeDef CallbackID, 574 pLTDC_CallbackTypeDef pCallback); 575 HAL_StatusTypeDef HAL_LTDC_UnRegisterCallback(LTDC_HandleTypeDef *hltdc, HAL_LTDC_CallbackIDTypeDef CallbackID); 576 #endif /* USE_HAL_LTDC_REGISTER_CALLBACKS */ 577 578 /** 579 * @} 580 */ 581 582 /** @addtogroup LTDC_Exported_Functions_Group2 583 * @{ 584 */ 585 /* IO operation functions *****************************************************/ 586 void HAL_LTDC_IRQHandler(LTDC_HandleTypeDef *hltdc); 587 /** 588 * @} 589 */ 590 591 /** @addtogroup LTDC_Exported_Functions_Group3 592 * @{ 593 */ 594 /* Peripheral Control functions ***********************************************/ 595 HAL_StatusTypeDef HAL_LTDC_ConfigLayer(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, uint32_t LayerIdx); 596 HAL_StatusTypeDef HAL_LTDC_SetWindowSize(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, uint32_t LayerIdx); 597 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, uint32_t LayerIdx); 598 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx); 599 HAL_StatusTypeDef HAL_LTDC_SetAlpha(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx); 600 HAL_StatusTypeDef HAL_LTDC_SetAddress(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx); 601 HAL_StatusTypeDef HAL_LTDC_SetPitch(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx); 602 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx); 603 HAL_StatusTypeDef HAL_LTDC_ConfigCLUT(LTDC_HandleTypeDef *hltdc, uint32_t *pCLUT, uint32_t CLUTSize, uint32_t LayerIdx); 604 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); 605 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); 606 HAL_StatusTypeDef HAL_LTDC_EnableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); 607 HAL_StatusTypeDef HAL_LTDC_DisableCLUT(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); 608 HAL_StatusTypeDef HAL_LTDC_ProgramLineEvent(LTDC_HandleTypeDef *hltdc, uint32_t Line); 609 HAL_StatusTypeDef HAL_LTDC_EnableDither(LTDC_HandleTypeDef *hltdc); 610 HAL_StatusTypeDef HAL_LTDC_DisableDither(LTDC_HandleTypeDef *hltdc); 611 HAL_StatusTypeDef HAL_LTDC_Reload(LTDC_HandleTypeDef *hltdc, uint32_t ReloadType); 612 HAL_StatusTypeDef HAL_LTDC_ConfigLayer_NoReload(LTDC_HandleTypeDef *hltdc, LTDC_LayerCfgTypeDef *pLayerCfg, 613 uint32_t LayerIdx); 614 HAL_StatusTypeDef HAL_LTDC_SetWindowSize_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t XSize, uint32_t YSize, 615 uint32_t LayerIdx); 616 HAL_StatusTypeDef HAL_LTDC_SetWindowPosition_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t X0, uint32_t Y0, 617 uint32_t LayerIdx); 618 HAL_StatusTypeDef HAL_LTDC_SetPixelFormat_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Pixelformat, uint32_t LayerIdx); 619 HAL_StatusTypeDef HAL_LTDC_SetAlpha_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Alpha, uint32_t LayerIdx); 620 HAL_StatusTypeDef HAL_LTDC_SetAddress_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t Address, uint32_t LayerIdx); 621 HAL_StatusTypeDef HAL_LTDC_SetPitch_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LinePitchInPixels, uint32_t LayerIdx); 622 HAL_StatusTypeDef HAL_LTDC_ConfigColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t RGBValue, uint32_t LayerIdx); 623 HAL_StatusTypeDef HAL_LTDC_EnableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); 624 HAL_StatusTypeDef HAL_LTDC_DisableColorKeying_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); 625 HAL_StatusTypeDef HAL_LTDC_EnableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); 626 HAL_StatusTypeDef HAL_LTDC_DisableCLUT_NoReload(LTDC_HandleTypeDef *hltdc, uint32_t LayerIdx); 627 628 /** 629 * @} 630 */ 631 632 /** @addtogroup LTDC_Exported_Functions_Group4 633 * @{ 634 */ 635 /* Peripheral State functions *************************************************/ 636 HAL_LTDC_StateTypeDef HAL_LTDC_GetState(LTDC_HandleTypeDef *hltdc); 637 uint32_t HAL_LTDC_GetError(LTDC_HandleTypeDef *hltdc); 638 /** 639 * @} 640 */ 641 642 /** 643 * @} 644 */ 645 646 /* Private types -------------------------------------------------------------*/ 647 /* Private variables ---------------------------------------------------------*/ 648 /* Private constants ---------------------------------------------------------*/ 649 /* Private macros ------------------------------------------------------------*/ 650 /** @defgroup LTDC_Private_Macros LTDC Private Macros 651 * @{ 652 */ 653 #define LTDC_LAYER(__HANDLE__, __LAYER__) ((LTDC_Layer_TypeDef *)((uint32_t)(\ 654 ((uint32_t)((__HANDLE__)->Instance))\ 655 + 0x84U + (0x80U*(__LAYER__))))) 656 #define IS_LTDC_LAYER(__LAYER__) ((__LAYER__) < MAX_LAYER) 657 #define IS_LTDC_HSPOL(__HSPOL__) (((__HSPOL__) == LTDC_HSPOLARITY_AL)\ 658 || ((__HSPOL__) == LTDC_HSPOLARITY_AH)) 659 #define IS_LTDC_VSPOL(__VSPOL__) (((__VSPOL__) == LTDC_VSPOLARITY_AL)\ 660 || ((__VSPOL__) == LTDC_VSPOLARITY_AH)) 661 #define IS_LTDC_DEPOL(__DEPOL__) (((__DEPOL__) == LTDC_DEPOLARITY_AL)\ 662 || ((__DEPOL__) == LTDC_DEPOLARITY_AH)) 663 #define IS_LTDC_PCPOL(__PCPOL__) (((__PCPOL__) == LTDC_PCPOLARITY_IPC)\ 664 || ((__PCPOL__) == LTDC_PCPOLARITY_IIPC)) 665 #define IS_LTDC_HSYNC(__HSYNC__) ((__HSYNC__) <= LTDC_HORIZONTALSYNC) 666 #define IS_LTDC_VSYNC(__VSYNC__) ((__VSYNC__) <= LTDC_VERTICALSYNC) 667 #define IS_LTDC_AHBP(__AHBP__) ((__AHBP__) <= LTDC_HORIZONTALSYNC) 668 #define IS_LTDC_AVBP(__AVBP__) ((__AVBP__) <= LTDC_VERTICALSYNC) 669 #define IS_LTDC_AAW(__AAW__) ((__AAW__) <= LTDC_HORIZONTALSYNC) 670 #define IS_LTDC_AAH(__AAH__) ((__AAH__) <= LTDC_VERTICALSYNC) 671 #define IS_LTDC_TOTALW(__TOTALW__) ((__TOTALW__) <= LTDC_HORIZONTALSYNC) 672 #define IS_LTDC_TOTALH(__TOTALH__) ((__TOTALH__) <= LTDC_VERTICALSYNC) 673 #define IS_LTDC_BLUEVALUE(__BBLUE__) ((__BBLUE__) <= LTDC_COLOR) 674 #define IS_LTDC_GREENVALUE(__BGREEN__) ((__BGREEN__) <= LTDC_COLOR) 675 #define IS_LTDC_REDVALUE(__BRED__) ((__BRED__) <= LTDC_COLOR) 676 #define IS_LTDC_BLENDING_FACTOR1(__BLENDING_FACTOR1__) (((__BLENDING_FACTOR1__) == LTDC_BLENDING_FACTOR1_CA) || \ 677 ((__BLENDING_FACTOR1__) == LTDC_BLENDING_FACTOR1_PAxCA)) 678 #define IS_LTDC_BLENDING_FACTOR2(__BLENDING_FACTOR1__) (((__BLENDING_FACTOR1__) == LTDC_BLENDING_FACTOR2_CA) || \ 679 ((__BLENDING_FACTOR1__) == LTDC_BLENDING_FACTOR2_PAxCA)) 680 #define IS_LTDC_PIXEL_FORMAT(__PIXEL_FORMAT__) (((__PIXEL_FORMAT__) == LTDC_PIXEL_FORMAT_ARGB8888) || \ 681 ((__PIXEL_FORMAT__) == LTDC_PIXEL_FORMAT_RGB888) || \ 682 ((__PIXEL_FORMAT__) == LTDC_PIXEL_FORMAT_RGB565) || \ 683 ((__PIXEL_FORMAT__) == LTDC_PIXEL_FORMAT_ARGB1555) || \ 684 ((__PIXEL_FORMAT__) == LTDC_PIXEL_FORMAT_ARGB4444) || \ 685 ((__PIXEL_FORMAT__) == LTDC_PIXEL_FORMAT_L8) || \ 686 ((__PIXEL_FORMAT__) == LTDC_PIXEL_FORMAT_AL44) || \ 687 ((__PIXEL_FORMAT__) == LTDC_PIXEL_FORMAT_AL88)) 688 #define IS_LTDC_ALPHA(__ALPHA__) ((__ALPHA__) <= LTDC_ALPHA) 689 #define IS_LTDC_HCONFIGST(__HCONFIGST__) ((__HCONFIGST__) <= LTDC_STARTPOSITION) 690 #define IS_LTDC_HCONFIGSP(__HCONFIGSP__) ((__HCONFIGSP__) <= LTDC_STOPPOSITION) 691 #define IS_LTDC_VCONFIGST(__VCONFIGST__) ((__VCONFIGST__) <= LTDC_STARTPOSITION) 692 #define IS_LTDC_VCONFIGSP(__VCONFIGSP__) ((__VCONFIGSP__) <= LTDC_STOPPOSITION) 693 #define IS_LTDC_CFBP(__CFBP__) ((__CFBP__) <= LTDC_COLOR_FRAME_BUFFER) 694 #define IS_LTDC_CFBLL(__CFBLL__) ((__CFBLL__) <= LTDC_COLOR_FRAME_BUFFER) 695 #define IS_LTDC_CFBLNBR(__CFBLNBR__) ((__CFBLNBR__) <= LTDC_LINE_NUMBER) 696 #define IS_LTDC_LIPOS(__LIPOS__) ((__LIPOS__) <= 0x7FFU) 697 #define IS_LTDC_RELOAD(__RELOADTYPE__) (((__RELOADTYPE__) == LTDC_RELOAD_IMMEDIATE) || \ 698 ((__RELOADTYPE__) == LTDC_RELOAD_VERTICAL_BLANKING)) 699 /** 700 * @} 701 */ 702 703 /* Private functions ---------------------------------------------------------*/ 704 /** @defgroup LTDC_Private_Functions LTDC Private Functions 705 * @{ 706 */ 707 708 /** 709 * @} 710 */ 711 712 /** 713 * @} 714 */ 715 716 /** 717 * @} 718 */ 719 720 #endif /* LTDC */ 721 722 #ifdef __cplusplus 723 } 724 #endif 725 726 #endif /* STM32L4xx_HAL_LTDC_H */ 727