2 ******************************************************************************
3 * @file stm32h7xx_ll_dma2d.c
4 * @author MCD Application Team
5 * @brief DMA2D LL module driver.
6 ******************************************************************************
9 * Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.
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.
16 ******************************************************************************
18 #if defined(USE_FULL_LL_DRIVER)
20 /* Includes ------------------------------------------------------------------*/
21 #include "stm32h7xx_ll_dma2d.h"
22 #include "stm32h7xx_ll_bus.h"
23 #ifdef USE_FULL_ASSERT
24 #include "stm32_assert.h"
26 #define assert_param(expr) ((void)0U)
27 #endif /* USE_FULL_ASSERT */
29 /** @addtogroup STM32H7xx_LL_Driver
35 /** @addtogroup DMA2D_LL
39 /* Private types -------------------------------------------------------------*/
40 /* Private variables ---------------------------------------------------------*/
41 /* Private constants ---------------------------------------------------------*/
42 /** @addtogroup DMA2D_LL_Private_Constants DMA2D Private Constants
45 #define LL_DMA2D_COLOR 0xFFU /*!< Maximum output color setting */
46 #define LL_DMA2D_NUMBEROFLINES DMA2D_NLR_NL /*!< Maximum number of lines */
47 #define LL_DMA2D_NUMBEROFPIXELS (DMA2D_NLR_PL >> DMA2D_NLR_PL_Pos) /*!< Maximum number of pixels per lines */
48 #define LL_DMA2D_OFFSET_MAX 0x3FFFU /*!< Maximum output line offset expressed in pixels */
49 #define LL_DMA2D_CLUTSIZE_MAX 0xFFU /*!< Maximum CLUT size */
53 /* Private macros ------------------------------------------------------------*/
54 /** @addtogroup DMA2D_LL_Private_Macros
57 #define IS_LL_DMA2D_MODE(MODE) (((MODE) == LL_DMA2D_MODE_M2M) || \
58 ((MODE) == LL_DMA2D_MODE_M2M_PFC) || \
59 ((MODE) == LL_DMA2D_MODE_M2M_BLEND) || \
60 ((MODE) == LL_DMA2D_MODE_M2M_BLEND_FIXED_COLOR_FG) || \
61 ((MODE) == LL_DMA2D_MODE_M2M_BLEND_FIXED_COLOR_BG) || \
62 ((MODE) == LL_DMA2D_MODE_R2M))
64 #define IS_LL_DMA2D_OCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB8888) || \
65 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB888) || \
66 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB565) || \
67 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB1555) || \
68 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB4444))
70 #define IS_LL_DMA2D_GREEN(GREEN) ((GREEN) <= LL_DMA2D_COLOR)
71 #define IS_LL_DMA2D_RED(RED) ((RED) <= LL_DMA2D_COLOR)
72 #define IS_LL_DMA2D_BLUE(BLUE) ((BLUE) <= LL_DMA2D_COLOR)
73 #define IS_LL_DMA2D_ALPHA(ALPHA) ((ALPHA) <= LL_DMA2D_COLOR)
75 #define IS_LL_DMA2D_OFFSET_MODE(MODE) (((MODE) == LL_DMA2D_LINE_OFFSET_PIXELS) || \
76 ((MODE) == LL_DMA2D_LINE_OFFSET_BYTES))
78 #define IS_LL_DMA2D_OFFSET(OFFSET) ((OFFSET) <= LL_DMA2D_OFFSET_MAX)
80 #define IS_LL_DMA2D_LINE(LINES) ((LINES) <= LL_DMA2D_NUMBEROFLINES)
81 #define IS_LL_DMA2D_PIXEL(PIXELS) ((PIXELS) <= LL_DMA2D_NUMBEROFPIXELS)
83 #define IS_LL_DMA2D_SWAP_MODE(MODE) (((MODE) == LL_DMA2D_SWAP_MODE_REGULAR) || \
84 ((MODE) == LL_DMA2D_SWAP_MODE_TWO_BY_TWO))
86 #define IS_LL_DMA2D_ALPHAINV(ALPHA) (((ALPHA) == LL_DMA2D_ALPHA_REGULAR) || \
87 ((ALPHA) == LL_DMA2D_ALPHA_INVERTED))
89 #define IS_LL_DMA2D_RBSWAP(RBSWAP) (((RBSWAP) == LL_DMA2D_RB_MODE_REGULAR) || \
90 ((RBSWAP) == LL_DMA2D_RB_MODE_SWAP))
92 #define IS_LL_DMA2D_LCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB8888) || \
93 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB888) || \
94 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB565) || \
95 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB1555) || \
96 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB4444) || \
97 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L8) || \
98 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL44) || \
99 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL88) || \
100 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L4) || \
101 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A8) || \
102 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A4))
104 #define IS_LL_DMA2D_CLUTCMODE(CLUTCMODE) (((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_ARGB8888) || \
105 ((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_RGB888))
107 #define IS_LL_DMA2D_CLUTSIZE(SIZE) ((SIZE) <= LL_DMA2D_CLUTSIZE_MAX)
109 #define IS_LL_DMA2D_ALPHAMODE(MODE) (((MODE) == LL_DMA2D_ALPHA_MODE_NO_MODIF) || \
110 ((MODE) == LL_DMA2D_ALPHA_MODE_REPLACE) || \
111 ((MODE) == LL_DMA2D_ALPHA_MODE_COMBINE))
113 #define IS_LL_DMA2D_CHROMA_SUB_SAMPLING(CSS) (((CSS) == LL_DMA2D_CSS_444) || \
114 ((CSS) == LL_DMA2D_CSS_422) || \
115 ((CSS) == LL_DMA2D_CSS_420))
121 /* Private function prototypes -----------------------------------------------*/
123 /* Exported functions --------------------------------------------------------*/
124 /** @addtogroup DMA2D_LL_Exported_Functions
128 /** @addtogroup DMA2D_LL_EF_Init_Functions Initialization and De-initialization Functions
133 * @brief De-initialize DMA2D registers (registers restored to their default values).
134 * @param DMA2Dx DMA2D Instance
135 * @retval An ErrorStatus enumeration value:
136 * - SUCCESS: DMA2D registers are de-initialized
137 * - ERROR: DMA2D registers are not de-initialized
139 ErrorStatus
LL_DMA2D_DeInit(const DMA2D_TypeDef
*DMA2Dx
)
141 ErrorStatus status
= SUCCESS
;
143 /* Check the parameters */
144 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
148 /* Force reset of DMA2D clock */
149 LL_AHB3_GRP1_ForceReset(LL_AHB3_GRP1_PERIPH_DMA2D
);
151 /* Release reset of DMA2D clock */
152 LL_AHB3_GRP1_ReleaseReset(LL_AHB3_GRP1_PERIPH_DMA2D
);
163 * @brief Initialize DMA2D registers according to the specified parameters in DMA2D_InitStruct.
164 * @note DMA2D transfers must be disabled to set initialization bits in configuration registers,
165 * otherwise ERROR result is returned.
166 * @param DMA2Dx DMA2D Instance
167 * @param DMA2D_InitStruct pointer to a LL_DMA2D_InitTypeDef structure
168 * that contains the configuration information for the specified DMA2D peripheral.
169 * @retval An ErrorStatus enumeration value:
170 * - SUCCESS: DMA2D registers are initialized according to DMA2D_InitStruct content
171 * - ERROR: Issue occurred during DMA2D registers initialization
173 ErrorStatus
LL_DMA2D_Init(DMA2D_TypeDef
*DMA2Dx
, LL_DMA2D_InitTypeDef
*DMA2D_InitStruct
)
175 ErrorStatus status
= ERROR
;
176 LL_DMA2D_ColorTypeDef dma2d_colorstruct
;
183 /* Check the parameters */
184 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
185 assert_param(IS_LL_DMA2D_MODE(DMA2D_InitStruct
->Mode
));
186 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_InitStruct
->ColorMode
));
187 assert_param(IS_LL_DMA2D_LINE(DMA2D_InitStruct
->NbrOfLines
));
188 assert_param(IS_LL_DMA2D_PIXEL(DMA2D_InitStruct
->NbrOfPixelsPerLines
));
189 assert_param(IS_LL_DMA2D_GREEN(DMA2D_InitStruct
->OutputGreen
));
190 assert_param(IS_LL_DMA2D_RED(DMA2D_InitStruct
->OutputRed
));
191 assert_param(IS_LL_DMA2D_BLUE(DMA2D_InitStruct
->OutputBlue
));
192 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_InitStruct
->OutputAlpha
));
193 assert_param(IS_LL_DMA2D_SWAP_MODE(DMA2D_InitStruct
->OutputSwapMode
));
194 assert_param(IS_LL_DMA2D_OFFSET_MODE(DMA2D_InitStruct
->LineOffsetMode
));
195 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_InitStruct
->LineOffset
));
196 assert_param(IS_LL_DMA2D_ALPHAINV(DMA2D_InitStruct
->AlphaInversionMode
));
197 assert_param(IS_LL_DMA2D_RBSWAP(DMA2D_InitStruct
->RBSwapMode
));
199 /* DMA2D transfers must be disabled to configure bits in initialization registers */
200 tmp
= LL_DMA2D_IsTransferOngoing(DMA2Dx
);
201 tmp1
= LL_DMA2D_FGND_IsEnabledCLUTLoad(DMA2Dx
);
202 tmp2
= LL_DMA2D_BGND_IsEnabledCLUTLoad(DMA2Dx
);
203 if ((tmp
== 0U) && (tmp1
== 0U) && (tmp2
== 0U))
205 /* DMA2D CR register configuration -------------------------------------------*/
206 MODIFY_REG(DMA2Dx
->CR
, (DMA2D_CR_MODE
| DMA2D_CR_LOM
), \
207 (DMA2D_InitStruct
->Mode
| DMA2D_InitStruct
->LineOffsetMode
));
209 /* DMA2D OPFCCR register configuration ---------------------------------------*/
210 regMask
= DMA2D_OPFCCR_CM
;
211 regValue
= DMA2D_InitStruct
->ColorMode
;
213 regMask
|= DMA2D_OPFCCR_SB
;
214 regValue
|= DMA2D_InitStruct
->OutputSwapMode
;
216 regMask
|= (DMA2D_OPFCCR_RBS
| DMA2D_OPFCCR_AI
);
217 regValue
|= (DMA2D_InitStruct
->AlphaInversionMode
| DMA2D_InitStruct
->RBSwapMode
);
220 MODIFY_REG(DMA2Dx
->OPFCCR
, regMask
, regValue
);
222 /* DMA2D OOR register configuration ------------------------------------------*/
223 LL_DMA2D_SetLineOffset(DMA2Dx
, DMA2D_InitStruct
->LineOffset
);
225 /* DMA2D NLR register configuration ------------------------------------------*/
226 LL_DMA2D_ConfigSize(DMA2Dx
, DMA2D_InitStruct
->NbrOfLines
, DMA2D_InitStruct
->NbrOfPixelsPerLines
);
228 /* DMA2D OMAR register configuration ------------------------------------------*/
229 LL_DMA2D_SetOutputMemAddr(DMA2Dx
, DMA2D_InitStruct
->OutputMemoryAddress
);
231 /* DMA2D OCOLR register configuration ------------------------------------------*/
232 dma2d_colorstruct
.ColorMode
= DMA2D_InitStruct
->ColorMode
;
233 dma2d_colorstruct
.OutputBlue
= DMA2D_InitStruct
->OutputBlue
;
234 dma2d_colorstruct
.OutputGreen
= DMA2D_InitStruct
->OutputGreen
;
235 dma2d_colorstruct
.OutputRed
= DMA2D_InitStruct
->OutputRed
;
236 dma2d_colorstruct
.OutputAlpha
= DMA2D_InitStruct
->OutputAlpha
;
237 LL_DMA2D_ConfigOutputColor(DMA2Dx
, &dma2d_colorstruct
);
241 /* If DMA2D transfers are not disabled, return ERROR */
247 * @brief Set each @ref LL_DMA2D_InitTypeDef field to default value.
248 * @param DMA2D_InitStruct pointer to a @ref LL_DMA2D_InitTypeDef structure
249 * whose fields will be set to default values.
252 void LL_DMA2D_StructInit(LL_DMA2D_InitTypeDef
*DMA2D_InitStruct
)
254 /* Set DMA2D_InitStruct fields to default values */
255 DMA2D_InitStruct
->Mode
= LL_DMA2D_MODE_M2M
;
256 DMA2D_InitStruct
->ColorMode
= LL_DMA2D_OUTPUT_MODE_ARGB8888
;
257 DMA2D_InitStruct
->NbrOfLines
= 0x0U
;
258 DMA2D_InitStruct
->NbrOfPixelsPerLines
= 0x0U
;
259 DMA2D_InitStruct
->LineOffsetMode
= LL_DMA2D_LINE_OFFSET_PIXELS
;
260 DMA2D_InitStruct
->LineOffset
= 0x0U
;
261 DMA2D_InitStruct
->OutputBlue
= 0x0U
;
262 DMA2D_InitStruct
->OutputGreen
= 0x0U
;
263 DMA2D_InitStruct
->OutputRed
= 0x0U
;
264 DMA2D_InitStruct
->OutputAlpha
= 0x0U
;
265 DMA2D_InitStruct
->OutputMemoryAddress
= 0x0U
;
266 DMA2D_InitStruct
->OutputSwapMode
= LL_DMA2D_SWAP_MODE_REGULAR
;
267 DMA2D_InitStruct
->AlphaInversionMode
= LL_DMA2D_ALPHA_REGULAR
;
268 DMA2D_InitStruct
->RBSwapMode
= LL_DMA2D_RB_MODE_REGULAR
;
272 * @brief Configure the foreground or background according to the specified parameters
273 * in the LL_DMA2D_LayerCfgTypeDef structure.
274 * @param DMA2Dx DMA2D Instance
275 * @param DMA2D_LayerCfg pointer to a LL_DMA2D_LayerCfgTypeDef structure that contains
276 * the configuration information for the specified layer.
277 * @param LayerIdx DMA2D Layer index.
278 * This parameter can be one of the following values:
279 * 0(background) / 1(foreground)
282 void LL_DMA2D_ConfigLayer(DMA2D_TypeDef
*DMA2Dx
, LL_DMA2D_LayerCfgTypeDef
*DMA2D_LayerCfg
, uint32_t LayerIdx
)
284 /* Check the parameters */
285 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_LayerCfg
->LineOffset
));
286 assert_param(IS_LL_DMA2D_LCMODE(DMA2D_LayerCfg
->ColorMode
));
287 assert_param(IS_LL_DMA2D_CLUTCMODE(DMA2D_LayerCfg
->CLUTColorMode
));
288 assert_param(IS_LL_DMA2D_CLUTSIZE(DMA2D_LayerCfg
->CLUTSize
));
289 assert_param(IS_LL_DMA2D_ALPHAMODE(DMA2D_LayerCfg
->AlphaMode
));
290 assert_param(IS_LL_DMA2D_GREEN(DMA2D_LayerCfg
->Green
));
291 assert_param(IS_LL_DMA2D_RED(DMA2D_LayerCfg
->Red
));
292 assert_param(IS_LL_DMA2D_BLUE(DMA2D_LayerCfg
->Blue
));
293 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_LayerCfg
->Alpha
));
294 assert_param(IS_LL_DMA2D_ALPHAINV(DMA2D_LayerCfg
->AlphaInversionMode
));
295 assert_param(IS_LL_DMA2D_RBSWAP(DMA2D_LayerCfg
->RBSwapMode
));
296 assert_param(IS_LL_DMA2D_CHROMA_SUB_SAMPLING(DMA2D_LayerCfg
->ChromaSubSampling
));
301 /* Configure the background memory address */
302 LL_DMA2D_BGND_SetMemAddr(DMA2Dx
, DMA2D_LayerCfg
->MemoryAddress
);
304 /* Configure the background line offset */
305 LL_DMA2D_BGND_SetLineOffset(DMA2Dx
, DMA2D_LayerCfg
->LineOffset
);
307 /* Configure the background Alpha value, Alpha mode, RB swap, Alpha inversion
308 CLUT size, CLUT Color mode and Color mode */
309 MODIFY_REG(DMA2Dx
->BGPFCCR
, \
310 (DMA2D_BGPFCCR_ALPHA
| DMA2D_BGPFCCR_RBS
| DMA2D_BGPFCCR_AI
| DMA2D_BGPFCCR_AM
| \
311 DMA2D_BGPFCCR_CS
| DMA2D_BGPFCCR_CCM
| DMA2D_BGPFCCR_CM
), \
312 ((DMA2D_LayerCfg
->Alpha
<< DMA2D_BGPFCCR_ALPHA_Pos
) | DMA2D_LayerCfg
->RBSwapMode
| \
313 DMA2D_LayerCfg
->AlphaInversionMode
| DMA2D_LayerCfg
->AlphaMode
| \
314 (DMA2D_LayerCfg
->CLUTSize
<< DMA2D_BGPFCCR_CS_Pos
) | DMA2D_LayerCfg
->CLUTColorMode
| \
315 DMA2D_LayerCfg
->ColorMode
));
317 /* Configure the background color */
318 LL_DMA2D_BGND_SetColor(DMA2Dx
, DMA2D_LayerCfg
->Red
, DMA2D_LayerCfg
->Green
, DMA2D_LayerCfg
->Blue
);
320 /* Configure the background CLUT memory address */
321 LL_DMA2D_BGND_SetCLUTMemAddr(DMA2Dx
, DMA2D_LayerCfg
->CLUTMemoryAddress
);
325 /* Configure the foreground memory address */
326 LL_DMA2D_FGND_SetMemAddr(DMA2Dx
, DMA2D_LayerCfg
->MemoryAddress
);
328 /* Configure the foreground line offset */
329 LL_DMA2D_FGND_SetLineOffset(DMA2Dx
, DMA2D_LayerCfg
->LineOffset
);
331 /* Configure the foreground Alpha value, Alpha mode, RB swap, Alpha inversion
332 CLUT size, CLUT Color mode and Color mode */
333 MODIFY_REG(DMA2Dx
->FGPFCCR
, \
334 (DMA2D_FGPFCCR_ALPHA
| DMA2D_FGPFCCR_RBS
| DMA2D_FGPFCCR_AI
| DMA2D_FGPFCCR_CSS
| DMA2D_FGPFCCR_AM
| \
335 DMA2D_FGPFCCR_CS
| DMA2D_FGPFCCR_CCM
| DMA2D_FGPFCCR_CM
), \
336 ((DMA2D_LayerCfg
->Alpha
<< DMA2D_FGPFCCR_ALPHA_Pos
) | DMA2D_LayerCfg
->RBSwapMode
| \
337 DMA2D_LayerCfg
->AlphaInversionMode
| DMA2D_LayerCfg
->ChromaSubSampling
| \
338 DMA2D_LayerCfg
->AlphaMode
| (DMA2D_LayerCfg
->CLUTSize
<< DMA2D_FGPFCCR_CS_Pos
) | \
339 DMA2D_LayerCfg
->CLUTColorMode
| DMA2D_LayerCfg
->ColorMode
));
341 /* Configure the foreground color */
342 LL_DMA2D_FGND_SetColor(DMA2Dx
, DMA2D_LayerCfg
->Red
, DMA2D_LayerCfg
->Green
, DMA2D_LayerCfg
->Blue
);
344 /* Configure the foreground CLUT memory address */
345 LL_DMA2D_FGND_SetCLUTMemAddr(DMA2Dx
, DMA2D_LayerCfg
->CLUTMemoryAddress
);
350 * @brief Set each @ref LL_DMA2D_LayerCfgTypeDef field to default value.
351 * @param DMA2D_LayerCfg pointer to a @ref LL_DMA2D_LayerCfgTypeDef structure
352 * whose fields will be set to default values.
355 void LL_DMA2D_LayerCfgStructInit(LL_DMA2D_LayerCfgTypeDef
*DMA2D_LayerCfg
)
357 /* Set DMA2D_LayerCfg fields to default values */
358 DMA2D_LayerCfg
->MemoryAddress
= 0x0U
;
359 DMA2D_LayerCfg
->ColorMode
= LL_DMA2D_INPUT_MODE_ARGB8888
;
360 DMA2D_LayerCfg
->LineOffset
= 0x0U
;
361 DMA2D_LayerCfg
->CLUTColorMode
= LL_DMA2D_CLUT_COLOR_MODE_ARGB8888
;
362 DMA2D_LayerCfg
->CLUTSize
= 0x0U
;
363 DMA2D_LayerCfg
->AlphaMode
= LL_DMA2D_ALPHA_MODE_NO_MODIF
;
364 DMA2D_LayerCfg
->Alpha
= 0x0U
;
365 DMA2D_LayerCfg
->Blue
= 0x0U
;
366 DMA2D_LayerCfg
->Green
= 0x0U
;
367 DMA2D_LayerCfg
->Red
= 0x0U
;
368 DMA2D_LayerCfg
->CLUTMemoryAddress
= 0x0U
;
369 DMA2D_LayerCfg
->AlphaInversionMode
= LL_DMA2D_ALPHA_REGULAR
;
370 DMA2D_LayerCfg
->RBSwapMode
= LL_DMA2D_RB_MODE_REGULAR
;
371 DMA2D_LayerCfg
->ChromaSubSampling
= LL_DMA2D_CSS_444
;
375 * @brief Initialize DMA2D output color register according to the specified parameters
376 * in DMA2D_ColorStruct.
377 * @param DMA2Dx DMA2D Instance
378 * @param DMA2D_ColorStruct pointer to a LL_DMA2D_ColorTypeDef structure that contains
379 * the color configuration information for the specified DMA2D peripheral.
382 void LL_DMA2D_ConfigOutputColor(DMA2D_TypeDef
*DMA2Dx
, LL_DMA2D_ColorTypeDef
*DMA2D_ColorStruct
)
388 /* Check the parameters */
389 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
390 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_ColorStruct
->ColorMode
));
391 assert_param(IS_LL_DMA2D_GREEN(DMA2D_ColorStruct
->OutputGreen
));
392 assert_param(IS_LL_DMA2D_RED(DMA2D_ColorStruct
->OutputRed
));
393 assert_param(IS_LL_DMA2D_BLUE(DMA2D_ColorStruct
->OutputBlue
));
394 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_ColorStruct
->OutputAlpha
));
396 /* DMA2D OCOLR register configuration ------------------------------------------*/
397 if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
399 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 8U;
400 outred
= DMA2D_ColorStruct
->OutputRed
<< 16U;
401 outalpha
= DMA2D_ColorStruct
->OutputAlpha
<< 24U;
403 else if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
405 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 8U;
406 outred
= DMA2D_ColorStruct
->OutputRed
<< 16U;
407 outalpha
= 0x00000000U
;
409 else if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
411 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 5U;
412 outred
= DMA2D_ColorStruct
->OutputRed
<< 11U;
413 outalpha
= 0x00000000U
;
415 else if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
417 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 5U;
418 outred
= DMA2D_ColorStruct
->OutputRed
<< 10U;
419 outalpha
= DMA2D_ColorStruct
->OutputAlpha
<< 15U;
421 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
423 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 4U;
424 outred
= DMA2D_ColorStruct
->OutputRed
<< 8U;
425 outalpha
= DMA2D_ColorStruct
->OutputAlpha
<< 12U;
427 LL_DMA2D_SetOutputColor(DMA2Dx
, (outgreen
| outred
| DMA2D_ColorStruct
->OutputBlue
| outalpha
));
431 * @brief Return DMA2D output Blue color.
432 * @param DMA2Dx DMA2D Instance.
433 * @param ColorMode This parameter can be one of the following values:
434 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
435 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
436 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
437 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
438 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
439 * @retval Output Blue color value between Min_Data=0 and Max_Data=0xFF
441 uint32_t LL_DMA2D_GetOutputBlueColor(const DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
445 /* Check the parameters */
446 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
447 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
449 /* DMA2D OCOLR register reading ------------------------------------------*/
450 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
452 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFFU
));
454 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
456 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFFU
));
458 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
460 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x1FU
));
462 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
464 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x1FU
));
466 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
468 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFU
));
475 * @brief Return DMA2D output Green color.
476 * @param DMA2Dx DMA2D Instance.
477 * @param ColorMode This parameter can be one of the following values:
478 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
479 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
480 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
481 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
482 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
483 * @retval Output Green color value between Min_Data=0 and Max_Data=0xFF
485 uint32_t LL_DMA2D_GetOutputGreenColor(const DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
489 /* Check the parameters */
490 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
491 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
493 /* DMA2D OCOLR register reading ------------------------------------------*/
494 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
496 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF00U
) >> 8U);
498 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
500 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF00U
) >> 8U);
502 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
504 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x7E0U
) >> 5U);
506 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
508 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x3E0U
) >> 5U);
510 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
512 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF0U
) >> 4U);
519 * @brief Return DMA2D output Red color.
520 * @param DMA2Dx DMA2D Instance.
521 * @param ColorMode This parameter can be one of the following values:
522 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
523 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
524 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
525 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
526 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
527 * @retval Output Red color value between Min_Data=0 and Max_Data=0xFF
529 uint32_t LL_DMA2D_GetOutputRedColor(const DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
533 /* Check the parameters */
534 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
535 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
537 /* DMA2D OCOLR register reading ------------------------------------------*/
538 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
540 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF0000U
) >> 16U);
542 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
544 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF0000U
) >> 16U);
546 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
548 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF800U
) >> 11U);
550 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
552 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x7C00U
) >> 10U);
554 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
556 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF00U
) >> 8U);
563 * @brief Return DMA2D output Alpha color.
564 * @param DMA2Dx DMA2D Instance.
565 * @param ColorMode This parameter can be one of the following values:
566 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
567 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
568 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
569 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
570 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
571 * @retval Output Alpha color value between Min_Data=0 and Max_Data=0xFF
573 uint32_t LL_DMA2D_GetOutputAlphaColor(const DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
577 /* Check the parameters */
578 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
579 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
581 /* DMA2D OCOLR register reading ------------------------------------------*/
582 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
584 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF000000U
) >> 24U);
586 else if ((ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
) || (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
))
590 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
592 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x8000U
) >> 15U);
594 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
596 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF000U
) >> 12U);
603 * @brief Configure DMA2D transfer size.
604 * @param DMA2Dx DMA2D Instance
605 * @param NbrOfLines Value between Min_Data=0 and Max_Data=0xFFFF
606 * @param NbrOfPixelsPerLines Value between Min_Data=0 and Max_Data=0x3FFF
609 void LL_DMA2D_ConfigSize(DMA2D_TypeDef
*DMA2Dx
, uint32_t NbrOfLines
, uint32_t NbrOfPixelsPerLines
)
611 MODIFY_REG(DMA2Dx
->NLR
, (DMA2D_NLR_PL
| DMA2D_NLR_NL
), \
612 ((NbrOfPixelsPerLines
<< DMA2D_NLR_PL_Pos
) | NbrOfLines
));
627 #endif /* defined (DMA2D) */
633 #endif /* USE_FULL_LL_DRIVER */