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