2 ******************************************************************************
3 * @file stm32h7xx_ll_dma2d.c
4 * @author MCD Application Team
5 * @brief DMA2D LL module driver.
6 ******************************************************************************
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
19 #if defined(USE_FULL_LL_DRIVER)
21 /* Includes ------------------------------------------------------------------*/
22 #include "stm32h7xx_ll_dma2d.h"
23 #include "stm32h7xx_ll_bus.h"
24 #ifdef USE_FULL_ASSERT
25 #include "stm32_assert.h"
27 #define assert_param(expr) ((void)0U)
30 /** @addtogroup STM32H7xx_LL_Driver
36 /** @addtogroup DMA2D_LL
40 /* Private types -------------------------------------------------------------*/
41 /* Private variables ---------------------------------------------------------*/
42 /* Private constants ---------------------------------------------------------*/
43 /** @addtogroup DMA2D_LL_Private_Constants DMA2D Private Constants
46 #define LL_DMA2D_COLOR 0xFFU /*!< Maximum output color setting */
47 #define LL_DMA2D_NUMBEROFLINES DMA2D_NLR_NL /*!< Maximum number of lines */
48 #define LL_DMA2D_NUMBEROFPIXELS (DMA2D_NLR_PL >> DMA2D_NLR_PL_Pos) /*!< Maximum number of pixels per lines */
49 #define LL_DMA2D_OFFSET_MAX 0x3FFFU /*!< Maximum output line offset expressed in pixels */
50 #define LL_DMA2D_CLUTSIZE_MAX 0xFFU /*!< Maximum CLUT size */
54 /* Private macros ------------------------------------------------------------*/
55 /** @addtogroup DMA2D_LL_Private_Macros
58 #define IS_LL_DMA2D_MODE(MODE) (((MODE) == LL_DMA2D_MODE_M2M) || \
59 ((MODE) == LL_DMA2D_MODE_M2M_PFC) || \
60 ((MODE) == LL_DMA2D_MODE_M2M_BLEND) || \
61 ((MODE) == LL_DMA2D_MODE_M2M_BLEND_FIXED_COLOR_FG) || \
62 ((MODE) == LL_DMA2D_MODE_M2M_BLEND_FIXED_COLOR_BG) || \
63 ((MODE) == LL_DMA2D_MODE_R2M))
65 #define IS_LL_DMA2D_OCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB8888) || \
66 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB888) || \
67 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB565) || \
68 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB1555) || \
69 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB4444))
71 #define IS_LL_DMA2D_GREEN(GREEN) ((GREEN) <= LL_DMA2D_COLOR)
72 #define IS_LL_DMA2D_RED(RED) ((RED) <= LL_DMA2D_COLOR)
73 #define IS_LL_DMA2D_BLUE(BLUE) ((BLUE) <= LL_DMA2D_COLOR)
74 #define IS_LL_DMA2D_ALPHA(ALPHA) ((ALPHA) <= LL_DMA2D_COLOR)
76 #define IS_LL_DMA2D_OFFSET_MODE(MODE) (((MODE) == LL_DMA2D_LINE_OFFSET_PIXELS) || \
77 ((MODE) == LL_DMA2D_LINE_OFFSET_BYTES))
79 #define IS_LL_DMA2D_OFFSET(OFFSET) ((OFFSET) <= LL_DMA2D_OFFSET_MAX)
81 #define IS_LL_DMA2D_LINE(LINES) ((LINES) <= LL_DMA2D_NUMBEROFLINES)
82 #define IS_LL_DMA2D_PIXEL(PIXELS) ((PIXELS) <= LL_DMA2D_NUMBEROFPIXELS)
84 #define IS_LL_DMA2D_SWAP_MODE(MODE) (((MODE) == LL_DMA2D_SWAP_MODE_REGULAR) || \
85 ((MODE) == LL_DMA2D_SWAP_MODE_TWO_BY_TWO))
87 #define IS_LL_DMA2D_ALPHAINV(ALPHA) (((ALPHA) == LL_DMA2D_ALPHA_REGULAR) || \
88 ((ALPHA) == LL_DMA2D_ALPHA_INVERTED))
90 #define IS_LL_DMA2D_RBSWAP(RBSWAP) (((RBSWAP) == LL_DMA2D_RB_MODE_REGULAR) || \
91 ((RBSWAP) == LL_DMA2D_RB_MODE_SWAP))
93 #define IS_LL_DMA2D_LCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB8888) || \
94 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB888) || \
95 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB565) || \
96 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB1555) || \
97 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB4444) || \
98 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L8) || \
99 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL44) || \
100 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL88) || \
101 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L4) || \
102 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A8) || \
103 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A4))
105 #define IS_LL_DMA2D_CLUTCMODE(CLUTCMODE) (((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_ARGB8888) || \
106 ((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_RGB888))
108 #define IS_LL_DMA2D_CLUTSIZE(SIZE) ((SIZE) <= LL_DMA2D_CLUTSIZE_MAX)
110 #define IS_LL_DMA2D_ALPHAMODE(MODE) (((MODE) == LL_DMA2D_ALPHA_MODE_NO_MODIF) || \
111 ((MODE) == LL_DMA2D_ALPHA_MODE_REPLACE) || \
112 ((MODE) == LL_DMA2D_ALPHA_MODE_COMBINE))
114 #define IS_LL_DMA2D_CHROMA_SUB_SAMPLING(CSS) (((CSS) == LL_DMA2D_CSS_444) || \
115 ((CSS) == LL_DMA2D_CSS_422) || \
116 ((CSS) == LL_DMA2D_CSS_420))
122 /* Private function prototypes -----------------------------------------------*/
124 /* Exported functions --------------------------------------------------------*/
125 /** @addtogroup DMA2D_LL_Exported_Functions
129 /** @addtogroup DMA2D_LL_EF_Init_Functions Initialization and De-initialization Functions
134 * @brief De-initialize DMA2D registers (registers restored to their default values).
135 * @param DMA2Dx DMA2D Instance
136 * @retval An ErrorStatus enumeration value:
137 * - SUCCESS: DMA2D registers are de-initialized
138 * - ERROR: DMA2D registers are not de-initialized
140 ErrorStatus
LL_DMA2D_DeInit(DMA2D_TypeDef
*DMA2Dx
)
142 ErrorStatus status
= SUCCESS
;
144 /* Check the parameters */
145 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
149 /* Force reset of DMA2D clock */
150 LL_AHB3_GRP1_ForceReset(LL_AHB3_GRP1_PERIPH_DMA2D
);
152 /* Release reset of DMA2D clock */
153 LL_AHB3_GRP1_ReleaseReset(LL_AHB3_GRP1_PERIPH_DMA2D
);
165 * @brief Initialize DMA2D registers according to the specified parameters in DMA2D_InitStruct.
166 * @note DMA2D transfers must be disabled to set initialization bits in configuration registers,
167 * otherwise ERROR result is returned.
168 * @param DMA2Dx DMA2D Instance
169 * @param DMA2D_InitStruct pointer to a LL_DMA2D_InitTypeDef structure
170 * that contains the configuration information for the specified DMA2D peripheral.
171 * @retval An ErrorStatus enumeration value:
172 * - SUCCESS: DMA2D registers are initialized according to DMA2D_InitStruct content
173 * - ERROR: Issue occurred during DMA2D registers initialization
175 ErrorStatus
LL_DMA2D_Init(DMA2D_TypeDef
*DMA2Dx
, LL_DMA2D_InitTypeDef
*DMA2D_InitStruct
)
177 ErrorStatus status
= ERROR
;
178 LL_DMA2D_ColorTypeDef DMA2D_ColorStruct
;
179 uint32_t tmp
, tmp1
, tmp2
;
180 uint32_t regMask
, regValue
;
182 /* Check the parameters */
183 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
184 assert_param(IS_LL_DMA2D_MODE(DMA2D_InitStruct
->Mode
));
185 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_InitStruct
->ColorMode
));
186 assert_param(IS_LL_DMA2D_LINE(DMA2D_InitStruct
->NbrOfLines
));
187 assert_param(IS_LL_DMA2D_PIXEL(DMA2D_InitStruct
->NbrOfPixelsPerLines
));
188 assert_param(IS_LL_DMA2D_GREEN(DMA2D_InitStruct
->OutputGreen
));
189 assert_param(IS_LL_DMA2D_RED(DMA2D_InitStruct
->OutputRed
));
190 assert_param(IS_LL_DMA2D_BLUE(DMA2D_InitStruct
->OutputBlue
));
191 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_InitStruct
->OutputAlpha
));
192 assert_param(IS_LL_DMA2D_SWAP_MODE(DMA2D_InitStruct
->OutputSwapMode
));
193 assert_param(IS_LL_DMA2D_OFFSET_MODE(DMA2D_InitStruct
->LineOffsetMode
));
194 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_InitStruct
->LineOffset
));
195 assert_param(IS_LL_DMA2D_ALPHAINV(DMA2D_InitStruct
->AlphaInversionMode
));
196 assert_param(IS_LL_DMA2D_RBSWAP(DMA2D_InitStruct
->RBSwapMode
));
198 /* DMA2D transfers must be disabled to configure bits in initialization registers */
199 tmp
= LL_DMA2D_IsTransferOngoing(DMA2Dx
);
200 tmp1
= LL_DMA2D_FGND_IsEnabledCLUTLoad(DMA2Dx
);
201 tmp2
= LL_DMA2D_BGND_IsEnabledCLUTLoad(DMA2Dx
);
202 if ((tmp
== 0U) && (tmp1
== 0U) && (tmp2
== 0U))
204 /* DMA2D CR register configuration -------------------------------------------*/
205 MODIFY_REG(DMA2Dx
->CR
, (DMA2D_CR_MODE
| DMA2D_CR_LOM
), \
206 (DMA2D_InitStruct
->Mode
| DMA2D_InitStruct
->LineOffsetMode
));
208 /* DMA2D OPFCCR register configuration ---------------------------------------*/
209 regMask
= DMA2D_OPFCCR_CM
;
210 regValue
= DMA2D_InitStruct
->ColorMode
;
212 regMask
|= DMA2D_OPFCCR_SB
;
213 regValue
|= DMA2D_InitStruct
->OutputSwapMode
;
215 regMask
|= (DMA2D_OPFCCR_RBS
| DMA2D_OPFCCR_AI
);
216 regValue
|= (DMA2D_InitStruct
->AlphaInversionMode
| DMA2D_InitStruct
->RBSwapMode
);
219 MODIFY_REG(DMA2Dx
->OPFCCR
, regMask
, regValue
);
221 /* DMA2D OOR register configuration ------------------------------------------*/
222 LL_DMA2D_SetLineOffset(DMA2Dx
, DMA2D_InitStruct
->LineOffset
);
224 /* DMA2D NLR register configuration ------------------------------------------*/
225 LL_DMA2D_ConfigSize(DMA2Dx
, DMA2D_InitStruct
->NbrOfLines
, DMA2D_InitStruct
->NbrOfPixelsPerLines
);
227 /* DMA2D OMAR register configuration ------------------------------------------*/
228 LL_DMA2D_SetOutputMemAddr(DMA2Dx
, DMA2D_InitStruct
->OutputMemoryAddress
);
230 /* DMA2D OCOLR register configuration ------------------------------------------*/
231 DMA2D_ColorStruct
.ColorMode
= DMA2D_InitStruct
->ColorMode
;
232 DMA2D_ColorStruct
.OutputBlue
= DMA2D_InitStruct
->OutputBlue
;
233 DMA2D_ColorStruct
.OutputGreen
= DMA2D_InitStruct
->OutputGreen
;
234 DMA2D_ColorStruct
.OutputRed
= DMA2D_InitStruct
->OutputRed
;
235 DMA2D_ColorStruct
.OutputAlpha
= DMA2D_InitStruct
->OutputAlpha
;
236 LL_DMA2D_ConfigOutputColor(DMA2Dx
, &DMA2D_ColorStruct
);
240 /* If DMA2D transfers are not disabled, return ERROR */
246 * @brief Set each @ref LL_DMA2D_InitTypeDef field to default value.
247 * @param DMA2D_InitStruct pointer to a @ref LL_DMA2D_InitTypeDef structure
248 * whose fields will be set to default values.
251 void LL_DMA2D_StructInit(LL_DMA2D_InitTypeDef
*DMA2D_InitStruct
)
253 /* Set DMA2D_InitStruct fields to default values */
254 DMA2D_InitStruct
->Mode
= LL_DMA2D_MODE_M2M
;
255 DMA2D_InitStruct
->ColorMode
= LL_DMA2D_OUTPUT_MODE_ARGB8888
;
256 DMA2D_InitStruct
->NbrOfLines
= 0x0U
;
257 DMA2D_InitStruct
->NbrOfPixelsPerLines
= 0x0U
;
258 DMA2D_InitStruct
->LineOffsetMode
= LL_DMA2D_LINE_OFFSET_PIXELS
;
259 DMA2D_InitStruct
->LineOffset
= 0x0U
;
260 DMA2D_InitStruct
->OutputBlue
= 0x0U
;
261 DMA2D_InitStruct
->OutputGreen
= 0x0U
;
262 DMA2D_InitStruct
->OutputRed
= 0x0U
;
263 DMA2D_InitStruct
->OutputAlpha
= 0x0U
;
264 DMA2D_InitStruct
->OutputMemoryAddress
= 0x0U
;
265 DMA2D_InitStruct
->OutputSwapMode
= LL_DMA2D_SWAP_MODE_REGULAR
;
266 DMA2D_InitStruct
->AlphaInversionMode
= LL_DMA2D_ALPHA_REGULAR
;
267 DMA2D_InitStruct
->RBSwapMode
= LL_DMA2D_RB_MODE_REGULAR
;
271 * @brief Configure the foreground or background according to the specified parameters
272 * in the LL_DMA2D_LayerCfgTypeDef structure.
273 * @param DMA2Dx DMA2D Instance
274 * @param DMA2D_LayerCfg pointer to a LL_DMA2D_LayerCfgTypeDef structure that contains
275 * the configuration information for the specified layer.
276 * @param LayerIdx DMA2D Layer index.
277 * This parameter can be one of the following values:
278 * 0(background) / 1(foreground)
281 void LL_DMA2D_ConfigLayer(DMA2D_TypeDef
*DMA2Dx
, LL_DMA2D_LayerCfgTypeDef
*DMA2D_LayerCfg
, uint32_t LayerIdx
)
283 /* Check the parameters */
284 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_LayerCfg
->LineOffset
));
285 assert_param(IS_LL_DMA2D_LCMODE(DMA2D_LayerCfg
->ColorMode
));
286 assert_param(IS_LL_DMA2D_CLUTCMODE(DMA2D_LayerCfg
->CLUTColorMode
));
287 assert_param(IS_LL_DMA2D_CLUTSIZE(DMA2D_LayerCfg
->CLUTSize
));
288 assert_param(IS_LL_DMA2D_ALPHAMODE(DMA2D_LayerCfg
->AlphaMode
));
289 assert_param(IS_LL_DMA2D_GREEN(DMA2D_LayerCfg
->Green
));
290 assert_param(IS_LL_DMA2D_RED(DMA2D_LayerCfg
->Red
));
291 assert_param(IS_LL_DMA2D_BLUE(DMA2D_LayerCfg
->Blue
));
292 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_LayerCfg
->Alpha
));
293 assert_param(IS_LL_DMA2D_ALPHAINV(DMA2D_LayerCfg
->AlphaInversionMode
));
294 assert_param(IS_LL_DMA2D_RBSWAP(DMA2D_LayerCfg
->RBSwapMode
));
295 assert_param(IS_LL_DMA2D_CHROMA_SUB_SAMPLING(DMA2D_LayerCfg
->ChromaSubSampling
));
300 /* Configure the background memory address */
301 LL_DMA2D_BGND_SetMemAddr(DMA2Dx
, DMA2D_LayerCfg
->MemoryAddress
);
303 /* Configure the background line offset */
304 LL_DMA2D_BGND_SetLineOffset(DMA2Dx
, DMA2D_LayerCfg
->LineOffset
);
306 /* Configure the background Alpha value, Alpha mode, RB swap, Alpha inversion
307 CLUT size, CLUT Color mode and Color mode */
308 MODIFY_REG(DMA2Dx
->BGPFCCR
, \
309 (DMA2D_BGPFCCR_ALPHA
| DMA2D_BGPFCCR_RBS
| DMA2D_BGPFCCR_AI
| DMA2D_BGPFCCR_AM
| \
310 DMA2D_BGPFCCR_CS
| DMA2D_BGPFCCR_CCM
| DMA2D_BGPFCCR_CM
), \
311 ((DMA2D_LayerCfg
->Alpha
<< DMA2D_BGPFCCR_ALPHA_Pos
) | DMA2D_LayerCfg
->RBSwapMode
| \
312 DMA2D_LayerCfg
->AlphaInversionMode
| DMA2D_LayerCfg
->AlphaMode
| \
313 (DMA2D_LayerCfg
->CLUTSize
<< DMA2D_BGPFCCR_CS_Pos
) | DMA2D_LayerCfg
->CLUTColorMode
| \
314 DMA2D_LayerCfg
->ColorMode
));
316 /* Configure the background color */
317 LL_DMA2D_BGND_SetColor(DMA2Dx
, DMA2D_LayerCfg
->Red
, DMA2D_LayerCfg
->Green
, DMA2D_LayerCfg
->Blue
);
319 /* Configure the background CLUT memory address */
320 LL_DMA2D_BGND_SetCLUTMemAddr(DMA2Dx
, DMA2D_LayerCfg
->CLUTMemoryAddress
);
324 /* Configure the foreground memory address */
325 LL_DMA2D_FGND_SetMemAddr(DMA2Dx
, DMA2D_LayerCfg
->MemoryAddress
);
327 /* Configure the foreground line offset */
328 LL_DMA2D_FGND_SetLineOffset(DMA2Dx
, DMA2D_LayerCfg
->LineOffset
);
330 /* Configure the foreground Alpha value, Alpha mode, RB swap, Alpha inversion
331 CLUT size, CLUT Color mode and Color mode */
332 MODIFY_REG(DMA2Dx
->FGPFCCR
, \
333 (DMA2D_FGPFCCR_ALPHA
| DMA2D_FGPFCCR_RBS
| DMA2D_FGPFCCR_AI
| DMA2D_FGPFCCR_CSS
| DMA2D_FGPFCCR_AM
| \
334 DMA2D_FGPFCCR_CS
| DMA2D_FGPFCCR_CCM
| DMA2D_FGPFCCR_CM
), \
335 ((DMA2D_LayerCfg
->Alpha
<< DMA2D_FGPFCCR_ALPHA_Pos
) | DMA2D_LayerCfg
->RBSwapMode
| \
336 DMA2D_LayerCfg
->AlphaInversionMode
| DMA2D_LayerCfg
->ChromaSubSampling
| \
337 DMA2D_LayerCfg
->AlphaMode
| (DMA2D_LayerCfg
->CLUTSize
<< DMA2D_FGPFCCR_CS_Pos
) | \
338 DMA2D_LayerCfg
->CLUTColorMode
| DMA2D_LayerCfg
->ColorMode
));
340 /* Configure the foreground color */
341 LL_DMA2D_FGND_SetColor(DMA2Dx
, DMA2D_LayerCfg
->Red
, DMA2D_LayerCfg
->Green
, DMA2D_LayerCfg
->Blue
);
343 /* Configure the foreground CLUT memory address */
344 LL_DMA2D_FGND_SetCLUTMemAddr(DMA2Dx
, DMA2D_LayerCfg
->CLUTMemoryAddress
);
349 * @brief Set each @ref LL_DMA2D_LayerCfgTypeDef field to default value.
350 * @param DMA2D_LayerCfg pointer to a @ref LL_DMA2D_LayerCfgTypeDef structure
351 * whose fields will be set to default values.
354 void LL_DMA2D_LayerCfgStructInit(LL_DMA2D_LayerCfgTypeDef
*DMA2D_LayerCfg
)
356 /* Set DMA2D_LayerCfg fields to default values */
357 DMA2D_LayerCfg
->MemoryAddress
= 0x0U
;
358 DMA2D_LayerCfg
->ColorMode
= LL_DMA2D_INPUT_MODE_ARGB8888
;
359 DMA2D_LayerCfg
->LineOffset
= 0x0U
;
360 DMA2D_LayerCfg
->CLUTColorMode
= LL_DMA2D_CLUT_COLOR_MODE_ARGB8888
;
361 DMA2D_LayerCfg
->CLUTSize
= 0x0U
;
362 DMA2D_LayerCfg
->AlphaMode
= LL_DMA2D_ALPHA_MODE_NO_MODIF
;
363 DMA2D_LayerCfg
->Alpha
= 0x0U
;
364 DMA2D_LayerCfg
->Blue
= 0x0U
;
365 DMA2D_LayerCfg
->Green
= 0x0U
;
366 DMA2D_LayerCfg
->Red
= 0x0U
;
367 DMA2D_LayerCfg
->CLUTMemoryAddress
= 0x0U
;
368 DMA2D_LayerCfg
->AlphaInversionMode
= LL_DMA2D_ALPHA_REGULAR
;
369 DMA2D_LayerCfg
->RBSwapMode
= LL_DMA2D_RB_MODE_REGULAR
;
370 DMA2D_LayerCfg
->ChromaSubSampling
= LL_DMA2D_CSS_444
;
374 * @brief Initialize DMA2D output color register according to the specified parameters
375 * in DMA2D_ColorStruct.
376 * @param DMA2Dx DMA2D Instance
377 * @param DMA2D_ColorStruct pointer to a LL_DMA2D_ColorTypeDef structure that contains
378 * the color configuration information for the specified DMA2D peripheral.
381 void LL_DMA2D_ConfigOutputColor(DMA2D_TypeDef
*DMA2Dx
, LL_DMA2D_ColorTypeDef
*DMA2D_ColorStruct
)
387 /* Check the parameters */
388 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
389 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_ColorStruct
->ColorMode
));
390 assert_param(IS_LL_DMA2D_GREEN(DMA2D_ColorStruct
->OutputGreen
));
391 assert_param(IS_LL_DMA2D_RED(DMA2D_ColorStruct
->OutputRed
));
392 assert_param(IS_LL_DMA2D_BLUE(DMA2D_ColorStruct
->OutputBlue
));
393 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_ColorStruct
->OutputAlpha
));
395 /* DMA2D OCOLR register configuration ------------------------------------------*/
396 if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
398 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 8U;
399 outred
= DMA2D_ColorStruct
->OutputRed
<< 16U;
400 outalpha
= DMA2D_ColorStruct
->OutputAlpha
<< 24U;
402 else if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
404 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 8U;
405 outred
= DMA2D_ColorStruct
->OutputRed
<< 16U;
406 outalpha
= 0x00000000U
;
408 else if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
410 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 5U;
411 outred
= DMA2D_ColorStruct
->OutputRed
<< 11U;
412 outalpha
= 0x00000000U
;
414 else if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
416 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 5U;
417 outred
= DMA2D_ColorStruct
->OutputRed
<< 10U;
418 outalpha
= DMA2D_ColorStruct
->OutputAlpha
<< 15U;
420 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
422 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 4U;
423 outred
= DMA2D_ColorStruct
->OutputRed
<< 8U;
424 outalpha
= DMA2D_ColorStruct
->OutputAlpha
<< 12U;
426 LL_DMA2D_SetOutputColor(DMA2Dx
, (outgreen
| outred
| DMA2D_ColorStruct
->OutputBlue
| outalpha
));
430 * @brief Return DMA2D output Blue color.
431 * @param DMA2Dx DMA2D Instance.
432 * @param ColorMode This parameter can be one of the following values:
433 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
434 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
435 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
436 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
437 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
438 * @retval Output Blue color value between Min_Data=0 and Max_Data=0xFF
440 uint32_t LL_DMA2D_GetOutputBlueColor(DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
444 /* Check the parameters */
445 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
446 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
448 /* DMA2D OCOLR register reading ------------------------------------------*/
449 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
451 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFFU
));
453 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
455 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFFU
));
457 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
459 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x1FU
));
461 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
463 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x1FU
));
465 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
467 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFU
));
474 * @brief Return DMA2D output Green color.
475 * @param DMA2Dx DMA2D Instance.
476 * @param ColorMode This parameter can be one of the following values:
477 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
478 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
479 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
480 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
481 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
482 * @retval Output Green color value between Min_Data=0 and Max_Data=0xFF
484 uint32_t LL_DMA2D_GetOutputGreenColor(DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
488 /* Check the parameters */
489 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
490 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
492 /* DMA2D OCOLR register reading ------------------------------------------*/
493 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
495 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF00U
) >> 8U);
497 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
499 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF00U
) >> 8U);
501 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
503 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x7E0U
) >> 5U);
505 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
507 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x3E0U
) >> 5U);
509 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
511 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF0U
) >> 4U);
518 * @brief Return DMA2D output Red color.
519 * @param DMA2Dx DMA2D Instance.
520 * @param ColorMode This parameter can be one of the following values:
521 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
522 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
523 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
524 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
525 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
526 * @retval Output Red color value between Min_Data=0 and Max_Data=0xFF
528 uint32_t LL_DMA2D_GetOutputRedColor(DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
532 /* Check the parameters */
533 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
534 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
536 /* DMA2D OCOLR register reading ------------------------------------------*/
537 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
539 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF0000U
) >> 16U);
541 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
543 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF0000U
) >> 16U);
545 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
547 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF800U
) >> 11U);
549 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
551 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x7C00U
) >> 10U);
553 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
555 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF00U
) >> 8U);
562 * @brief Return DMA2D output Alpha color.
563 * @param DMA2Dx DMA2D Instance.
564 * @param ColorMode This parameter can be one of the following values:
565 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
566 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
567 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
568 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
569 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
570 * @retval Output Alpha color value between Min_Data=0 and Max_Data=0xFF
572 uint32_t LL_DMA2D_GetOutputAlphaColor(DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
576 /* Check the parameters */
577 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
578 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
580 /* DMA2D OCOLR register reading ------------------------------------------*/
581 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
583 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF000000U
) >> 24U);
585 else if ((ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
) || (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
))
589 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
591 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x8000U
) >> 15U);
593 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
595 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF000U
) >> 12U);
602 * @brief Configure DMA2D transfer size.
603 * @param DMA2Dx DMA2D Instance
604 * @param NbrOfLines Value between Min_Data=0 and Max_Data=0xFFFF
605 * @param NbrOfPixelsPerLines Value between Min_Data=0 and Max_Data=0x3FFF
608 void LL_DMA2D_ConfigSize(DMA2D_TypeDef
*DMA2Dx
, uint32_t NbrOfLines
, uint32_t NbrOfPixelsPerLines
)
610 MODIFY_REG(DMA2Dx
->NLR
, (DMA2D_NLR_PL
| DMA2D_NLR_NL
), \
611 ((NbrOfPixelsPerLines
<< DMA2D_NLR_PL_Pos
) | NbrOfLines
));
626 #endif /* defined (DMA2D) */
632 #endif /* USE_FULL_LL_DRIVER */
634 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/