stm32l4xx_hal_dma2d.h 32 KB

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