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.
 
 
 

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