stm32f4xx_hal_ltdc.h 31 KB

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