stm32f4xx_dma2d.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_dma2d.h
  4. * @author MCD Application Team
  5. * @version V1.8.1
  6. * @date 27-January-2022
  7. * @brief This file contains all the functions prototypes for the DMA2D firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * Copyright (c) 2016 STMicroelectronics.
  13. * All rights reserved.
  14. *
  15. * This software is licensed under terms that can be found in the LICENSE file
  16. * in the root directory of this software component.
  17. * If no LICENSE file comes with this software, it is provided AS-IS.
  18. *
  19. ******************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __STM32F4xx_DMA2D_H
  23. #define __STM32F4xx_DMA2D_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f4xx.h"
  29. /** @addtogroup STM32F4xx_StdPeriph_Driver
  30. * @{
  31. */
  32. /** @addtogroup DMA2D
  33. * @{
  34. */
  35. /* Exported types ------------------------------------------------------------*/
  36. /**
  37. * @brief DMA2D Init structure definition
  38. */
  39. typedef struct
  40. {
  41. uint32_t DMA2D_Mode; /*!< configures the DMA2D transfer mode.
  42. This parameter can be one value of @ref DMA2D_MODE */
  43. uint32_t DMA2D_CMode; /*!< configures the color format of the output image.
  44. This parameter can be one value of @ref DMA2D_CMODE */
  45. uint32_t DMA2D_OutputBlue; /*!< configures the blue value of the output image.
  46. This parameter must range:
  47. - from 0x00 to 0xFF if ARGB8888 color mode is slected
  48. - from 0x00 to 0xFF if RGB888 color mode is slected
  49. - from 0x00 to 0x1F if RGB565 color mode is slected
  50. - from 0x00 to 0x1F if ARGB1555 color mode is slected
  51. - from 0x00 to 0x0F if ARGB4444 color mode is slected */
  52. uint32_t DMA2D_OutputGreen; /*!< configures the green value of the output image.
  53. This parameter must range:
  54. - from 0x00 to 0xFF if ARGB8888 color mode is selected
  55. - from 0x00 to 0xFF if RGB888 color mode is selected
  56. - from 0x00 to 0x2F if RGB565 color mode is selected
  57. - from 0x00 to 0x1F if ARGB1555 color mode is selected
  58. - from 0x00 to 0x0F if ARGB4444 color mode is selected */
  59. uint32_t DMA2D_OutputRed; /*!< configures the red value of the output image.
  60. This parameter must range:
  61. - from 0x00 to 0xFF if ARGB8888 color mode is slected
  62. - from 0x00 to 0xFF if RGB888 color mode is slected
  63. - from 0x00 to 0x1F if RGB565 color mode is slected
  64. - from 0x00 to 0x1F if ARGB1555 color mode is slected
  65. - from 0x00 to 0x0F if ARGB4444 color mode is slected */
  66. uint32_t DMA2D_OutputAlpha; /*!< configures the alpha channel of the output color.
  67. This parameter must range:
  68. - from 0x00 to 0xFF if ARGB8888 color mode is selected
  69. - from 0x00 to 0x01 if ARGB1555 color mode is selected
  70. - from 0x00 to 0x0F if ARGB4444 color mode is selected */
  71. uint32_t DMA2D_OutputMemoryAdd; /*!< Specifies the memory address. This parameter
  72. must be range from 0x00000000 to 0xFFFFFFFF. */
  73. uint32_t DMA2D_OutputOffset; /*!< Specifies the Offset value. This parameter must be range from
  74. 0x0000 to 0x3FFF. */
  75. uint32_t DMA2D_NumberOfLine; /*!< Configures the number of line of the area to be transfered.
  76. This parameter must range from 0x0000 to 0xFFFF */
  77. uint32_t DMA2D_PixelPerLine; /*!< Configures the number pixel per line of the area to be transferred.
  78. This parameter must range from 0x0000 to 0x3FFF */
  79. } DMA2D_InitTypeDef;
  80. typedef struct
  81. {
  82. uint32_t DMA2D_FGMA; /*!< configures the DMA2D foreground memory address.
  83. This parameter must be range from 0x00000000 to 0xFFFFFFFF. */
  84. uint32_t DMA2D_FGO; /*!< configures the DMA2D foreground offset.
  85. This parameter must be range from 0x0000 to 0x3FFF. */
  86. uint32_t DMA2D_FGCM; /*!< configures the DMA2D foreground color mode .
  87. This parameter can be one value of @ref DMA2D_FGCM */
  88. uint32_t DMA2D_FG_CLUT_CM; /*!< configures the DMA2D foreground CLUT color mode.
  89. This parameter can be one value of @ref DMA2D_FG_CLUT_CM */
  90. uint32_t DMA2D_FG_CLUT_SIZE; /*!< configures the DMA2D foreground CLUT size.
  91. This parameter must range from 0x00 to 0xFF. */
  92. uint32_t DMA2D_FGPFC_ALPHA_MODE; /*!< configures the DMA2D foreground alpha mode.
  93. This parameter can be one value of @ref DMA2D_FGPFC_ALPHA_MODE */
  94. uint32_t DMA2D_FGPFC_ALPHA_VALUE; /*!< Specifies the DMA2D foreground alpha value
  95. must be range from 0x00 to 0xFF. */
  96. uint32_t DMA2D_FGC_BLUE; /*!< Specifies the DMA2D foreground blue value
  97. must be range from 0x00 to 0xFF. */
  98. uint32_t DMA2D_FGC_GREEN; /*!< Specifies the DMA2D foreground green value
  99. must be range from 0x00 to 0xFF. */
  100. uint32_t DMA2D_FGC_RED; /*!< Specifies the DMA2D foreground red value
  101. must be range from 0x00 to 0xFF. */
  102. uint32_t DMA2D_FGCMAR; /*!< Configures the DMA2D foreground CLUT memory address.
  103. This parameter must range from 0x00000000 to 0xFFFFFFFF. */
  104. } DMA2D_FG_InitTypeDef;
  105. typedef struct
  106. {
  107. uint32_t DMA2D_BGMA; /*!< configures the DMA2D background memory address.
  108. This parameter must be range from 0x00000000 to 0xFFFFFFFF. */
  109. uint32_t DMA2D_BGO; /*!< configures the DMA2D background offset.
  110. This parameter must be range from 0x0000 to 0x3FFF. */
  111. uint32_t DMA2D_BGCM; /*!< configures the DMA2D background color mode .
  112. This parameter can be one value of @ref DMA2D_FGCM */
  113. uint32_t DMA2D_BG_CLUT_CM; /*!< configures the DMA2D background CLUT color mode.
  114. This parameter can be one value of @ref DMA2D_FG_CLUT_CM */
  115. uint32_t DMA2D_BG_CLUT_SIZE; /*!< configures the DMA2D background CLUT size.
  116. This parameter must range from 0x00 to 0xFF. */
  117. uint32_t DMA2D_BGPFC_ALPHA_MODE; /*!< configures the DMA2D background alpha mode.
  118. This parameter can be one value of @ref DMA2D_FGPFC_ALPHA_MODE */
  119. uint32_t DMA2D_BGPFC_ALPHA_VALUE; /*!< Specifies the DMA2D background alpha value
  120. must be range from 0x00 to 0xFF. */
  121. uint32_t DMA2D_BGC_BLUE; /*!< Specifies the DMA2D background blue value
  122. must be range from 0x00 to 0xFF. */
  123. uint32_t DMA2D_BGC_GREEN; /*!< Specifies the DMA2D background green value
  124. must be range from 0x00 to 0xFF. */
  125. uint32_t DMA2D_BGC_RED; /*!< Specifies the DMA2D background red value
  126. must be range from 0x00 to 0xFF. */
  127. uint32_t DMA2D_BGCMAR; /*!< Configures the DMA2D background CLUT memory address.
  128. This parameter must range from 0x00000000 to 0xFFFFFFFF. */
  129. } DMA2D_BG_InitTypeDef;
  130. /* Exported constants --------------------------------------------------------*/
  131. /** @defgroup DMA2D_Exported_Constants
  132. * @{
  133. */
  134. /** @defgroup DMA2D_MODE
  135. * @{
  136. */
  137. #define DMA2D_M2M ((uint32_t)0x00000000)
  138. #define DMA2D_M2M_PFC ((uint32_t)0x00010000)
  139. #define DMA2D_M2M_BLEND ((uint32_t)0x00020000)
  140. #define DMA2D_R2M ((uint32_t)0x00030000)
  141. #define IS_DMA2D_MODE(MODE) (((MODE) == DMA2D_M2M) || ((MODE) == DMA2D_M2M_PFC) || \
  142. ((MODE) == DMA2D_M2M_BLEND) || ((MODE) == DMA2D_R2M))
  143. /**
  144. * @}
  145. */
  146. /** @defgroup DMA2D_CMODE
  147. * @{
  148. */
  149. #define DMA2D_ARGB8888 ((uint32_t)0x00000000)
  150. #define DMA2D_RGB888 ((uint32_t)0x00000001)
  151. #define DMA2D_RGB565 ((uint32_t)0x00000002)
  152. #define DMA2D_ARGB1555 ((uint32_t)0x00000003)
  153. #define DMA2D_ARGB4444 ((uint32_t)0x00000004)
  154. #define IS_DMA2D_CMODE(MODE_ARGB) (((MODE_ARGB) == DMA2D_ARGB8888) || ((MODE_ARGB) == DMA2D_RGB888) || \
  155. ((MODE_ARGB) == DMA2D_RGB565) || ((MODE_ARGB) == DMA2D_ARGB1555) || \
  156. ((MODE_ARGB) == DMA2D_ARGB4444))
  157. /**
  158. * @}
  159. */
  160. /** @defgroup DMA2D_OUTPUT_COLOR
  161. * @{
  162. */
  163. #define DMA2D_Output_Color ((uint32_t)0x000000FF)
  164. #define IS_DMA2D_OGREEN(OGREEN) ((OGREEN) <= DMA2D_Output_Color)
  165. #define IS_DMA2D_ORED(ORED) ((ORED) <= DMA2D_Output_Color)
  166. #define IS_DMA2D_OBLUE(OBLUE) ((OBLUE) <= DMA2D_Output_Color)
  167. #define IS_DMA2D_OALPHA(OALPHA) ((OALPHA) <= DMA2D_Output_Color)
  168. /**
  169. * @}
  170. */
  171. /** @defgroup DMA2D_OUTPUT_OFFSET
  172. * @{
  173. */
  174. #define DMA2D_OUTPUT_OFFSET ((uint32_t)0x00003FFF)
  175. #define IS_DMA2D_OUTPUT_OFFSET(OOFFSET) ((OOFFSET) <= DMA2D_OUTPUT_OFFSET)
  176. /**
  177. * @}
  178. */
  179. /** @defgroup DMA2D_SIZE
  180. * @{
  181. */
  182. #define DMA2D_pixel ((uint32_t)0x00003FFF)
  183. #define DMA2D_Line ((uint32_t)0x0000FFFF)
  184. #define IS_DMA2D_LINE(LINE) ((LINE) <= DMA2D_Line)
  185. #define IS_DMA2D_PIXEL(PIXEL) ((PIXEL) <= DMA2D_pixel)
  186. /**
  187. * @}
  188. */
  189. /** @defgroup DMA2D_OFFSET
  190. * @{
  191. */
  192. #define OFFSET ((uint32_t)0x00003FFF)
  193. #define IS_DMA2D_FGO(FGO) ((FGO) <= OFFSET)
  194. #define IS_DMA2D_BGO(BGO) ((BGO) <= OFFSET)
  195. /**
  196. * @}
  197. */
  198. /** @defgroup DMA2D_FGCM
  199. * @{
  200. */
  201. #define CM_ARGB8888 ((uint32_t)0x00000000)
  202. #define CM_RGB888 ((uint32_t)0x00000001)
  203. #define CM_RGB565 ((uint32_t)0x00000002)
  204. #define CM_ARGB1555 ((uint32_t)0x00000003)
  205. #define CM_ARGB4444 ((uint32_t)0x00000004)
  206. #define CM_L8 ((uint32_t)0x00000005)
  207. #define CM_AL44 ((uint32_t)0x00000006)
  208. #define CM_AL88 ((uint32_t)0x00000007)
  209. #define CM_L4 ((uint32_t)0x00000008)
  210. #define CM_A8 ((uint32_t)0x00000009)
  211. #define CM_A4 ((uint32_t)0x0000000A)
  212. #define IS_DMA2D_FGCM(FGCM) (((FGCM) == CM_ARGB8888) || ((FGCM) == CM_RGB888) || \
  213. ((FGCM) == CM_RGB565) || ((FGCM) == CM_ARGB1555) || \
  214. ((FGCM) == CM_ARGB4444) || ((FGCM) == CM_L8) || \
  215. ((FGCM) == CM_AL44) || ((FGCM) == CM_AL88) || \
  216. ((FGCM) == CM_L4) || ((FGCM) == CM_A8) || \
  217. ((FGCM) == CM_A4))
  218. #define IS_DMA2D_BGCM(BGCM) (((BGCM) == CM_ARGB8888) || ((BGCM) == CM_RGB888) || \
  219. ((BGCM) == CM_RGB565) || ((BGCM) == CM_ARGB1555) || \
  220. ((BGCM) == CM_ARGB4444) || ((BGCM) == CM_L8) || \
  221. ((BGCM) == CM_AL44) || ((BGCM) == CM_AL88) || \
  222. ((BGCM) == CM_L4) || ((BGCM) == CM_A8) || \
  223. ((BGCM) == CM_A4))
  224. /**
  225. * @}
  226. */
  227. /** @defgroup DMA2D_FG_CLUT_CM
  228. * @{
  229. */
  230. #define CLUT_CM_ARGB8888 ((uint32_t)0x00000000)
  231. #define CLUT_CM_RGB888 ((uint32_t)0x00000001)
  232. #define IS_DMA2D_FG_CLUT_CM(FG_CLUT_CM) (((FG_CLUT_CM) == CLUT_CM_ARGB8888) || ((FG_CLUT_CM) == CLUT_CM_RGB888))
  233. #define IS_DMA2D_BG_CLUT_CM(BG_CLUT_CM) (((BG_CLUT_CM) == CLUT_CM_ARGB8888) || ((BG_CLUT_CM) == CLUT_CM_RGB888))
  234. /**
  235. * @}
  236. */
  237. /** @defgroup DMA2D_FG_COLOR_VALUE
  238. * @{
  239. */
  240. #define COLOR_VALUE ((uint32_t)0x000000FF)
  241. #define IS_DMA2D_FG_CLUT_SIZE(FG_CLUT_SIZE) ((FG_CLUT_SIZE) <= COLOR_VALUE)
  242. #define IS_DMA2D_FG_ALPHA_VALUE(FG_ALPHA_VALUE) ((FG_ALPHA_VALUE) <= COLOR_VALUE)
  243. #define IS_DMA2D_FGC_BLUE(FGC_BLUE) ((FGC_BLUE) <= COLOR_VALUE)
  244. #define IS_DMA2D_FGC_GREEN(FGC_GREEN) ((FGC_GREEN) <= COLOR_VALUE)
  245. #define IS_DMA2D_FGC_RED(FGC_RED) ((FGC_RED) <= COLOR_VALUE)
  246. #define IS_DMA2D_BG_CLUT_SIZE(BG_CLUT_SIZE) ((BG_CLUT_SIZE) <= COLOR_VALUE)
  247. #define IS_DMA2D_BG_ALPHA_VALUE(BG_ALPHA_VALUE) ((BG_ALPHA_VALUE) <= COLOR_VALUE)
  248. #define IS_DMA2D_BGC_BLUE(BGC_BLUE) ((BGC_BLUE) <= COLOR_VALUE)
  249. #define IS_DMA2D_BGC_GREEN(BGC_GREEN) ((BGC_GREEN) <= COLOR_VALUE)
  250. #define IS_DMA2D_BGC_RED(BGC_RED) ((BGC_RED) <= COLOR_VALUE)
  251. /**
  252. * @}
  253. */
  254. /** DMA2D_FGPFC_ALPHA_MODE
  255. * @{
  256. */
  257. #define NO_MODIF_ALPHA_VALUE ((uint32_t)0x00000000)
  258. #define REPLACE_ALPHA_VALUE ((uint32_t)0x00000001)
  259. #define COMBINE_ALPHA_VALUE ((uint32_t)0x00000002)
  260. #define IS_DMA2D_FG_ALPHA_MODE(FG_ALPHA_MODE) (((FG_ALPHA_MODE) == NO_MODIF_ALPHA_VALUE) || \
  261. ((FG_ALPHA_MODE) == REPLACE_ALPHA_VALUE) || \
  262. ((FG_ALPHA_MODE) == COMBINE_ALPHA_VALUE))
  263. #define IS_DMA2D_BG_ALPHA_MODE(BG_ALPHA_MODE) (((BG_ALPHA_MODE) == NO_MODIF_ALPHA_VALUE) || \
  264. ((BG_ALPHA_MODE) == REPLACE_ALPHA_VALUE) || \
  265. ((BG_ALPHA_MODE) == COMBINE_ALPHA_VALUE))
  266. /**
  267. * @}
  268. */
  269. /** @defgroup DMA2D_Interrupts
  270. * @{
  271. */
  272. #define DMA2D_IT_CE DMA2D_CR_CEIE
  273. #define DMA2D_IT_CTC DMA2D_CR_CTCIE
  274. #define DMA2D_IT_CAE DMA2D_CR_CAEIE
  275. #define DMA2D_IT_TW DMA2D_CR_TWIE
  276. #define DMA2D_IT_TC DMA2D_CR_TCIE
  277. #define DMA2D_IT_TE DMA2D_CR_TEIE
  278. #define IS_DMA2D_IT(IT) (((IT) == DMA2D_IT_CTC) || ((IT) == DMA2D_IT_CAE) || \
  279. ((IT) == DMA2D_IT_TW) || ((IT) == DMA2D_IT_TC) || \
  280. ((IT) == DMA2D_IT_TE) || ((IT) == DMA2D_IT_CE))
  281. /**
  282. * @}
  283. */
  284. /** @defgroup DMA2D_Flag
  285. * @{
  286. */
  287. #define DMA2D_FLAG_CE DMA2D_ISR_CEIF
  288. #define DMA2D_FLAG_CTC DMA2D_ISR_CTCIF
  289. #define DMA2D_FLAG_CAE DMA2D_ISR_CAEIF
  290. #define DMA2D_FLAG_TW DMA2D_ISR_TWIF
  291. #define DMA2D_FLAG_TC DMA2D_ISR_TCIF
  292. #define DMA2D_FLAG_TE DMA2D_ISR_TEIF
  293. #define IS_DMA2D_GET_FLAG(FLAG) (((FLAG) == DMA2D_FLAG_CTC) || ((FLAG) == DMA2D_FLAG_CAE) || \
  294. ((FLAG) == DMA2D_FLAG_TW) || ((FLAG) == DMA2D_FLAG_TC) || \
  295. ((FLAG) == DMA2D_FLAG_TE) || ((FLAG) == DMA2D_FLAG_CE))
  296. /**
  297. * @}
  298. */
  299. /** @defgroup DMA2D_DeadTime
  300. * @{
  301. */
  302. #define DEADTIME ((uint32_t)0x000000FF)
  303. #define IS_DMA2D_DEAD_TIME(DEAD_TIME) ((DEAD_TIME) <= DEADTIME)
  304. #define LINE_WATERMARK DMA2D_LWR_LW
  305. #define IS_DMA2D_LineWatermark(LineWatermark) ((LineWatermark) <= LINE_WATERMARK)
  306. /**
  307. * @}
  308. */
  309. /**
  310. * @}
  311. */
  312. /* Exported macro ------------------------------------------------------------*/
  313. /* Exported functions ------------------------------------------------------- */
  314. /* Function used to set the DMA2D configuration to the default reset state *****/
  315. void DMA2D_DeInit(void);
  316. /* Initialization and Configuration functions *********************************/
  317. void DMA2D_Init(DMA2D_InitTypeDef* DMA2D_InitStruct);
  318. void DMA2D_StructInit(DMA2D_InitTypeDef* DMA2D_InitStruct);
  319. void DMA2D_StartTransfer(void);
  320. void DMA2D_AbortTransfer(void);
  321. void DMA2D_Suspend(FunctionalState NewState);
  322. void DMA2D_FGConfig(DMA2D_FG_InitTypeDef* DMA2D_FG_InitStruct);
  323. void DMA2D_FG_StructInit(DMA2D_FG_InitTypeDef* DMA2D_FG_InitStruct);
  324. void DMA2D_BGConfig(DMA2D_BG_InitTypeDef* DMA2D_BG_InitStruct);
  325. void DMA2D_BG_StructInit(DMA2D_BG_InitTypeDef* DMA2D_BG_InitStruct);
  326. void DMA2D_FGStart(FunctionalState NewState);
  327. void DMA2D_BGStart(FunctionalState NewState);
  328. void DMA2D_DeadTimeConfig(uint32_t DMA2D_DeadTime, FunctionalState NewState);
  329. void DMA2D_LineWatermarkConfig(uint32_t DMA2D_LWatermarkConfig);
  330. /* Interrupts and flags management functions **********************************/
  331. void DMA2D_ITConfig(uint32_t DMA2D_IT, FunctionalState NewState);
  332. FlagStatus DMA2D_GetFlagStatus(uint32_t DMA2D_FLAG);
  333. void DMA2D_ClearFlag(uint32_t DMA2D_FLAG);
  334. ITStatus DMA2D_GetITStatus(uint32_t DMA2D_IT);
  335. void DMA2D_ClearITPendingBit(uint32_t DMA2D_IT);
  336. #ifdef __cplusplus
  337. }
  338. #endif
  339. #endif /* __STM32F4xx_DMA2D_H */
  340. /**
  341. * @}
  342. */
  343. /**
  344. * @}
  345. */