2 ******************************************************************************
3 * @file stm32f7xx_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 "stm32f7xx_ll_dma2d.h"
23 #include "stm32f7xx_ll_bus.h"
24 #ifdef USE_FULL_ASSERT
25 #include "stm32_assert.h"
27 #define assert_param(expr) ((void)0U)
30 /** @addtogroup STM32F7xx_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_R2M))
63 #define IS_LL_DMA2D_OCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB8888) || \
64 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB888) || \
65 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB565) || \
66 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB1555) || \
67 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB4444))
69 #define IS_LL_DMA2D_GREEN(GREEN) ((GREEN) <= LL_DMA2D_COLOR)
70 #define IS_LL_DMA2D_RED(RED) ((RED) <= LL_DMA2D_COLOR)
71 #define IS_LL_DMA2D_BLUE(BLUE) ((BLUE) <= LL_DMA2D_COLOR)
72 #define IS_LL_DMA2D_ALPHA(ALPHA) ((ALPHA) <= LL_DMA2D_COLOR)
75 #define IS_LL_DMA2D_OFFSET(OFFSET) ((OFFSET) <= LL_DMA2D_OFFSET_MAX)
77 #define IS_LL_DMA2D_LINE(LINES) ((LINES) <= LL_DMA2D_NUMBEROFLINES)
78 #define IS_LL_DMA2D_PIXEL(PIXELS) ((PIXELS) <= LL_DMA2D_NUMBEROFPIXELS)
81 #if defined (DMA2D_ALPHA_INV_RB_SWAP_SUPPORT)
82 #define IS_LL_DMA2D_ALPHAINV(ALPHA) (((ALPHA) == LL_DMA2D_ALPHA_REGULAR) || \
83 ((ALPHA) == LL_DMA2D_ALPHA_INVERTED))
85 #define IS_LL_DMA2D_RBSWAP(RBSWAP) (((RBSWAP) == LL_DMA2D_RB_MODE_REGULAR) || \
86 ((RBSWAP) == LL_DMA2D_RB_MODE_SWAP))
87 #endif /* DMA2D_ALPHA_INV_RB_SWAP_SUPPORT */
89 #define IS_LL_DMA2D_LCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB8888) || \
90 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB888) || \
91 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB565) || \
92 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB1555) || \
93 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB4444) || \
94 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L8) || \
95 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL44) || \
96 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL88) || \
97 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L4) || \
98 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A8) || \
99 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A4))
101 #define IS_LL_DMA2D_CLUTCMODE(CLUTCMODE) (((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_ARGB8888) || \
102 ((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_RGB888))
104 #define IS_LL_DMA2D_CLUTSIZE(SIZE) ((SIZE) <= LL_DMA2D_CLUTSIZE_MAX)
106 #define IS_LL_DMA2D_ALPHAMODE(MODE) (((MODE) == LL_DMA2D_ALPHA_MODE_NO_MODIF) || \
107 ((MODE) == LL_DMA2D_ALPHA_MODE_REPLACE) || \
108 ((MODE) == LL_DMA2D_ALPHA_MODE_COMBINE))
115 /* Private function prototypes -----------------------------------------------*/
117 /* Exported functions --------------------------------------------------------*/
118 /** @addtogroup DMA2D_LL_Exported_Functions
122 /** @addtogroup DMA2D_LL_EF_Init_Functions Initialization and De-initialization Functions
127 * @brief De-initialize DMA2D registers (registers restored to their default values).
128 * @param DMA2Dx DMA2D Instance
129 * @retval An ErrorStatus enumeration value:
130 * - SUCCESS: DMA2D registers are de-initialized
131 * - ERROR: DMA2D registers are not de-initialized
133 ErrorStatus
LL_DMA2D_DeInit(DMA2D_TypeDef
*DMA2Dx
)
135 ErrorStatus status
= SUCCESS
;
137 /* Check the parameters */
138 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
142 /* Force reset of DMA2D clock */
143 LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_DMA2D
);
145 /* Release reset of DMA2D clock */
146 LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_DMA2D
);
157 * @brief Initialize DMA2D registers according to the specified parameters in DMA2D_InitStruct.
158 * @note DMA2D transfers must be disabled to set initialization bits in configuration registers,
159 * otherwise ERROR result is returned.
160 * @param DMA2Dx DMA2D Instance
161 * @param DMA2D_InitStruct pointer to a LL_DMA2D_InitTypeDef structure
162 * that contains the configuration information for the specified DMA2D peripheral.
163 * @retval An ErrorStatus enumeration value:
164 * - SUCCESS: DMA2D registers are initialized according to DMA2D_InitStruct content
165 * - ERROR: Issue occurred during DMA2D registers initialization
167 ErrorStatus
LL_DMA2D_Init(DMA2D_TypeDef
*DMA2Dx
, LL_DMA2D_InitTypeDef
*DMA2D_InitStruct
)
169 ErrorStatus status
= ERROR
;
170 LL_DMA2D_ColorTypeDef DMA2D_ColorStruct
;
171 uint32_t tmp
, tmp1
, tmp2
;
172 uint32_t regMask
, regValue
;
174 /* Check the parameters */
175 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
176 assert_param(IS_LL_DMA2D_MODE(DMA2D_InitStruct
->Mode
));
177 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_InitStruct
->ColorMode
));
178 assert_param(IS_LL_DMA2D_LINE(DMA2D_InitStruct
->NbrOfLines
));
179 assert_param(IS_LL_DMA2D_PIXEL(DMA2D_InitStruct
->NbrOfPixelsPerLines
));
180 assert_param(IS_LL_DMA2D_GREEN(DMA2D_InitStruct
->OutputGreen
));
181 assert_param(IS_LL_DMA2D_RED(DMA2D_InitStruct
->OutputRed
));
182 assert_param(IS_LL_DMA2D_BLUE(DMA2D_InitStruct
->OutputBlue
));
183 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_InitStruct
->OutputAlpha
));
184 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_InitStruct
->LineOffset
));
185 #if defined (DMA2D_ALPHA_INV_RB_SWAP_SUPPORT)
186 assert_param(IS_LL_DMA2D_ALPHAINV(DMA2D_InitStruct
->AlphaInversionMode
));
187 assert_param(IS_LL_DMA2D_RBSWAP(DMA2D_InitStruct
->RBSwapMode
));
188 #endif /* DMA2D_ALPHA_INV_RB_SWAP_SUPPORT */
190 /* DMA2D transfers must be disabled to configure bits in initialization registers */
191 tmp
= LL_DMA2D_IsTransferOngoing(DMA2Dx
);
192 tmp1
= LL_DMA2D_FGND_IsEnabledCLUTLoad(DMA2Dx
);
193 tmp2
= LL_DMA2D_BGND_IsEnabledCLUTLoad(DMA2Dx
);
194 if ((tmp
== 0U) && (tmp1
== 0U) && (tmp2
== 0U))
196 /* DMA2D CR register configuration -------------------------------------------*/
197 LL_DMA2D_SetMode(DMA2Dx
, DMA2D_InitStruct
->Mode
);
199 /* DMA2D OPFCCR register configuration ---------------------------------------*/
200 regMask
= DMA2D_OPFCCR_CM
;
201 regValue
= DMA2D_InitStruct
->ColorMode
;
204 #if defined(DMA2D_ALPHA_INV_RB_SWAP_SUPPORT)
205 regMask
|= (DMA2D_OPFCCR_RBS
| DMA2D_OPFCCR_AI
);
206 regValue
|= (DMA2D_InitStruct
->AlphaInversionMode
| DMA2D_InitStruct
->RBSwapMode
);
207 #endif /* DMA2D_ALPHA_INV_RB_SWAP_SUPPORT */
210 MODIFY_REG(DMA2Dx
->OPFCCR
, regMask
, regValue
);
212 /* DMA2D OOR register configuration ------------------------------------------*/
213 LL_DMA2D_SetLineOffset(DMA2Dx
, DMA2D_InitStruct
->LineOffset
);
215 /* DMA2D NLR register configuration ------------------------------------------*/
216 LL_DMA2D_ConfigSize(DMA2Dx
, DMA2D_InitStruct
->NbrOfLines
, DMA2D_InitStruct
->NbrOfPixelsPerLines
);
218 /* DMA2D OMAR register configuration ------------------------------------------*/
219 LL_DMA2D_SetOutputMemAddr(DMA2Dx
, DMA2D_InitStruct
->OutputMemoryAddress
);
221 /* DMA2D OCOLR register configuration ------------------------------------------*/
222 DMA2D_ColorStruct
.ColorMode
= DMA2D_InitStruct
->ColorMode
;
223 DMA2D_ColorStruct
.OutputBlue
= DMA2D_InitStruct
->OutputBlue
;
224 DMA2D_ColorStruct
.OutputGreen
= DMA2D_InitStruct
->OutputGreen
;
225 DMA2D_ColorStruct
.OutputRed
= DMA2D_InitStruct
->OutputRed
;
226 DMA2D_ColorStruct
.OutputAlpha
= DMA2D_InitStruct
->OutputAlpha
;
227 LL_DMA2D_ConfigOutputColor(DMA2Dx
, &DMA2D_ColorStruct
);
231 /* If DMA2D transfers are not disabled, return ERROR */
237 * @brief Set each @ref LL_DMA2D_InitTypeDef field to default value.
238 * @param DMA2D_InitStruct pointer to a @ref LL_DMA2D_InitTypeDef structure
239 * whose fields will be set to default values.
242 void LL_DMA2D_StructInit(LL_DMA2D_InitTypeDef
*DMA2D_InitStruct
)
244 /* Set DMA2D_InitStruct fields to default values */
245 DMA2D_InitStruct
->Mode
= LL_DMA2D_MODE_M2M
;
246 DMA2D_InitStruct
->ColorMode
= LL_DMA2D_OUTPUT_MODE_ARGB8888
;
247 DMA2D_InitStruct
->NbrOfLines
= 0x0U
;
248 DMA2D_InitStruct
->NbrOfPixelsPerLines
= 0x0U
;
249 DMA2D_InitStruct
->LineOffset
= 0x0U
;
250 DMA2D_InitStruct
->OutputBlue
= 0x0U
;
251 DMA2D_InitStruct
->OutputGreen
= 0x0U
;
252 DMA2D_InitStruct
->OutputRed
= 0x0U
;
253 DMA2D_InitStruct
->OutputAlpha
= 0x0U
;
254 DMA2D_InitStruct
->OutputMemoryAddress
= 0x0U
;
255 #if defined(DMA2D_ALPHA_INV_RB_SWAP_SUPPORT)
256 DMA2D_InitStruct
->AlphaInversionMode
= LL_DMA2D_ALPHA_REGULAR
;
257 DMA2D_InitStruct
->RBSwapMode
= LL_DMA2D_RB_MODE_REGULAR
;
258 #endif /* DMA2D_ALPHA_INV_RB_SWAP_SUPPORT */
262 * @brief Configure the foreground or background according to the specified parameters
263 * in the LL_DMA2D_LayerCfgTypeDef structure.
264 * @param DMA2Dx DMA2D Instance
265 * @param DMA2D_LayerCfg pointer to a LL_DMA2D_LayerCfgTypeDef structure that contains
266 * the configuration information for the specified layer.
267 * @param LayerIdx DMA2D Layer index.
268 * This parameter can be one of the following values:
269 * 0(background) / 1(foreground)
272 void LL_DMA2D_ConfigLayer(DMA2D_TypeDef
*DMA2Dx
, LL_DMA2D_LayerCfgTypeDef
*DMA2D_LayerCfg
, uint32_t LayerIdx
)
274 /* Check the parameters */
275 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_LayerCfg
->LineOffset
));
276 assert_param(IS_LL_DMA2D_LCMODE(DMA2D_LayerCfg
->ColorMode
));
277 assert_param(IS_LL_DMA2D_CLUTCMODE(DMA2D_LayerCfg
->CLUTColorMode
));
278 assert_param(IS_LL_DMA2D_CLUTSIZE(DMA2D_LayerCfg
->CLUTSize
));
279 assert_param(IS_LL_DMA2D_ALPHAMODE(DMA2D_LayerCfg
->AlphaMode
));
280 assert_param(IS_LL_DMA2D_GREEN(DMA2D_LayerCfg
->Green
));
281 assert_param(IS_LL_DMA2D_RED(DMA2D_LayerCfg
->Red
));
282 assert_param(IS_LL_DMA2D_BLUE(DMA2D_LayerCfg
->Blue
));
283 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_LayerCfg
->Alpha
));
284 #if defined(DMA2D_ALPHA_INV_RB_SWAP_SUPPORT)
285 assert_param(IS_LL_DMA2D_ALPHAINV(DMA2D_LayerCfg
->AlphaInversionMode
));
286 assert_param(IS_LL_DMA2D_RBSWAP(DMA2D_LayerCfg
->RBSwapMode
));
287 #endif /* DMA2D_ALPHA_INV_RB_SWAP_SUPPORT */
292 /* Configure the background memory address */
293 LL_DMA2D_BGND_SetMemAddr(DMA2Dx
, DMA2D_LayerCfg
->MemoryAddress
);
295 /* Configure the background line offset */
296 LL_DMA2D_BGND_SetLineOffset(DMA2Dx
, DMA2D_LayerCfg
->LineOffset
);
298 #if defined(DMA2D_ALPHA_INV_RB_SWAP_SUPPORT)
299 /* Configure the background Alpha value, Alpha mode, RB swap, Alpha inversion
300 CLUT size, CLUT Color mode and Color mode */
301 MODIFY_REG(DMA2Dx
->BGPFCCR
, \
302 (DMA2D_BGPFCCR_ALPHA
| DMA2D_BGPFCCR_RBS
| DMA2D_BGPFCCR_AI
| DMA2D_BGPFCCR_AM
| \
303 DMA2D_BGPFCCR_CS
| DMA2D_BGPFCCR_CCM
| DMA2D_BGPFCCR_CM
), \
304 ((DMA2D_LayerCfg
->Alpha
<< DMA2D_BGPFCCR_ALPHA_Pos
) | DMA2D_LayerCfg
->RBSwapMode
| \
305 DMA2D_LayerCfg
->AlphaInversionMode
| DMA2D_LayerCfg
->AlphaMode
| \
306 (DMA2D_LayerCfg
->CLUTSize
<< DMA2D_BGPFCCR_CS_Pos
) | DMA2D_LayerCfg
->CLUTColorMode
| \
307 DMA2D_LayerCfg
->ColorMode
));
309 /* Configure the background Alpha value, Alpha mode, CLUT size, CLUT Color mode and Color mode */
310 MODIFY_REG(DMA2Dx
->BGPFCCR
, \
311 (DMA2D_BGPFCCR_ALPHA
| DMA2D_BGPFCCR_AM
| DMA2D_BGPFCCR_CS
| DMA2D_BGPFCCR_CCM
| DMA2D_BGPFCCR_CM
), \
312 ((DMA2D_LayerCfg
->Alpha
<< DMA2D_BGPFCCR_ALPHA_Pos
) | DMA2D_LayerCfg
->AlphaMode
| \
313 (DMA2D_LayerCfg
->CLUTSize
<< DMA2D_BGPFCCR_CS_Pos
) | DMA2D_LayerCfg
->CLUTColorMode
| \
314 DMA2D_LayerCfg
->ColorMode
));
315 #endif /* DMA2D_ALPHA_INV_RB_SWAP_SUPPORT */
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 #if defined(DMA2D_ALPHA_INV_RB_SWAP_SUPPORT)
332 /* Configure the foreground Alpha value, Alpha mode, RB swap, Alpha inversion
333 CLUT size, CLUT Color mode and Color mode */
334 MODIFY_REG(DMA2Dx
->FGPFCCR
, \
335 (DMA2D_FGPFCCR_ALPHA
| DMA2D_FGPFCCR_RBS
| DMA2D_FGPFCCR_AI
| DMA2D_FGPFCCR_AM
| \
336 DMA2D_FGPFCCR_CS
| DMA2D_FGPFCCR_CCM
| DMA2D_FGPFCCR_CM
), \
337 ((DMA2D_LayerCfg
->Alpha
<< DMA2D_FGPFCCR_ALPHA_Pos
) | DMA2D_LayerCfg
->RBSwapMode
| \
338 DMA2D_LayerCfg
->AlphaInversionMode
| DMA2D_LayerCfg
->AlphaMode
| \
339 (DMA2D_LayerCfg
->CLUTSize
<< DMA2D_FGPFCCR_CS_Pos
) | DMA2D_LayerCfg
->CLUTColorMode
| \
340 DMA2D_LayerCfg
->ColorMode
));
342 /* Configure the foreground Alpha value, Alpha mode, CLUT size, CLUT Color mode and Color mode */
343 MODIFY_REG(DMA2Dx
->FGPFCCR
, \
344 (DMA2D_FGPFCCR_ALPHA
| DMA2D_FGPFCCR_AM
| DMA2D_FGPFCCR_CS
| DMA2D_FGPFCCR_CCM
| DMA2D_FGPFCCR_CM
), \
345 ((DMA2D_LayerCfg
->Alpha
<< DMA2D_FGPFCCR_ALPHA_Pos
) | DMA2D_LayerCfg
->AlphaMode
| \
346 (DMA2D_LayerCfg
->CLUTSize
<< DMA2D_FGPFCCR_CS_Pos
) | DMA2D_LayerCfg
->CLUTColorMode
| \
347 DMA2D_LayerCfg
->ColorMode
));
348 #endif /* DMA2D_ALPHA_INV_RB_SWAP_SUPPORT */
350 /* Configure the foreground color */
351 LL_DMA2D_FGND_SetColor(DMA2Dx
, DMA2D_LayerCfg
->Red
, DMA2D_LayerCfg
->Green
, DMA2D_LayerCfg
->Blue
);
353 /* Configure the foreground CLUT memory address */
354 LL_DMA2D_FGND_SetCLUTMemAddr(DMA2Dx
, DMA2D_LayerCfg
->CLUTMemoryAddress
);
359 * @brief Set each @ref LL_DMA2D_LayerCfgTypeDef field to default value.
360 * @param DMA2D_LayerCfg pointer to a @ref LL_DMA2D_LayerCfgTypeDef structure
361 * whose fields will be set to default values.
364 void LL_DMA2D_LayerCfgStructInit(LL_DMA2D_LayerCfgTypeDef
*DMA2D_LayerCfg
)
366 /* Set DMA2D_LayerCfg fields to default values */
367 DMA2D_LayerCfg
->MemoryAddress
= 0x0U
;
368 DMA2D_LayerCfg
->ColorMode
= LL_DMA2D_INPUT_MODE_ARGB8888
;
369 DMA2D_LayerCfg
->LineOffset
= 0x0U
;
370 DMA2D_LayerCfg
->CLUTColorMode
= LL_DMA2D_CLUT_COLOR_MODE_ARGB8888
;
371 DMA2D_LayerCfg
->CLUTSize
= 0x0U
;
372 DMA2D_LayerCfg
->AlphaMode
= LL_DMA2D_ALPHA_MODE_NO_MODIF
;
373 DMA2D_LayerCfg
->Alpha
= 0x0U
;
374 DMA2D_LayerCfg
->Blue
= 0x0U
;
375 DMA2D_LayerCfg
->Green
= 0x0U
;
376 DMA2D_LayerCfg
->Red
= 0x0U
;
377 DMA2D_LayerCfg
->CLUTMemoryAddress
= 0x0U
;
378 #if defined(DMA2D_ALPHA_INV_RB_SWAP_SUPPORT)
379 DMA2D_LayerCfg
->AlphaInversionMode
= LL_DMA2D_ALPHA_REGULAR
;
380 DMA2D_LayerCfg
->RBSwapMode
= LL_DMA2D_RB_MODE_REGULAR
;
381 #endif /* DMA2D_ALPHA_INV_RB_SWAP_SUPPORT */
385 * @brief Initialize DMA2D output color register according to the specified parameters
386 * in DMA2D_ColorStruct.
387 * @param DMA2Dx DMA2D Instance
388 * @param DMA2D_ColorStruct pointer to a LL_DMA2D_ColorTypeDef structure that contains
389 * the color configuration information for the specified DMA2D peripheral.
392 void LL_DMA2D_ConfigOutputColor(DMA2D_TypeDef
*DMA2Dx
, LL_DMA2D_ColorTypeDef
*DMA2D_ColorStruct
)
398 /* Check the parameters */
399 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
400 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_ColorStruct
->ColorMode
));
401 assert_param(IS_LL_DMA2D_GREEN(DMA2D_ColorStruct
->OutputGreen
));
402 assert_param(IS_LL_DMA2D_RED(DMA2D_ColorStruct
->OutputRed
));
403 assert_param(IS_LL_DMA2D_BLUE(DMA2D_ColorStruct
->OutputBlue
));
404 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_ColorStruct
->OutputAlpha
));
406 /* DMA2D OCOLR register configuration ------------------------------------------*/
407 if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
409 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 8U;
410 outred
= DMA2D_ColorStruct
->OutputRed
<< 16U;
411 outalpha
= DMA2D_ColorStruct
->OutputAlpha
<< 24U;
413 else if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
415 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 8U;
416 outred
= DMA2D_ColorStruct
->OutputRed
<< 16U;
417 outalpha
= 0x00000000U
;
419 else if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
421 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 5U;
422 outred
= DMA2D_ColorStruct
->OutputRed
<< 11U;
423 outalpha
= 0x00000000U
;
425 else if (DMA2D_ColorStruct
->ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
427 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 5U;
428 outred
= DMA2D_ColorStruct
->OutputRed
<< 10U;
429 outalpha
= DMA2D_ColorStruct
->OutputAlpha
<< 15U;
431 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
433 outgreen
= DMA2D_ColorStruct
->OutputGreen
<< 4U;
434 outred
= DMA2D_ColorStruct
->OutputRed
<< 8U;
435 outalpha
= DMA2D_ColorStruct
->OutputAlpha
<< 12U;
437 LL_DMA2D_SetOutputColor(DMA2Dx
, (outgreen
| outred
| DMA2D_ColorStruct
->OutputBlue
| outalpha
));
441 * @brief Return DMA2D output Blue color.
442 * @param DMA2Dx DMA2D Instance.
443 * @param ColorMode This parameter can be one of the following values:
444 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
445 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
446 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
447 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
448 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
449 * @retval Output Blue color value between Min_Data=0 and Max_Data=0xFF
451 uint32_t LL_DMA2D_GetOutputBlueColor(DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
455 /* Check the parameters */
456 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
457 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
459 /* DMA2D OCOLR register reading ------------------------------------------*/
460 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
462 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFFU
));
464 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
466 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFFU
));
468 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
470 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x1FU
));
472 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
474 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x1FU
));
476 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
478 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFU
));
485 * @brief Return DMA2D output Green color.
486 * @param DMA2Dx DMA2D Instance.
487 * @param ColorMode This parameter can be one of the following values:
488 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
489 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
490 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
491 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
492 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
493 * @retval Output Green color value between Min_Data=0 and Max_Data=0xFF
495 uint32_t LL_DMA2D_GetOutputGreenColor(DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
499 /* Check the parameters */
500 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
501 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
503 /* DMA2D OCOLR register reading ------------------------------------------*/
504 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
506 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF00U
) >> 8U);
508 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
510 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF00U
) >> 8U);
512 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
514 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x7E0U
) >> 5U);
516 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
518 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x3E0U
) >> 5U);
520 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
522 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF0U
) >> 4U);
529 * @brief Return DMA2D output Red color.
530 * @param DMA2Dx DMA2D Instance.
531 * @param ColorMode This parameter can be one of the following values:
532 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
533 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
534 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
535 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
536 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
537 * @retval Output Red color value between Min_Data=0 and Max_Data=0xFF
539 uint32_t LL_DMA2D_GetOutputRedColor(DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
543 /* Check the parameters */
544 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
545 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
547 /* DMA2D OCOLR register reading ------------------------------------------*/
548 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
550 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF0000U
) >> 16U);
552 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
)
554 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF0000U
) >> 16U);
556 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
)
558 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF800U
) >> 11U);
560 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
562 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x7C00U
) >> 10U);
564 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
566 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF00U
) >> 8U);
573 * @brief Return DMA2D output Alpha color.
574 * @param DMA2Dx DMA2D Instance.
575 * @param ColorMode This parameter can be one of the following values:
576 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
577 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
578 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
579 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
580 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
581 * @retval Output Alpha color value between Min_Data=0 and Max_Data=0xFF
583 uint32_t LL_DMA2D_GetOutputAlphaColor(DMA2D_TypeDef
*DMA2Dx
, uint32_t ColorMode
)
587 /* Check the parameters */
588 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx
));
589 assert_param(IS_LL_DMA2D_OCMODE(ColorMode
));
591 /* DMA2D OCOLR register reading ------------------------------------------*/
592 if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB8888
)
594 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xFF000000U
) >> 24U);
596 else if ((ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB888
) || (ColorMode
== LL_DMA2D_OUTPUT_MODE_RGB565
))
600 else if (ColorMode
== LL_DMA2D_OUTPUT_MODE_ARGB1555
)
602 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0x8000U
) >> 15U);
604 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
606 color
= (uint32_t)(READ_BIT(DMA2Dx
->OCOLR
, 0xF000U
) >> 12U);
613 * @brief Configure DMA2D transfer size.
614 * @param DMA2Dx DMA2D Instance
615 * @param NbrOfLines Value between Min_Data=0 and Max_Data=0xFFFF
616 * @param NbrOfPixelsPerLines Value between Min_Data=0 and Max_Data=0x3FFF
619 void LL_DMA2D_ConfigSize(DMA2D_TypeDef
*DMA2Dx
, uint32_t NbrOfLines
, uint32_t NbrOfPixelsPerLines
)
621 MODIFY_REG(DMA2Dx
->NLR
, (DMA2D_NLR_PL
| DMA2D_NLR_NL
), \
622 ((NbrOfPixelsPerLines
<< DMA2D_NLR_PL_Pos
) | NbrOfLines
));
637 #endif /* defined (DMA2D) */
643 #endif /* USE_FULL_LL_DRIVER */
645 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/