stm32l4xx_hal_dma2d.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  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. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L4xx_HAL_DMA2D_H
  37. #define __STM32L4xx_HAL_DMA2D_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. #if defined(STM32L496xx) || defined(STM32L4A6xx) || \
  42. defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l4xx_hal_def.h"
  45. /** @addtogroup STM32L4xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup DMA2D DMA2D
  49. * @brief DMA2D HAL module driver
  50. * @{
  51. */
  52. /* Exported types ------------------------------------------------------------*/
  53. /** @defgroup DMA2D_Exported_Types DMA2D Exported Types
  54. * @{
  55. */
  56. #define MAX_DMA2D_LAYER 2U
  57. /**
  58. * @brief DMA2D color Structure definition
  59. */
  60. typedef struct
  61. {
  62. uint32_t Blue; /*!< Configures the blue value.
  63. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */
  64. uint32_t Green; /*!< Configures the green value.
  65. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */
  66. uint32_t Red; /*!< Configures the red value.
  67. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF. */
  68. } DMA2D_ColorTypeDef;
  69. /**
  70. * @brief DMA2D CLUT Structure definition
  71. */
  72. typedef struct
  73. {
  74. uint32_t *pCLUT; /*!< Configures the DMA2D CLUT memory address.*/
  75. uint32_t CLUTColorMode; /*!< Configures the DMA2D CLUT color mode.
  76. This parameter can be one value of @ref DMA2D_CLUT_CM. */
  77. uint32_t Size; /*!< Configures the DMA2D CLUT size.
  78. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF.*/
  79. } DMA2D_CLUTCfgTypeDef;
  80. /**
  81. * @brief DMA2D Init structure definition
  82. */
  83. typedef struct
  84. {
  85. uint32_t Mode; /*!< Configures the DMA2D transfer mode.
  86. This parameter can be one value of @ref DMA2D_Mode. */
  87. uint32_t ColorMode; /*!< Configures the color format of the output image.
  88. This parameter can be one value of @ref DMA2D_Output_Color_Mode. */
  89. uint32_t OutputOffset; /*!< Specifies the Offset value.
  90. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF. */
  91. uint32_t AlphaInverted; /*!< Select regular or inverted alpha value for the output pixel format converter.
  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. for the output pixel format converter.
  95. This parameter can be one value of @ref DMA2D_RB_Swap. */
  96. #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  97. uint32_t BytesSwap; /*!< Select byte regular mode or bytes swap mode (two by two).
  98. This parameter can be one value of @ref DMA2D_Bytes_Swap. */
  99. uint32_t LineOffsetMode; /*!< Configures how is expressed the line offset for the foreground, background and output.
  100. This parameter can be one value of @ref DMA2D_Line_Offset_Mode. */
  101. #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  102. } DMA2D_InitTypeDef;
  103. /**
  104. * @brief DMA2D Layer structure definition
  105. */
  106. typedef struct
  107. {
  108. uint32_t InputOffset; /*!< Configures the DMA2D foreground or background offset.
  109. This parameter must be a number between Min_Data = 0x0000 and Max_Data = 0x3FFF. */
  110. uint32_t InputColorMode; /*!< Configures the DMA2D foreground or background color mode.
  111. This parameter can be one value of @ref DMA2D_Input_Color_Mode. */
  112. uint32_t AlphaMode; /*!< Configures the DMA2D foreground or background alpha mode.
  113. This parameter can be one value of @ref DMA2D_Alpha_Mode. */
  114. uint32_t InputAlpha; /*!< Specifies the DMA2D foreground or background alpha value and color value in case of A8 or A4 color mode.
  115. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0xFF except for the color modes detailed below.
  116. @note In case of A8 or A4 color mode (ARGB), this parameter must be a number between
  117. Min_Data = 0x00000000 and Max_Data = 0xFFFFFFFF where
  118. - InputAlpha[24:31] is the alpha value ALPHA[0:7]
  119. - InputAlpha[16:23] is the red value RED[0:7]
  120. - InputAlpha[8:15] is the green value GREEN[0:7]
  121. - InputAlpha[0:7] is the blue value BLUE[0:7]. */
  122. uint32_t AlphaInverted; /*!< Select regular or inverted alpha value.
  123. This parameter can be one value of @ref DMA2D_Alpha_Inverted. */
  124. uint32_t RedBlueSwap; /*!< Select regular mode (RGB or ARGB) or swap mode (BGR or ABGR).
  125. This parameter can be one value of @ref DMA2D_RB_Swap. */
  126. } DMA2D_LayerCfgTypeDef;
  127. /**
  128. * @brief HAL DMA2D State structures definition
  129. */
  130. typedef enum
  131. {
  132. HAL_DMA2D_STATE_RESET = 0x00U, /*!< DMA2D not yet initialized or disabled */
  133. HAL_DMA2D_STATE_READY = 0x01U, /*!< Peripheral Initialized and ready for use */
  134. HAL_DMA2D_STATE_BUSY = 0x02U, /*!< An internal process is ongoing */
  135. HAL_DMA2D_STATE_TIMEOUT = 0x03U, /*!< Timeout state */
  136. HAL_DMA2D_STATE_ERROR = 0x04U, /*!< DMA2D state error */
  137. HAL_DMA2D_STATE_SUSPEND = 0x05U /*!< DMA2D process is suspended */
  138. }HAL_DMA2D_StateTypeDef;
  139. /**
  140. * @brief DMA2D handle Structure definition
  141. */
  142. typedef struct __DMA2D_HandleTypeDef
  143. {
  144. DMA2D_TypeDef *Instance; /*!< DMA2D register base address. */
  145. DMA2D_InitTypeDef Init; /*!< DMA2D communication parameters. */
  146. void (* XferCpltCallback)(struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D transfer complete callback. */
  147. void (* XferErrorCallback)(struct __DMA2D_HandleTypeDef * hdma2d); /*!< DMA2D transfer error callback. */
  148. DMA2D_LayerCfgTypeDef LayerCfg[MAX_DMA2D_LAYER]; /*!< DMA2D Layers parameters */
  149. HAL_LockTypeDef Lock; /*!< DMA2D lock. */
  150. __IO HAL_DMA2D_StateTypeDef State; /*!< DMA2D transfer state. */
  151. __IO uint32_t ErrorCode; /*!< DMA2D error code. */
  152. } DMA2D_HandleTypeDef;
  153. /**
  154. * @}
  155. */
  156. /* Exported constants --------------------------------------------------------*/
  157. /** @defgroup DMA2D_Exported_Constants DMA2D Exported Constants
  158. * @{
  159. */
  160. /** @defgroup DMA2D_Error_Code DMA2D Error Code
  161. * @{
  162. */
  163. #define HAL_DMA2D_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
  164. #define HAL_DMA2D_ERROR_TE ((uint32_t)0x00000001U) /*!< Transfer error */
  165. #define HAL_DMA2D_ERROR_CE ((uint32_t)0x00000002U) /*!< Configuration error */
  166. #define HAL_DMA2D_ERROR_CAE ((uint32_t)0x00000004U) /*!< CLUT access error */
  167. #define HAL_DMA2D_ERROR_TIMEOUT ((uint32_t)0x00000020U) /*!< Timeout error */
  168. /**
  169. * @}
  170. */
  171. /** @defgroup DMA2D_Mode DMA2D Mode
  172. * @{
  173. */
  174. #define DMA2D_M2M ((uint32_t)0x00000000U) /*!< DMA2D memory to memory transfer mode */
  175. #define DMA2D_M2M_PFC DMA2D_CR_MODE_0 /*!< DMA2D memory to memory with pixel format conversion transfer mode */
  176. #define DMA2D_M2M_BLEND DMA2D_CR_MODE_1 /*!< DMA2D memory to memory with blending transfer mode */
  177. #define DMA2D_R2M (DMA2D_CR_MODE_1 | DMA2D_CR_MODE_0) /*!< DMA2D register to memory transfer mode */
  178. #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  179. #define DMA2D_M2M_BLEND_FG DMA2D_CR_MODE_2 /*!< DMA2D memory to memory with blending transfer mode and fixed color FG */
  180. #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 */
  181. #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  182. /**
  183. * @}
  184. */
  185. /** @defgroup DMA2D_Output_Color_Mode DMA2D Output Color Mode
  186. * @{
  187. */
  188. #define DMA2D_OUTPUT_ARGB8888 ((uint32_t)0x00000000U) /*!< ARGB8888 DMA2D color mode */
  189. #define DMA2D_OUTPUT_RGB888 DMA2D_OPFCCR_CM_0 /*!< RGB888 DMA2D color mode */
  190. #define DMA2D_OUTPUT_RGB565 DMA2D_OPFCCR_CM_1 /*!< RGB565 DMA2D color mode */
  191. #define DMA2D_OUTPUT_ARGB1555 (DMA2D_OPFCCR_CM_0|DMA2D_OPFCCR_CM_1) /*!< ARGB1555 DMA2D color mode */
  192. #define DMA2D_OUTPUT_ARGB4444 DMA2D_OPFCCR_CM_2 /*!< ARGB4444 DMA2D color mode */
  193. /**
  194. * @}
  195. */
  196. /** @defgroup DMA2D_Input_Color_Mode DMA2D Input Color Mode
  197. * @{
  198. */
  199. #define DMA2D_INPUT_ARGB8888 ((uint32_t)0x00000000U) /*!< ARGB8888 color mode */
  200. #define DMA2D_INPUT_RGB888 ((uint32_t)0x00000001U) /*!< RGB888 color mode */
  201. #define DMA2D_INPUT_RGB565 ((uint32_t)0x00000002U) /*!< RGB565 color mode */
  202. #define DMA2D_INPUT_ARGB1555 ((uint32_t)0x00000003U) /*!< ARGB1555 color mode */
  203. #define DMA2D_INPUT_ARGB4444 ((uint32_t)0x00000004U) /*!< ARGB4444 color mode */
  204. #define DMA2D_INPUT_L8 ((uint32_t)0x00000005U) /*!< L8 color mode */
  205. #define DMA2D_INPUT_AL44 ((uint32_t)0x00000006U) /*!< AL44 color mode */
  206. #define DMA2D_INPUT_AL88 ((uint32_t)0x00000007U) /*!< AL88 color mode */
  207. #define DMA2D_INPUT_L4 ((uint32_t)0x00000008U) /*!< L4 color mode */
  208. #define DMA2D_INPUT_A8 ((uint32_t)0x00000009U) /*!< A8 color mode */
  209. #define DMA2D_INPUT_A4 ((uint32_t)0x0000000AU) /*!< A4 color mode */
  210. /**
  211. * @}
  212. */
  213. /** @defgroup DMA2D_Alpha_Mode DMA2D Alpha Mode
  214. * @{
  215. */
  216. #define DMA2D_NO_MODIF_ALPHA ((uint32_t)0x00000000U) /*!< No modification of the alpha channel value */
  217. #define DMA2D_REPLACE_ALPHA ((uint32_t)0x00000001U) /*!< Replace original alpha channel value by programmed alpha value */
  218. #define DMA2D_COMBINE_ALPHA ((uint32_t)0x00000002U) /*!< Replace original alpha channel value by programmed alpha value
  219. with original alpha channel value */
  220. /**
  221. * @}
  222. */
  223. /** @defgroup DMA2D_Alpha_Inverted DMA2D Alpha Inversion
  224. * @{
  225. */
  226. #define DMA2D_REGULAR_ALPHA ((uint32_t)0x00000000U) /*!< No modification of the alpha channel value */
  227. #define DMA2D_INVERTED_ALPHA ((uint32_t)0x00000001U) /*!< Invert the alpha channel value */
  228. /**
  229. * @}
  230. */
  231. /** @defgroup DMA2D_RB_Swap DMA2D Red and Blue Swap
  232. * @{
  233. */
  234. #define DMA2D_RB_REGULAR ((uint32_t)0x00000000U) /*!< Select regular mode (RGB or ARGB) */
  235. #define DMA2D_RB_SWAP ((uint32_t)0x00000001U) /*!< Select swap mode (BGR or ABGR) */
  236. /**
  237. * @}
  238. */
  239. #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  240. /** @defgroup DMA2D_Line_Offset_Mode DMA2D Line Offset Mode
  241. * @{
  242. */
  243. #define DMA2D_LOM_PIXELS ((uint32_t)0x00000000U) /*!< Line offsets expressed in pixels */
  244. #define DMA2D_LOM_BYTES DMA2D_CR_LOM /*!< Line offsets expressed in bytes */
  245. /**
  246. * @}
  247. */
  248. /** @defgroup DMA2D_Bytes_Swap DMA2D Bytes Swap
  249. * @{
  250. */
  251. #define DMA2D_BYTES_REGULAR ((uint32_t)0x00000000U) /*!< Bytes in regular order in output FIFO */
  252. #define DMA2D_BYTES_SWAP DMA2D_OPFCCR_SB /*!< Bytes are swapped two by two in output FIFO */
  253. /**
  254. * @}
  255. */
  256. #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  257. /** @defgroup DMA2D_CLUT_CM DMA2D CLUT Color Mode
  258. * @{
  259. */
  260. #define DMA2D_CCM_ARGB8888 ((uint32_t)0x00000000U) /*!< ARGB8888 DMA2D CLUT color mode */
  261. #define DMA2D_CCM_RGB888 ((uint32_t)0x00000001U) /*!< RGB888 DMA2D CLUT color mode */
  262. /**
  263. * @}
  264. */
  265. /** @defgroup DMA2D_Interrupts DMA2D Interrupts
  266. * @{
  267. */
  268. #define DMA2D_IT_CE DMA2D_CR_CEIE /*!< Configuration Error Interrupt */
  269. #define DMA2D_IT_CTC DMA2D_CR_CTCIE /*!< CLUT Transfer Complete Interrupt */
  270. #define DMA2D_IT_CAE DMA2D_CR_CAEIE /*!< CLUT Access Error Interrupt */
  271. #define DMA2D_IT_TW DMA2D_CR_TWIE /*!< Transfer Watermark Interrupt */
  272. #define DMA2D_IT_TC DMA2D_CR_TCIE /*!< Transfer Complete Interrupt */
  273. #define DMA2D_IT_TE DMA2D_CR_TEIE /*!< Transfer Error Interrupt */
  274. /**
  275. * @}
  276. */
  277. /** @defgroup DMA2D_Flags DMA2D Flags
  278. * @{
  279. */
  280. #define DMA2D_FLAG_CE DMA2D_ISR_CEIF /*!< Configuration Error Interrupt Flag */
  281. #define DMA2D_FLAG_CTC DMA2D_ISR_CTCIF /*!< CLUT Transfer Complete Interrupt Flag */
  282. #define DMA2D_FLAG_CAE DMA2D_ISR_CAEIF /*!< CLUT Access Error Interrupt Flag */
  283. #define DMA2D_FLAG_TW DMA2D_ISR_TWIF /*!< Transfer Watermark Interrupt Flag */
  284. #define DMA2D_FLAG_TC DMA2D_ISR_TCIF /*!< Transfer Complete Interrupt Flag */
  285. #define DMA2D_FLAG_TE DMA2D_ISR_TEIF /*!< Transfer Error Interrupt Flag */
  286. /**
  287. * @}
  288. */
  289. /** @defgroup DMA2D_Aliases DMA2D API Aliases
  290. * @{
  291. */
  292. #define HAL_DMA2D_DisableCLUT HAL_DMA2D_CLUTLoading_Abort /*!< Aliased to HAL_DMA2D_CLUTLoading_Abort for compatibility with legacy code */
  293. /**
  294. * @}
  295. */
  296. /**
  297. * @}
  298. */
  299. /* Exported macros ------------------------------------------------------------*/
  300. /** @defgroup DMA2D_Exported_Macros DMA2D Exported Macros
  301. * @{
  302. */
  303. /** @brief Reset DMA2D handle state
  304. * @param __HANDLE__: specifies the DMA2D handle.
  305. * @retval None
  306. */
  307. #define __HAL_DMA2D_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DMA2D_STATE_RESET)
  308. /**
  309. * @brief Enable the DMA2D.
  310. * @param __HANDLE__: DMA2D handle
  311. * @retval None.
  312. */
  313. #define __HAL_DMA2D_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DMA2D_CR_START)
  314. /* Interrupt & Flag management */
  315. /**
  316. * @brief Get the DMA2D pending flags.
  317. * @param __HANDLE__: DMA2D handle
  318. * @param __FLAG__: flag to check.
  319. * This parameter can be any combination of the following values:
  320. * @arg DMA2D_FLAG_CE: Configuration error flag
  321. * @arg DMA2D_FLAG_CTC: CLUT transfer complete flag
  322. * @arg DMA2D_FLAG_CAE: CLUT access error flag
  323. * @arg DMA2D_FLAG_TW: Transfer Watermark flag
  324. * @arg DMA2D_FLAG_TC: Transfer complete flag
  325. * @arg DMA2D_FLAG_TE: Transfer error flag
  326. * @retval The state of FLAG.
  327. */
  328. #define __HAL_DMA2D_GET_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ISR & (__FLAG__))
  329. /**
  330. * @brief Clear the DMA2D pending flags.
  331. * @param __HANDLE__: DMA2D handle
  332. * @param __FLAG__: specifies the flag to clear.
  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 None
  341. */
  342. #define __HAL_DMA2D_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->IFCR = (__FLAG__))
  343. /**
  344. * @brief Enable the specified DMA2D interrupts.
  345. * @param __HANDLE__: DMA2D handle
  346. * @param __INTERRUPT__: specifies the DMA2D interrupt sources to be enabled.
  347. * This parameter can be any combination of the following values:
  348. * @arg DMA2D_IT_CE: Configuration error interrupt mask
  349. * @arg DMA2D_IT_CTC: CLUT transfer complete interrupt mask
  350. * @arg DMA2D_IT_CAE: CLUT access error interrupt mask
  351. * @arg DMA2D_IT_TW: Transfer Watermark interrupt mask
  352. * @arg DMA2D_IT_TC: Transfer complete interrupt mask
  353. * @arg DMA2D_IT_TE: Transfer error interrupt mask
  354. * @retval None
  355. */
  356. #define __HAL_DMA2D_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
  357. /**
  358. * @brief Disable the specified DMA2D interrupts.
  359. * @param __HANDLE__: DMA2D handle
  360. * @param __INTERRUPT__: specifies the DMA2D interrupt sources to be disabled.
  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_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR &= ~(__INTERRUPT__))
  371. /**
  372. * @brief Check whether the specified DMA2D interrupt source is enabled or not.
  373. * @param __HANDLE__: DMA2D handle
  374. * @param __INTERRUPT__: specifies the DMA2D interrupt source to check.
  375. * This parameter can be one 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 The state of INTERRUPT source.
  383. */
  384. #define __HAL_DMA2D_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR & (__INTERRUPT__))
  385. /**
  386. * @}
  387. */
  388. /* Exported functions --------------------------------------------------------*/
  389. /** @addtogroup DMA2D_Exported_Functions DMA2D Exported Functions
  390. * @{
  391. */
  392. /** @addtogroup DMA2D_Exported_Functions_Group1 Initialization and de-initialization functions
  393. * @{
  394. */
  395. /* Initialization and de-initialization functions *******************************/
  396. HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d);
  397. HAL_StatusTypeDef HAL_DMA2D_DeInit (DMA2D_HandleTypeDef *hdma2d);
  398. void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d);
  399. void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d);
  400. /**
  401. * @}
  402. */
  403. /** @addtogroup DMA2D_Exported_Functions_Group2 IO operation functions
  404. * @{
  405. */
  406. /* IO operation functions *******************************************************/
  407. HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height);
  408. HAL_StatusTypeDef HAL_DMA2D_BlendingStart(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height);
  409. HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height);
  410. HAL_StatusTypeDef HAL_DMA2D_BlendingStart_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height);
  411. HAL_StatusTypeDef HAL_DMA2D_Suspend(DMA2D_HandleTypeDef *hdma2d);
  412. HAL_StatusTypeDef HAL_DMA2D_Resume(DMA2D_HandleTypeDef *hdma2d);
  413. HAL_StatusTypeDef HAL_DMA2D_Abort(DMA2D_HandleTypeDef *hdma2d);
  414. HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  415. HAL_StatusTypeDef HAL_DMA2D_CLUTLoad(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx);
  416. HAL_StatusTypeDef HAL_DMA2D_CLUTLoad_IT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx);
  417. HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Abort(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  418. HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Suspend(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  419. HAL_StatusTypeDef HAL_DMA2D_CLUTLoading_Resume(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  420. HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout);
  421. void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d);
  422. void HAL_DMA2D_LineEventCallback(DMA2D_HandleTypeDef *hdma2d);
  423. void HAL_DMA2D_CLUTLoadingCpltCallback(DMA2D_HandleTypeDef *hdma2d);
  424. /**
  425. * @}
  426. */
  427. /** @addtogroup DMA2D_Exported_Functions_Group3 Peripheral Control functions
  428. * @{
  429. */
  430. /* Peripheral Control functions *************************************************/
  431. HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx);
  432. HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx);
  433. HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line);
  434. HAL_StatusTypeDef HAL_DMA2D_EnableDeadTime(DMA2D_HandleTypeDef *hdma2d);
  435. HAL_StatusTypeDef HAL_DMA2D_DisableDeadTime(DMA2D_HandleTypeDef *hdma2d);
  436. HAL_StatusTypeDef HAL_DMA2D_ConfigDeadTime(DMA2D_HandleTypeDef *hdma2d, uint8_t DeadTime);
  437. /**
  438. * @}
  439. */
  440. /** @addtogroup DMA2D_Exported_Functions_Group4 Peripheral State and Error functions
  441. * @{
  442. */
  443. /* Peripheral State functions ***************************************************/
  444. HAL_DMA2D_StateTypeDef HAL_DMA2D_GetState(DMA2D_HandleTypeDef *hdma2d);
  445. uint32_t HAL_DMA2D_GetError(DMA2D_HandleTypeDef *hdma2d);
  446. /**
  447. * @}
  448. */
  449. /**
  450. * @}
  451. */
  452. /* Private constants ---------------------------------------------------------*/
  453. /** @addtogroup DMA2D_Private_Constants DMA2D Private Constants
  454. * @{
  455. */
  456. /** @defgroup DMA2D_Maximum_Line_WaterMark DMA2D Maximum Line Watermark
  457. * @{
  458. */
  459. #define DMA2D_LINE_WATERMARK_MAX DMA2D_LWR_LW /*!< DMA2D maximum line watermark */
  460. /**
  461. * @}
  462. */
  463. /** @defgroup DMA2D_Color_Value DMA2D Color Value
  464. * @{
  465. */
  466. #define DMA2D_COLOR_VALUE ((uint32_t)0x000000FFU) /*!< Color value mask */
  467. /**
  468. * @}
  469. */
  470. /** @defgroup DMA2D_Max_Layer DMA2D Maximum Number of Layers
  471. * @{
  472. */
  473. #define DMA2D_MAX_LAYER 2 /*!< DMA2D maximum number of layers */
  474. /**
  475. * @}
  476. */
  477. /** @defgroup DMA2D_Offset DMA2D Offset
  478. * @{
  479. */
  480. #define DMA2D_OFFSET DMA2D_FGOR_LO /*!< Line Offset */
  481. /**
  482. * @}
  483. */
  484. /** @defgroup DMA2D_Size DMA2D Size
  485. * @{
  486. */
  487. #define DMA2D_PIXEL (DMA2D_NLR_PL >> 16U) /*!< DMA2D number of pixels per line */
  488. #define DMA2D_LINE DMA2D_NLR_NL /*!< DMA2D number of lines */
  489. /**
  490. * @}
  491. */
  492. /** @defgroup DMA2D_CLUT_Size DMA2D CLUT Size
  493. * @{
  494. */
  495. #define DMA2D_CLUT_SIZE (DMA2D_FGPFCCR_CS >> 8) /*!< DMA2D CLUT size */
  496. /**
  497. * @}
  498. */
  499. /**
  500. * @}
  501. */
  502. /* Private macros ------------------------------------------------------------*/
  503. /** @defgroup DMA2D_Private_Macros DMA2D Private Macros
  504. * @{
  505. */
  506. #define IS_DMA2D_LAYER(LAYER) ((LAYER) <= DMA2D_MAX_LAYER)
  507. #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  508. #define IS_DMA2D_MODE(MODE) (((MODE) == DMA2D_M2M) || ((MODE) == DMA2D_M2M_PFC) || \
  509. ((MODE) == DMA2D_M2M_BLEND) || ((MODE) == DMA2D_R2M) || \
  510. ((MODE) == DMA2D_M2M_BLEND_FG) || ((MODE) == DMA2D_M2M_BLEND_BG))
  511. #else
  512. #define IS_DMA2D_MODE(MODE) (((MODE) == DMA2D_M2M) || ((MODE) == DMA2D_M2M_PFC) || \
  513. ((MODE) == DMA2D_M2M_BLEND) || ((MODE) == DMA2D_R2M))
  514. #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  515. #define IS_DMA2D_CMODE(MODE_ARGB) (((MODE_ARGB) == DMA2D_OUTPUT_ARGB8888) || ((MODE_ARGB) == DMA2D_OUTPUT_RGB888) || \
  516. ((MODE_ARGB) == DMA2D_OUTPUT_RGB565) || ((MODE_ARGB) == DMA2D_OUTPUT_ARGB1555) || \
  517. ((MODE_ARGB) == DMA2D_OUTPUT_ARGB4444))
  518. #define IS_DMA2D_COLOR(COLOR) ((COLOR) <= DMA2D_COLOR_VALUE)
  519. #define IS_DMA2D_LINE(LINE) ((LINE) <= DMA2D_LINE)
  520. #define IS_DMA2D_PIXEL(PIXEL) ((PIXEL) <= DMA2D_PIXEL)
  521. #define IS_DMA2D_OFFSET(OOFFSET) ((OOFFSET) <= DMA2D_OFFSET)
  522. #define IS_DMA2D_INPUT_COLOR_MODE(INPUT_CM) (((INPUT_CM) == DMA2D_INPUT_ARGB8888) || ((INPUT_CM) == DMA2D_INPUT_RGB888) || \
  523. ((INPUT_CM) == DMA2D_INPUT_RGB565) || ((INPUT_CM) == DMA2D_INPUT_ARGB1555) || \
  524. ((INPUT_CM) == DMA2D_INPUT_ARGB4444) || ((INPUT_CM) == DMA2D_INPUT_L8) || \
  525. ((INPUT_CM) == DMA2D_INPUT_AL44) || ((INPUT_CM) == DMA2D_INPUT_AL88) || \
  526. ((INPUT_CM) == DMA2D_INPUT_L4) || ((INPUT_CM) == DMA2D_INPUT_A8) || \
  527. ((INPUT_CM) == DMA2D_INPUT_A4))
  528. #define IS_DMA2D_ALPHA_MODE(AlphaMode) (((AlphaMode) == DMA2D_NO_MODIF_ALPHA) || \
  529. ((AlphaMode) == DMA2D_REPLACE_ALPHA) || \
  530. ((AlphaMode) == DMA2D_COMBINE_ALPHA))
  531. #define IS_DMA2D_ALPHA_INVERTED(Alpha_Inverted) (((Alpha_Inverted) == DMA2D_REGULAR_ALPHA) || \
  532. ((Alpha_Inverted) == DMA2D_INVERTED_ALPHA))
  533. #define IS_DMA2D_RB_SWAP(RB_Swap) (((RB_Swap) == DMA2D_RB_REGULAR) || \
  534. ((RB_Swap) == DMA2D_RB_SWAP))
  535. #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  536. #define IS_DMA2D_LOM_MODE(LOM) (((LOM) == DMA2D_LOM_PIXELS) || \
  537. ((LOM) == DMA2D_LOM_BYTES))
  538. #define IS_DMA2D_BYTES_SWAP(BYTES_SWAP) (((BYTES_SWAP) == DMA2D_BYTES_REGULAR) || \
  539. ((BYTES_SWAP) == DMA2D_BYTES_SWAP))
  540. #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  541. #define IS_DMA2D_CLUT_CM(CLUT_CM) (((CLUT_CM) == DMA2D_CCM_ARGB8888) || ((CLUT_CM) == DMA2D_CCM_RGB888))
  542. #define IS_DMA2D_CLUT_SIZE(CLUT_SIZE) ((CLUT_SIZE) <= DMA2D_CLUT_SIZE)
  543. #define IS_DMA2D_LINEWATERMARK(LineWatermark) ((LineWatermark) <= DMA2D_LINE_WATERMARK_MAX)
  544. #define IS_DMA2D_IT(IT) (((IT) == DMA2D_IT_CTC) || ((IT) == DMA2D_IT_CAE) || \
  545. ((IT) == DMA2D_IT_TW) || ((IT) == DMA2D_IT_TC) || \
  546. ((IT) == DMA2D_IT_TE) || ((IT) == DMA2D_IT_CE))
  547. #define IS_DMA2D_GET_FLAG(FLAG) (((FLAG) == DMA2D_FLAG_CTC) || ((FLAG) == DMA2D_FLAG_CAE) || \
  548. ((FLAG) == DMA2D_FLAG_TW) || ((FLAG) == DMA2D_FLAG_TC) || \
  549. ((FLAG) == DMA2D_FLAG_TE) || ((FLAG) == DMA2D_FLAG_CE))
  550. /**
  551. * @}
  552. */
  553. /**
  554. * @}
  555. */
  556. /**
  557. * @}
  558. */
  559. #endif /* STM32L496xx || STM32L4A6xx || */
  560. /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  561. #ifdef __cplusplus
  562. }
  563. #endif
  564. #endif /* __STM32L4xx_HAL_DMA2D_H */
  565. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/