You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

675 lines
29 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_dma2d.h
  4. * @author MCD Application Team
  5. * @brief Header file of DMA2D 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. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_HAL_DMA2D_H
  21. #define STM32H7xx_HAL_DMA2D_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup DMA2D DMA2D
  31. * @brief DMA2D HAL module driver
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /** @defgroup DMA2D_Exported_Types DMA2D Exported Types
  36. * @{
  37. */
  38. #define MAX_DMA2D_LAYER 2U /*!< DMA2D maximum number of layers */
  39. /**
  40. * @brief DMA2D CLUT Structure definition
  41. */
  42. typedef struct
  43. {
  44. uint32_t *pCLUT; /*!< Configures the DMA2D CLUT memory address.*/
  45. uint32_t CLUTColorMode; /*!< Configures the DMA2D CLUT color mode.
  46. This parameter can be one value of @ref DMA2D_CLUT_CM. */
  47. uint32_t Size; /*!< Configures the DMA2D CLUT size.
  48. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.*/
  49. } DMA2D_CLUTCfgTypeDef;
  50. /**
  51. * @brief DMA2D Init structure definition
  52. */
  53. typedef struct
  54. {
  55. uint32_t Mode; /*!< Configures the DMA2D transfer mode.
  56. This parameter can be one value of @ref DMA2D_Mode. */
  57. uint32_t ColorMode; /*!< Configures the color format of the output image.
  58. This parameter can be one value of @ref DMA2D_Output_Color_Mode. */
  59. uint32_t OutputOffset; /*!< Specifies the Offset value.
  60. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF. */
  61. uint32_t AlphaInverted; /*!< Select regular or inverted alpha value for the output pixel format converter.
  62. This parameter can be one value of @ref DMA2D_Alpha_Inverted. */
  63. uint32_t RedBlueSwap; /*!< Select regular mode (RGB or ARGB) or swap mode (BGR or ABGR)
  64. for the output pixel format converter.
  65. This parameter can be one value of @ref DMA2D_RB_Swap. */
  66. } DMA2D_InitTypeDef;
  67. /**
  68. * @brief DMA2D Layer structure definition
  69. */
  70. typedef struct
  71. {
  72. uint32_t InputOffset; /*!< Configures the DMA2D foreground or background offset.
  73. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF. */
  74. uint32_t InputColorMode; /*!< Configures the DMA2D foreground or background color mode.
  75. This parameter can be one value of @ref DMA2D_Input_Color_Mode. */
  76. uint32_t AlphaMode; /*!< Configures the DMA2D foreground or background alpha mode.
  77. This parameter can be one value of @ref DMA2D_Alpha_Mode. */
  78. uint32_t InputAlpha; /*!< Specifies the DMA2D foreground or background alpha value and color value in case of A8 or A4 color mode.
  79. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF except for the color modes detailed below.
  80. @note In case of A8 or A4 color mode (ARGB), this parameter must be a number between
  81. Min_Data = 0x00000000 and Max_Data = 0xFFFFFFFF where
  82. - InputAlpha[24:31] is the alpha value ALPHA[0:7]
  83. - InputAlpha[16:23] is the red value RED[0:7]
  84. - InputAlpha[8:15] is the green value GREEN[0:7]
  85. - InputAlpha[0:7] is the blue value BLUE[0:7]. */
  86. uint32_t AlphaInverted; /*!< Select regular or inverted alpha value.
  87. This parameter can be one value of @ref DMA2D_Alpha_Inverted. */
  88. uint32_t RedBlueSwap; /*!< Select regular mode (RGB or ARGB) or swap mode (BGR or ABGR).
  89. This parameter can be one value of @ref DMA2D_RB_Swap. */
  90. uint32_t ChromaSubSampling; /*!< Configure the chroma sub-sampling mode for the YCbCr color mode
  91. This parameter can be one value of @ref DMA2D_Chroma_Sub_Sampling */
  92. } DMA2D_LayerCfgTypeDef;
  93. /**
  94. * @brief HAL DMA2D State structures definition
  95. */
  96. typedef enum
  97. {
  98. HAL_DMA2D_STATE_RESET = 0x00U, /*!< DMA2D not yet initialized or disabled */
  99. HAL_DMA2D_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
  100. HAL_DMA2D_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
  101. HAL_DMA2D_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
  102. HAL_DMA2D_STATE_ERROR = 0x04U, /*!< DMA2D state error */
  103. HAL_DMA2D_STATE_SUSPEND = 0x05U /*!< DMA2D process is suspended */
  104. }HAL_DMA2D_StateTypeDef;
  105. /**
  106. * @brief DMA2D handle Structure definition
  107. */
  108. typedef struct __DMA2D_HandleTypeDef
  109. {
  110. DMA2D_TypeDef *Instance; /*!< DMA2D register base address. */
  111. DMA2D_InitTypeDef Init; /*!< DMA2D communication parameters. */
  112. void (* XferCpltCallback)(struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D transfer complete callback. */
  113. void (* XferErrorCallback)(struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D transfer error callback. */
  114. #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
  115. void (* LineEventCallback)( struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D line event callback. */
  116. void (* CLUTLoadingCpltCallback)( struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D CLUT loading completion callback. */
  117. void (* MspInitCallback)( struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D Msp Init callback. */
  118. void (* MspDeInitCallback)( struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D Msp DeInit callback. */
  119. #endif /* (USE_HAL_DMA2D_REGISTER_CALLBACKS) */
  120. DMA2D_LayerCfgTypeDef LayerCfg[MAX_DMA2D_LAYER]; /*!< DMA2D Layers parameters */
  121. HAL_LockTypeDef Lock; /*!< DMA2D lock. */
  122. __IO HAL_DMA2D_StateTypeDef State; /*!< DMA2D transfer state. */
  123. __IO uint32_t ErrorCode; /*!< DMA2D error code. */
  124. } DMA2D_HandleTypeDef;
  125. #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
  126. /**
  127. * @brief HAL DMA2D Callback pointer definition
  128. */
  129. typedef void (*pDMA2D_CallbackTypeDef)(DMA2D_HandleTypeDef * hdma2d); /*!< Pointer to a DMA2D common callback function */
  130. #endif /* USE_HAL_DMA2D_REGISTER_CALLBACKS */
  131. /**
  132. * @}
  133. */
  134. /* Exported constants --------------------------------------------------------*/
  135. /** @defgroup DMA2D_Exported_Constants DMA2D Exported Constants
  136. * @{
  137. */
  138. /** @defgroup DMA2D_Error_Code DMA2D Error Code
  139. * @{
  140. */
  141. #define HAL_DMA2D_ERROR_NONE 0x00000000U /*!< No error */
  142. #define HAL_DMA2D_ERROR_TE 0x00000001U /*!< Transfer error */
  143. #define HAL_DMA2D_ERROR_CE 0x00000002U /*!< Configuration error */
  144. #define HAL_DMA2D_ERROR_CAE 0x00000004U /*!< CLUT access error */
  145. #define HAL_DMA2D_ERROR_TIMEOUT 0x00000020U /*!< Timeout error */
  146. #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
  147. #define HAL_DMA2D_ERROR_INVALID_CALLBACK 0x00000040U /*!< Invalid callback error */
  148. #endif /* USE_HAL_UART_REGISTER_CALLBACKS */
  149. /**
  150. * @}
  151. */
  152. /** @defgroup DMA2D_Mode DMA2D Mode
  153. * @{
  154. */
  155. #define DMA2D_M2M 0x00000000U /*!< DMA2D memory to memory transfer mode */
  156. #define DMA2D_M2M_PFC DMA2D_CR_MODE_0 /*!< DMA2D memory to memory with pixel format conversion transfer mode */
  157. #define DMA2D_M2M_BLEND DMA2D_CR_MODE_1 /*!< DMA2D memory to memory with blending transfer mode */
  158. #define DMA2D_R2M DMA2D_CR_MODE /*!< DMA2D register to memory transfer mode */
  159. /**
  160. * @}
  161. */
  162. /** @defgroup DMA2D_Output_Color_Mode DMA2D Output Color Mode
  163. * @{
  164. */
  165. #define DMA2D_OUTPUT_ARGB8888 0x00000000U /*!< ARGB8888 DMA2D color mode */
  166. #define DMA2D_OUTPUT_RGB888 DMA2D_OPFCCR_CM_0 /*!< RGB888 DMA2D color mode */
  167. #define DMA2D_OUTPUT_RGB565 DMA2D_OPFCCR_CM_1 /*!< RGB565 DMA2D color mode */
  168. #define DMA2D_OUTPUT_ARGB1555 (DMA2D_OPFCCR_CM_0|DMA2D_OPFCCR_CM_1) /*!< ARGB1555 DMA2D color mode */
  169. #define DMA2D_OUTPUT_ARGB4444 DMA2D_OPFCCR_CM_2 /*!< ARGB4444 DMA2D color mode */
  170. /**
  171. * @}
  172. */
  173. /** @defgroup DMA2D_Input_Color_Mode DMA2D Input Color Mode
  174. * @{
  175. */
  176. #define DMA2D_INPUT_ARGB8888 0x00000000U /*!< ARGB8888 color mode */
  177. #define DMA2D_INPUT_RGB888 0x00000001U /*!< RGB888 color mode */
  178. #define DMA2D_INPUT_RGB565 0x00000002U /*!< RGB565 color mode */
  179. #define DMA2D_INPUT_ARGB1555 0x00000003U /*!< ARGB1555 color mode */
  180. #define DMA2D_INPUT_ARGB4444 0x00000004U /*!< ARGB4444 color mode */
  181. #define DMA2D_INPUT_L8 0x00000005U /*!< L8 color mode */
  182. #define DMA2D_INPUT_AL44 0x00000006U /*!< AL44 color mode */
  183. #define DMA2D_INPUT_AL88 0x00000007U /*!< AL88 color mode */
  184. #define DMA2D_INPUT_L4 0x00000008U /*!< L4 color mode */
  185. #define DMA2D_INPUT_A8 0x00000009U /*!< A8 color mode */
  186. #define DMA2D_INPUT_A4 0x0000000AU /*!< A4 color mode */
  187. #define DMA2D_INPUT_YCBCR 0x0000000BU /*!< YCbCr color mode */
  188. /**
  189. * @}
  190. */
  191. /** @defgroup DMA2D_Alpha_Mode DMA2D Alpha Mode
  192. * @{
  193. */
  194. #define DMA2D_NO_MODIF_ALPHA 0x00000000U /*!< No modification of the alpha channel value */
  195. #define DMA2D_REPLACE_ALPHA 0x00000001U /*!< Replace original alpha channel value by programmed alpha value */
  196. #define DMA2D_COMBINE_ALPHA 0x00000002U /*!< Replace original alpha channel value by programmed alpha value
  197. with original alpha channel value */
  198. /**
  199. * @}
  200. */
  201. /** @defgroup DMA2D_Alpha_Inverted DMA2D Alpha Inversion
  202. * @{
  203. */
  204. #define DMA2D_REGULAR_ALPHA 0x00000000U /*!< No modification of the alpha channel value */
  205. #define DMA2D_INVERTED_ALPHA 0x00000001U /*!< Invert the alpha channel value */
  206. /**
  207. * @}
  208. */
  209. /** @defgroup DMA2D_RB_Swap DMA2D Red and Blue Swap
  210. * @{
  211. */
  212. #define DMA2D_RB_REGULAR 0x00000000U /*!< Select regular mode (RGB or ARGB) */
  213. #define DMA2D_RB_SWAP 0x00000001U /*!< Select swap mode (BGR or ABGR) */
  214. /**
  215. * @}
  216. */
  217. /** @defgroup DMA2D_Chroma_Sub_Sampling DMA2D Chroma Sub Sampling
  218. * @{
  219. */
  220. #define DMA2D_NO_CSS 0x00000000U /*!< No chroma sub-sampling 4:4:4 */
  221. #define DMA2D_CSS_422 0x00000001U /*!< chroma sub-sampling 4:2:2 */
  222. #define DMA2D_CSS_420 0x00000002U /*!< chroma sub-sampling 4:2:0 */
  223. /**
  224. * @}
  225. */
  226. /** @defgroup DMA2D_CLUT_CM DMA2D CLUT Color Mode
  227. * @{
  228. */
  229. #define DMA2D_CCM_ARGB8888 0x00000000U /*!< ARGB8888 DMA2D CLUT color mode */
  230. #define DMA2D_CCM_RGB888 0x00000001U /*!< RGB888 DMA2D CLUT color mode */
  231. /**
  232. * @}
  233. */
  234. /** @defgroup DMA2D_Interrupts DMA2D Interrupts
  235. * @{
  236. */
  237. #define DMA2D_IT_CE DMA2D_CR_CEIE /*!< Configuration Error Interrupt */
  238. #define DMA2D_IT_CTC DMA2D_CR_CTCIE /*!< CLUT Transfer Complete Interrupt */
  239. #define DMA2D_IT_CAE DMA2D_CR_CAEIE /*!< CLUT Access Error Interrupt */
  240. #define DMA2D_IT_TW DMA2D_CR_TWIE /*!< Transfer Watermark Interrupt */
  241. #define DMA2D_IT_TC DMA2D_CR_TCIE /*!< Transfer Complete Interrupt */
  242. #define DMA2D_IT_TE DMA2D_CR_TEIE /*!< Transfer Error Interrupt */
  243. /**
  244. * @}
  245. */
  246. /** @defgroup DMA2D_Flags DMA2D Flags
  247. * @{
  248. */
  249. #define DMA2D_FLAG_CE DMA2D_ISR_CEIF /*!< Configuration Error Interrupt Flag */
  250. #define DMA2D_FLAG_CTC DMA2D_ISR_CTCIF /*!< CLUT Transfer Complete Interrupt Flag */
  251. #define DMA2D_FLAG_CAE DMA2D_ISR_CAEIF /*!< CLUT Access Error Interrupt Flag */
  252. #define DMA2D_FLAG_TW DMA2D_ISR_TWIF /*!< Transfer Watermark Interrupt Flag */
  253. #define DMA2D_FLAG_TC DMA2D_ISR_TCIF /*!< Transfer Complete Interrupt Flag */
  254. #define DMA2D_FLAG_TE DMA2D_ISR_TEIF /*!< Transfer Error Interrupt Flag */
  255. /**
  256. * @}
  257. */
  258. /** @defgroup DMA2D_Aliases DMA2D API Aliases
  259. * @{
  260. */
  261. #define HAL_DMA2D_DisableCLUT HAL_DMA2D_CLUTLoading_Abort /*!< Aliased to HAL_DMA2D_CLUTLoading_Abort for compatibility with legacy code */
  262. /**
  263. * @}
  264. */
  265. #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
  266. /**
  267. * @brief HAL DMA2D common Callback ID enumeration definition
  268. */
  269. typedef enum
  270. {
  271. HAL_DMA2D_MSPINIT_CB_ID = 0x00U, /*!< DMA2D MspInit callback ID */
  272. HAL_DMA2D_MSPDEINIT_CB_ID = 0x01U, /*!< DMA2D MspDeInit callback ID */
  273. HAL_DMA2D_TRANSFERCOMPLETE_CB_ID = 0x02U, /*!< DMA2D transfer complete callback ID */
  274. HAL_DMA2D_TRANSFERERROR_CB_ID = 0x03U, /*!< DMA2D transfer error callback ID */
  275. HAL_DMA2D_LINEEVENT_CB_ID = 0x04U, /*!< DMA2D line event callback ID */
  276. HAL_DMA2D_CLUTLOADINGCPLT_CB_ID = 0x05U, /*!< DMA2D CLUT loading completion callback ID */
  277. }HAL_DMA2D_CallbackIDTypeDef;
  278. #endif /* USE_HAL_DMA2D_REGISTER_CALLBACKS */
  279. /**
  280. * @}
  281. */
  282. /* Exported macros ------------------------------------------------------------*/
  283. /** @defgroup DMA2D_Exported_Macros DMA2D Exported Macros
  284. * @{
  285. */
  286. /** @brief Reset DMA2D handle state
  287. * @param __HANDLE__ specifies the DMA2D handle.
  288. * @retval None
  289. */
  290. #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
  291. #define __HAL_DMA2D_RESET_HANDLE_STATE(__HANDLE__) do{ \
  292. (__HANDLE__)->State = HAL_DMA2D_STATE_RESET;\
  293. (__HANDLE__)->MspInitCallback = NULL; \
  294. (__HANDLE__)->MspDeInitCallback = NULL; \
  295. }while(0)
  296. #else
  297. #define __HAL_DMA2D_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA2D_STATE_RESET)
  298. #endif /* USE_HAL_DMA2D_REGISTER_CALLBACKS */
  299. /**
  300. * @brief Enable the DMA2D.
  301. * @param __HANDLE__ DMA2D handle
  302. * @retval None.
  303. */
  304. #define __HAL_DMA2D_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DMA2D_CR_START)
  305. /* Interrupt & Flag management */
  306. /**
  307. * @brief Get the DMA2D pending flags.
  308. * @param __HANDLE__ DMA2D handle
  309. * @param __FLAG__ flag to check.
  310. * This parameter can be any combination of the following values:
  311. * @arg DMA2D_FLAG_CE: Configuration error flag
  312. * @arg DMA2D_FLAG_CTC: CLUT transfer complete flag
  313. * @arg DMA2D_FLAG_CAE: CLUT access error flag
  314. * @arg DMA2D_FLAG_TW: Transfer Watermark flag
  315. * @arg DMA2D_FLAG_TC: Transfer complete flag
  316. * @arg DMA2D_FLAG_TE: Transfer error flag
  317. * @retval The state of FLAG.
  318. */
  319. #define __HAL_DMA2D_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR & (__FLAG__))
  320. /**
  321. * @brief Clear the DMA2D pending flags.
  322. * @param __HANDLE__ DMA2D handle
  323. * @param __FLAG__ specifies the flag to clear.
  324. * This parameter can be any combination of the following values:
  325. * @arg DMA2D_FLAG_CE: Configuration error flag
  326. * @arg DMA2D_FLAG_CTC: CLUT transfer complete flag
  327. * @arg DMA2D_FLAG_CAE: CLUT access error flag
  328. * @arg DMA2D_FLAG_TW: Transfer Watermark flag
  329. * @arg DMA2D_FLAG_TC: Transfer complete flag
  330. * @arg DMA2D_FLAG_TE: Transfer error flag
  331. * @retval None
  332. */
  333. #define __HAL_DMA2D_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->IFCR = (__FLAG__))
  334. /**
  335. * @brief Enable the specified DMA2D interrupts.
  336. * @param __HANDLE__ DMA2D handle
  337. * @param __INTERRUPT__ specifies the DMA2D interrupt sources to be enabled.
  338. * This parameter can be any combination of the following values:
  339. * @arg DMA2D_IT_CE: Configuration error interrupt mask
  340. * @arg DMA2D_IT_CTC: CLUT transfer complete interrupt mask
  341. * @arg DMA2D_IT_CAE: CLUT access error interrupt mask
  342. * @arg DMA2D_IT_TW: Transfer Watermark interrupt mask
  343. * @arg DMA2D_IT_TC: Transfer complete interrupt mask
  344. * @arg DMA2D_IT_TE: Transfer error interrupt mask
  345. * @retval None
  346. */
  347. #define __HAL_DMA2D_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  348. /**
  349. * @brief Disable the specified DMA2D interrupts.
  350. * @param __HANDLE__ DMA2D handle
  351. * @param __INTERRUPT__ specifies the DMA2D interrupt sources to be disabled.
  352. * This parameter can be any combination of the following values:
  353. * @arg DMA2D_IT_CE: Configuration error interrupt mask
  354. * @arg DMA2D_IT_CTC: CLUT transfer complete interrupt mask
  355. * @arg DMA2D_IT_CAE: CLUT access error interrupt mask
  356. * @arg DMA2D_IT_TW: Transfer Watermark interrupt mask
  357. * @arg DMA2D_IT_TC: Transfer complete interrupt mask
  358. * @arg DMA2D_IT_TE: Transfer error interrupt mask
  359. * @retval None
  360. */
  361. #define __HAL_DMA2D_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  362. /**
  363. * @brief Check whether the specified DMA2D interrupt source is enabled or not.
  364. * @param __HANDLE__ DMA2D handle
  365. * @param __INTERRUPT__ specifies the DMA2D interrupt source to check.
  366. * This parameter can be one of the following values:
  367. * @arg DMA2D_IT_CE: Configuration error interrupt mask
  368. * @arg DMA2D_IT_CTC: CLUT transfer complete interrupt mask
  369. * @arg DMA2D_IT_CAE: CLUT access error interrupt mask
  370. * @arg DMA2D_IT_TW: Transfer Watermark interrupt mask
  371. * @arg DMA2D_IT_TC: Transfer complete interrupt mask
  372. * @arg DMA2D_IT_TE: Transfer error interrupt mask
  373. * @retval The state of INTERRUPT source.
  374. */
  375. #define __HAL_DMA2D_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR & (__INTERRUPT__))
  376. /**
  377. * @}
  378. */
  379. /* Exported functions --------------------------------------------------------*/
  380. /** @addtogroup DMA2D_Exported_Functions DMA2D Exported Functions
  381. * @{
  382. */
  383. /** @addtogroup DMA2D_Exported_Functions_Group1 Initialization and de-initialization functions
  384. * @{
  385. */
  386. /* Initialization and de-initialization functions *******************************/
  387. HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d);
  388. HAL_StatusTypeDef HAL_DMA2D_DeInit (DMA2D_HandleTypeDef *hdma2d);
  389. void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d);
  390. void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d);
  391. /* Callbacks Register/UnRegister functions ***********************************/
  392. #if (USE_HAL_DMA2D_REGISTER_CALLBACKS == 1)
  393. HAL_StatusTypeDef HAL_DMA2D_RegisterCallback(DMA2D_HandleTypeDef *hdma2d, HAL_DMA2D_CallbackIDTypeDef CallbackID, pDMA2D_CallbackTypeDef pCallback);
  394. HAL_StatusTypeDef HAL_DMA2D_UnRegisterCallback(DMA2D_HandleTypeDef *hdma2d, HAL_DMA2D_CallbackIDTypeDef CallbackID);
  395. #endif /* USE_HAL_DMA2D_REGISTER_CALLBACKS */
  396. /**
  397. * @}
  398. */
  399. /** @addtogroup DMA2D_Exported_Functions_Group2 IO operation functions
  400. * @{
  401. */
  402. /* IO operation functions *******************************************************/
  403. HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height);
  404. HAL_StatusTypeDef HAL_DMA2D_BlendingStart(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height);
  405. HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height);
  406. HAL_StatusTypeDef HAL_DMA2D_BlendingStart_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height);
  407. HAL_StatusTypeDef HAL_DMA2D_Suspend(DMA2D_HandleTypeDef *hdma2d);
  408. HAL_StatusTypeDef HAL_DMA2D_Resume(DMA2D_HandleTypeDef *hdma2d);
  409. HAL_StatusTypeDef HAL_DMA2D_Abort(DMA2D_HandleTypeDef *hdma2d);
  410. HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  411. HAL_StatusTypeDef HAL_DMA2D_CLUTLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx);
  412. HAL_StatusTypeDef HAL_DMA2D_CLUTLoad_IT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx);
  413. HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Abort(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  414. HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Suspend(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  415. HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Resume(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  416. HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout);
  417. void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d);
  418. void HAL_DMA2D_LineEventCallback(DMA2D_HandleTypeDef *hdma2d);
  419. void HAL_DMA2D_CLUTLoadingCpltCallback(DMA2D_HandleTypeDef *hdma2d);
  420. /**
  421. * @}
  422. */
  423. /** @addtogroup DMA2D_Exported_Functions_Group3 Peripheral Control functions
  424. * @{
  425. */
  426. /* Peripheral Control functions *************************************************/
  427. HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  428. HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx);
  429. HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line);
  430. HAL_StatusTypeDef HAL_DMA2D_EnableDeadTime(DMA2D_HandleTypeDef *hdma2d);
  431. HAL_StatusTypeDef HAL_DMA2D_DisableDeadTime(DMA2D_HandleTypeDef *hdma2d);
  432. HAL_StatusTypeDef HAL_DMA2D_ConfigDeadTime(DMA2D_HandleTypeDef *hdma2d, uint8_t DeadTime);
  433. /**
  434. * @}
  435. */
  436. /** @addtogroup DMA2D_Exported_Functions_Group4 Peripheral State and Error functions
  437. * @{
  438. */
  439. /* Peripheral State functions ***************************************************/
  440. HAL_DMA2D_StateTypeDef HAL_DMA2D_GetState(DMA2D_HandleTypeDef *hdma2d);
  441. uint32_t HAL_DMA2D_GetError(DMA2D_HandleTypeDef *hdma2d);
  442. /**
  443. * @}
  444. */
  445. /**
  446. * @}
  447. */
  448. /* Private constants ---------------------------------------------------------*/
  449. /** @addtogroup DMA2D_Private_Constants DMA2D Private Constants
  450. * @{
  451. */
  452. /** @defgroup DMA2D_Maximum_Line_WaterMark DMA2D Maximum Line Watermark
  453. * @{
  454. */
  455. #define DMA2D_LINE_WATERMARK_MAX DMA2D_LWR_LW /*!< DMA2D maximum line watermark */
  456. /**
  457. * @}
  458. */
  459. /** @defgroup DMA2D_Color_Value DMA2D Color Value
  460. * @{
  461. */
  462. #define DMA2D_COLOR_VALUE 0x000000FFU /*!< Color value mask */
  463. /**
  464. * @}
  465. */
  466. /** @defgroup DMA2D_Max_Layer DMA2D Maximum Number of Layers
  467. * @{
  468. */
  469. #define DMA2D_MAX_LAYER 2U /*!< DMA2D maximum number of layers */
  470. /**
  471. * @}
  472. */
  473. /** @defgroup DMA2D_Layers DMA2D Layers
  474. * @{
  475. */
  476. #define DMA2D_BACKGROUND_LAYER 0x00000000U /*!< DMA2D Background Layer (layer 0) */
  477. #define DMA2D_FOREGROUND_LAYER 0x00000001U /*!< DMA2D Foreground Layer (layer 1) */
  478. /**
  479. * @}
  480. */
  481. /** @defgroup DMA2D_Offset DMA2D Offset
  482. * @{
  483. */
  484. #define DMA2D_OFFSET DMA2D_FGOR_LO /*!< maximum Line Offset */
  485. /**
  486. * @}
  487. */
  488. /** @defgroup DMA2D_Size DMA2D Size
  489. * @{
  490. */
  491. #define DMA2D_PIXEL (DMA2D_NLR_PL >> 16U) /*!< DMA2D maximum number of pixels per line */
  492. #define DMA2D_LINE DMA2D_NLR_NL /*!< DMA2D maximum number of lines */
  493. /**
  494. * @}
  495. */
  496. /** @defgroup DMA2D_CLUT_Size DMA2D CLUT Size
  497. * @{
  498. */
  499. #define DMA2D_CLUT_SIZE (DMA2D_FGPFCCR_CS >> 8U) /*!< DMA2D maximum CLUT size */
  500. /**
  501. * @}
  502. */
  503. /**
  504. * @}
  505. */
  506. /* Private macros ------------------------------------------------------------*/
  507. /** @defgroup DMA2D_Private_Macros DMA2D Private Macros
  508. * @{
  509. */
  510. #define IS_DMA2D_LAYER(LAYER) (((LAYER) == DMA2D_BACKGROUND_LAYER) || ((LAYER) == DMA2D_FOREGROUND_LAYER))
  511. #define IS_DMA2D_MODE(MODE) (((MODE) == DMA2D_M2M) || ((MODE) == DMA2D_M2M_PFC) || \
  512. ((MODE) == DMA2D_M2M_BLEND) || ((MODE) == DMA2D_R2M))
  513. #define IS_DMA2D_CMODE(MODE_ARGB) (((MODE_ARGB) == DMA2D_OUTPUT_ARGB8888) || ((MODE_ARGB) == DMA2D_OUTPUT_RGB888) || \
  514. ((MODE_ARGB) == DMA2D_OUTPUT_RGB565) || ((MODE_ARGB) == DMA2D_OUTPUT_ARGB1555) || \
  515. ((MODE_ARGB) == DMA2D_OUTPUT_ARGB4444))
  516. #define IS_DMA2D_COLOR(COLOR) ((COLOR) <= DMA2D_COLOR_VALUE)
  517. #define IS_DMA2D_LINE(LINE) ((LINE) <= DMA2D_LINE)
  518. #define IS_DMA2D_PIXEL(PIXEL) ((PIXEL) <= DMA2D_PIXEL)
  519. #define IS_DMA2D_OFFSET(OOFFSET) ((OOFFSET) <= DMA2D_OFFSET)
  520. #define IS_DMA2D_INPUT_COLOR_MODE(INPUT_CM) (((INPUT_CM) == DMA2D_INPUT_ARGB8888) || ((INPUT_CM) == DMA2D_INPUT_RGB888) || \
  521. ((INPUT_CM) == DMA2D_INPUT_RGB565) || ((INPUT_CM) == DMA2D_INPUT_ARGB1555) || \
  522. ((INPUT_CM) == DMA2D_INPUT_ARGB4444) || ((INPUT_CM) == DMA2D_INPUT_L8) || \
  523. ((INPUT_CM) == DMA2D_INPUT_AL44) || ((INPUT_CM) == DMA2D_INPUT_AL88) || \
  524. ((INPUT_CM) == DMA2D_INPUT_L4) || ((INPUT_CM) == DMA2D_INPUT_A8) || \
  525. ((INPUT_CM) == DMA2D_INPUT_A4) || ((INPUT_CM) == DMA2D_INPUT_YCBCR))
  526. #define IS_DMA2D_ALPHA_MODE(AlphaMode) (((AlphaMode) == DMA2D_NO_MODIF_ALPHA) || \
  527. ((AlphaMode) == DMA2D_REPLACE_ALPHA) || \
  528. ((AlphaMode) == DMA2D_COMBINE_ALPHA))
  529. #define IS_DMA2D_ALPHA_INVERTED(Alpha_Inverted) (((Alpha_Inverted) == DMA2D_REGULAR_ALPHA) || \
  530. ((Alpha_Inverted) == DMA2D_INVERTED_ALPHA))
  531. #define IS_DMA2D_RB_SWAP(RB_Swap) (((RB_Swap) == DMA2D_RB_REGULAR) || \
  532. ((RB_Swap) == DMA2D_RB_SWAP))
  533. #define IS_DMA2D_CHROMA_SUB_SAMPLING(CSS) (((CSS) == DMA2D_NO_CSS) || \
  534. ((CSS) == DMA2D_CSS_422) || \
  535. ((CSS) == DMA2D_CSS_420))
  536. #define IS_DMA2D_CLUT_CM(CLUT_CM) (((CLUT_CM) == DMA2D_CCM_ARGB8888) || ((CLUT_CM) == DMA2D_CCM_RGB888))
  537. #define IS_DMA2D_CLUT_SIZE(CLUT_SIZE) ((CLUT_SIZE) <= DMA2D_CLUT_SIZE)
  538. #define IS_DMA2D_LINEWATERMARK(LineWatermark) ((LineWatermark) <= DMA2D_LINE_WATERMARK_MAX)
  539. #define IS_DMA2D_IT(IT) (((IT) == DMA2D_IT_CTC) || ((IT) == DMA2D_IT_CAE) || \
  540. ((IT) == DMA2D_IT_TW) || ((IT) == DMA2D_IT_TC) || \
  541. ((IT) == DMA2D_IT_TE) || ((IT) == DMA2D_IT_CE))
  542. #define IS_DMA2D_GET_FLAG(FLAG) (((FLAG) == DMA2D_FLAG_CTC) || ((FLAG) == DMA2D_FLAG_CAE) || \
  543. ((FLAG) == DMA2D_FLAG_TW) || ((FLAG) == DMA2D_FLAG_TC) || \
  544. ((FLAG) == DMA2D_FLAG_TE) || ((FLAG) == DMA2D_FLAG_CE))
  545. /**
  546. * @}
  547. */
  548. /**
  549. * @}
  550. */
  551. /**
  552. * @}
  553. */
  554. #ifdef __cplusplus
  555. }
  556. #endif
  557. #endif /* STM32H7xx_HAL_DMA2D_H */
  558. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/