source: S-port/trunk/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_dma2d.c

Last change on this file was 1, checked in by AlexLir, 3 years ago
File size: 23.2 KB
Line 
1/**
2 ******************************************************************************
3 * @file stm32f4xx_ll_dma2d.c
4 * @author MCD Application Team
5 * @brief DMA2D LL module driver.
6 ******************************************************************************
7 * @attention
8 *
9 * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10 * All rights reserved.</center></h2>
11 *
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
16 *
17 ******************************************************************************
18 */
19#if defined(USE_FULL_LL_DRIVER)
20
21/* Includes ------------------------------------------------------------------*/
22#include "stm32f4xx_ll_dma2d.h"
23#include "stm32f4xx_ll_bus.h"
24#ifdef USE_FULL_ASSERT
25#include "stm32_assert.h"
26#else
27#define assert_param(expr) ((void)0U)
28#endif /* USE_FULL_ASSERT */
29
30/** @addtogroup STM32F4xx_LL_Driver
31 * @{
32 */
33
34#if defined (DMA2D)
35
36/** @addtogroup DMA2D_LL
37 * @{
38 */
39
40/* Private types -------------------------------------------------------------*/
41/* Private variables ---------------------------------------------------------*/
42/* Private constants ---------------------------------------------------------*/
43/** @addtogroup DMA2D_LL_Private_Constants DMA2D Private Constants
44 * @{
45 */
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 */
51/**
52 * @}
53 */
54/* Private macros ------------------------------------------------------------*/
55/** @addtogroup DMA2D_LL_Private_Macros
56 * @{
57 */
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))
62
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))
68
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)
73
74
75#define IS_LL_DMA2D_OFFSET(OFFSET) ((OFFSET) <= LL_DMA2D_OFFSET_MAX)
76
77#define IS_LL_DMA2D_LINE(LINES) ((LINES) <= LL_DMA2D_NUMBEROFLINES)
78#define IS_LL_DMA2D_PIXEL(PIXELS) ((PIXELS) <= LL_DMA2D_NUMBEROFPIXELS)
79
80
81
82#define IS_LL_DMA2D_LCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB8888) || \
83 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB888) || \
84 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB565) || \
85 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB1555) || \
86 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB4444) || \
87 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L8) || \
88 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL44) || \
89 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL88) || \
90 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L4) || \
91 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A8) || \
92 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A4))
93
94#define IS_LL_DMA2D_CLUTCMODE(CLUTCMODE) (((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_ARGB8888) || \
95 ((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_RGB888))
96
97#define IS_LL_DMA2D_CLUTSIZE(SIZE) ((SIZE) <= LL_DMA2D_CLUTSIZE_MAX)
98
99#define IS_LL_DMA2D_ALPHAMODE(MODE) (((MODE) == LL_DMA2D_ALPHA_MODE_NO_MODIF) || \
100 ((MODE) == LL_DMA2D_ALPHA_MODE_REPLACE) || \
101 ((MODE) == LL_DMA2D_ALPHA_MODE_COMBINE))
102
103
104/**
105 * @}
106 */
107
108/* Private function prototypes -----------------------------------------------*/
109
110/* Exported functions --------------------------------------------------------*/
111/** @addtogroup DMA2D_LL_Exported_Functions
112 * @{
113 */
114
115/** @addtogroup DMA2D_LL_EF_Init_Functions Initialization and De-initialization Functions
116 * @{
117 */
118
119/**
120 * @brief De-initialize DMA2D registers (registers restored to their default values).
121 * @param DMA2Dx DMA2D Instance
122 * @retval An ErrorStatus enumeration value:
123 * - SUCCESS: DMA2D registers are de-initialized
124 * - ERROR: DMA2D registers are not de-initialized
125 */
126ErrorStatus LL_DMA2D_DeInit(DMA2D_TypeDef *DMA2Dx)
127{
128 ErrorStatus status = SUCCESS;
129
130 /* Check the parameters */
131 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
132
133 if (DMA2Dx == DMA2D)
134 {
135 /* Force reset of DMA2D clock */
136 LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_DMA2D);
137
138 /* Release reset of DMA2D clock */
139 LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_DMA2D);
140 }
141 else
142 {
143 status = ERROR;
144 }
145
146 return (status);
147}
148
149/**
150 * @brief Initialize DMA2D registers according to the specified parameters in DMA2D_InitStruct.
151 * @note DMA2D transfers must be disabled to set initialization bits in configuration registers,
152 * otherwise ERROR result is returned.
153 * @param DMA2Dx DMA2D Instance
154 * @param DMA2D_InitStruct pointer to a LL_DMA2D_InitTypeDef structure
155 * that contains the configuration information for the specified DMA2D peripheral.
156 * @retval An ErrorStatus enumeration value:
157 * - SUCCESS: DMA2D registers are initialized according to DMA2D_InitStruct content
158 * - ERROR: Issue occurred during DMA2D registers initialization
159 */
160ErrorStatus LL_DMA2D_Init(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_InitTypeDef *DMA2D_InitStruct)
161{
162 ErrorStatus status = ERROR;
163 LL_DMA2D_ColorTypeDef dma2d_colorstruct;
164 uint32_t tmp;
165 uint32_t tmp1;
166 uint32_t tmp2;
167 uint32_t regMask;
168 uint32_t regValue;
169
170 /* Check the parameters */
171 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
172 assert_param(IS_LL_DMA2D_MODE(DMA2D_InitStruct->Mode));
173 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_InitStruct->ColorMode));
174 assert_param(IS_LL_DMA2D_LINE(DMA2D_InitStruct->NbrOfLines));
175 assert_param(IS_LL_DMA2D_PIXEL(DMA2D_InitStruct->NbrOfPixelsPerLines));
176 assert_param(IS_LL_DMA2D_GREEN(DMA2D_InitStruct->OutputGreen));
177 assert_param(IS_LL_DMA2D_RED(DMA2D_InitStruct->OutputRed));
178 assert_param(IS_LL_DMA2D_BLUE(DMA2D_InitStruct->OutputBlue));
179 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_InitStruct->OutputAlpha));
180 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_InitStruct->LineOffset));
181
182 /* DMA2D transfers must be disabled to configure bits in initialization registers */
183 tmp = LL_DMA2D_IsTransferOngoing(DMA2Dx);
184 tmp1 = LL_DMA2D_FGND_IsEnabledCLUTLoad(DMA2Dx);
185 tmp2 = LL_DMA2D_BGND_IsEnabledCLUTLoad(DMA2Dx);
186 if ((tmp == 0U) && (tmp1 == 0U) && (tmp2 == 0U))
187 {
188 /* DMA2D CR register configuration -------------------------------------------*/
189 LL_DMA2D_SetMode(DMA2Dx, DMA2D_InitStruct->Mode);
190
191 /* DMA2D OPFCCR register configuration ---------------------------------------*/
192 regMask = DMA2D_OPFCCR_CM;
193 regValue = DMA2D_InitStruct->ColorMode;
194
195
196
197
198 MODIFY_REG(DMA2Dx->OPFCCR, regMask, regValue);
199
200 /* DMA2D OOR register configuration ------------------------------------------*/
201 LL_DMA2D_SetLineOffset(DMA2Dx, DMA2D_InitStruct->LineOffset);
202
203 /* DMA2D NLR register configuration ------------------------------------------*/
204 LL_DMA2D_ConfigSize(DMA2Dx, DMA2D_InitStruct->NbrOfLines, DMA2D_InitStruct->NbrOfPixelsPerLines);
205
206 /* DMA2D OMAR register configuration ------------------------------------------*/
207 LL_DMA2D_SetOutputMemAddr(DMA2Dx, DMA2D_InitStruct->OutputMemoryAddress);
208
209 /* DMA2D OCOLR register configuration ------------------------------------------*/
210 dma2d_colorstruct.ColorMode = DMA2D_InitStruct->ColorMode;
211 dma2d_colorstruct.OutputBlue = DMA2D_InitStruct->OutputBlue;
212 dma2d_colorstruct.OutputGreen = DMA2D_InitStruct->OutputGreen;
213 dma2d_colorstruct.OutputRed = DMA2D_InitStruct->OutputRed;
214 dma2d_colorstruct.OutputAlpha = DMA2D_InitStruct->OutputAlpha;
215 LL_DMA2D_ConfigOutputColor(DMA2Dx, &dma2d_colorstruct);
216
217 status = SUCCESS;
218 }
219 /* If DMA2D transfers are not disabled, return ERROR */
220
221 return (status);
222}
223
224/**
225 * @brief Set each @ref LL_DMA2D_InitTypeDef field to default value.
226 * @param DMA2D_InitStruct pointer to a @ref LL_DMA2D_InitTypeDef structure
227 * whose fields will be set to default values.
228 * @retval None
229 */
230void LL_DMA2D_StructInit(LL_DMA2D_InitTypeDef *DMA2D_InitStruct)
231{
232 /* Set DMA2D_InitStruct fields to default values */
233 DMA2D_InitStruct->Mode = LL_DMA2D_MODE_M2M;
234 DMA2D_InitStruct->ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB8888;
235 DMA2D_InitStruct->NbrOfLines = 0x0U;
236 DMA2D_InitStruct->NbrOfPixelsPerLines = 0x0U;
237 DMA2D_InitStruct->LineOffset = 0x0U;
238 DMA2D_InitStruct->OutputBlue = 0x0U;
239 DMA2D_InitStruct->OutputGreen = 0x0U;
240 DMA2D_InitStruct->OutputRed = 0x0U;
241 DMA2D_InitStruct->OutputAlpha = 0x0U;
242 DMA2D_InitStruct->OutputMemoryAddress = 0x0U;
243}
244
245/**
246 * @brief Configure the foreground or background according to the specified parameters
247 * in the LL_DMA2D_LayerCfgTypeDef structure.
248 * @param DMA2Dx DMA2D Instance
249 * @param DMA2D_LayerCfg pointer to a LL_DMA2D_LayerCfgTypeDef structure that contains
250 * the configuration information for the specified layer.
251 * @param LayerIdx DMA2D Layer index.
252 * This parameter can be one of the following values:
253 * 0(background) / 1(foreground)
254 * @retval None
255 */
256void LL_DMA2D_ConfigLayer(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_LayerCfgTypeDef *DMA2D_LayerCfg, uint32_t LayerIdx)
257{
258 /* Check the parameters */
259 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_LayerCfg->LineOffset));
260 assert_param(IS_LL_DMA2D_LCMODE(DMA2D_LayerCfg->ColorMode));
261 assert_param(IS_LL_DMA2D_CLUTCMODE(DMA2D_LayerCfg->CLUTColorMode));
262 assert_param(IS_LL_DMA2D_CLUTSIZE(DMA2D_LayerCfg->CLUTSize));
263 assert_param(IS_LL_DMA2D_ALPHAMODE(DMA2D_LayerCfg->AlphaMode));
264 assert_param(IS_LL_DMA2D_GREEN(DMA2D_LayerCfg->Green));
265 assert_param(IS_LL_DMA2D_RED(DMA2D_LayerCfg->Red));
266 assert_param(IS_LL_DMA2D_BLUE(DMA2D_LayerCfg->Blue));
267 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_LayerCfg->Alpha));
268
269
270 if (LayerIdx == 0U)
271 {
272 /* Configure the background memory address */
273 LL_DMA2D_BGND_SetMemAddr(DMA2Dx, DMA2D_LayerCfg->MemoryAddress);
274
275 /* Configure the background line offset */
276 LL_DMA2D_BGND_SetLineOffset(DMA2Dx, DMA2D_LayerCfg->LineOffset);
277
278 /* Configure the background Alpha value, Alpha mode, CLUT size, CLUT Color mode and Color mode */
279 MODIFY_REG(DMA2Dx->BGPFCCR, \
280 (DMA2D_BGPFCCR_ALPHA | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM | DMA2D_BGPFCCR_CM), \
281 ((DMA2D_LayerCfg->Alpha << DMA2D_BGPFCCR_ALPHA_Pos) | DMA2D_LayerCfg->AlphaMode | \
282 (DMA2D_LayerCfg->CLUTSize << DMA2D_BGPFCCR_CS_Pos) | DMA2D_LayerCfg->CLUTColorMode | \
283 DMA2D_LayerCfg->ColorMode));
284
285 /* Configure the background color */
286 LL_DMA2D_BGND_SetColor(DMA2Dx, DMA2D_LayerCfg->Red, DMA2D_LayerCfg->Green, DMA2D_LayerCfg->Blue);
287
288 /* Configure the background CLUT memory address */
289 LL_DMA2D_BGND_SetCLUTMemAddr(DMA2Dx, DMA2D_LayerCfg->CLUTMemoryAddress);
290 }
291 else
292 {
293 /* Configure the foreground memory address */
294 LL_DMA2D_FGND_SetMemAddr(DMA2Dx, DMA2D_LayerCfg->MemoryAddress);
295
296 /* Configure the foreground line offset */
297 LL_DMA2D_FGND_SetLineOffset(DMA2Dx, DMA2D_LayerCfg->LineOffset);
298
299 /* Configure the foreground Alpha value, Alpha mode, CLUT size, CLUT Color mode and Color mode */
300 MODIFY_REG(DMA2Dx->FGPFCCR, \
301 (DMA2D_FGPFCCR_ALPHA | DMA2D_FGPFCCR_AM | DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM | DMA2D_FGPFCCR_CM), \
302 ((DMA2D_LayerCfg->Alpha << DMA2D_FGPFCCR_ALPHA_Pos) | DMA2D_LayerCfg->AlphaMode | \
303 (DMA2D_LayerCfg->CLUTSize << DMA2D_FGPFCCR_CS_Pos) | DMA2D_LayerCfg->CLUTColorMode | \
304 DMA2D_LayerCfg->ColorMode));
305
306 /* Configure the foreground color */
307 LL_DMA2D_FGND_SetColor(DMA2Dx, DMA2D_LayerCfg->Red, DMA2D_LayerCfg->Green, DMA2D_LayerCfg->Blue);
308
309 /* Configure the foreground CLUT memory address */
310 LL_DMA2D_FGND_SetCLUTMemAddr(DMA2Dx, DMA2D_LayerCfg->CLUTMemoryAddress);
311 }
312}
313
314/**
315 * @brief Set each @ref LL_DMA2D_LayerCfgTypeDef field to default value.
316 * @param DMA2D_LayerCfg pointer to a @ref LL_DMA2D_LayerCfgTypeDef structure
317 * whose fields will be set to default values.
318 * @retval None
319 */
320void LL_DMA2D_LayerCfgStructInit(LL_DMA2D_LayerCfgTypeDef *DMA2D_LayerCfg)
321{
322 /* Set DMA2D_LayerCfg fields to default values */
323 DMA2D_LayerCfg->MemoryAddress = 0x0U;
324 DMA2D_LayerCfg->ColorMode = LL_DMA2D_INPUT_MODE_ARGB8888;
325 DMA2D_LayerCfg->LineOffset = 0x0U;
326 DMA2D_LayerCfg->CLUTColorMode = LL_DMA2D_CLUT_COLOR_MODE_ARGB8888;
327 DMA2D_LayerCfg->CLUTSize = 0x0U;
328 DMA2D_LayerCfg->AlphaMode = LL_DMA2D_ALPHA_MODE_NO_MODIF;
329 DMA2D_LayerCfg->Alpha = 0x0U;
330 DMA2D_LayerCfg->Blue = 0x0U;
331 DMA2D_LayerCfg->Green = 0x0U;
332 DMA2D_LayerCfg->Red = 0x0U;
333 DMA2D_LayerCfg->CLUTMemoryAddress = 0x0U;
334}
335
336/**
337 * @brief Initialize DMA2D output color register according to the specified parameters
338 * in DMA2D_ColorStruct.
339 * @param DMA2Dx DMA2D Instance
340 * @param DMA2D_ColorStruct pointer to a LL_DMA2D_ColorTypeDef structure that contains
341 * the color configuration information for the specified DMA2D peripheral.
342 * @retval None
343 */
344void LL_DMA2D_ConfigOutputColor(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_ColorTypeDef *DMA2D_ColorStruct)
345{
346 uint32_t outgreen;
347 uint32_t outred;
348 uint32_t outalpha;
349
350 /* Check the parameters */
351 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
352 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_ColorStruct->ColorMode));
353 assert_param(IS_LL_DMA2D_GREEN(DMA2D_ColorStruct->OutputGreen));
354 assert_param(IS_LL_DMA2D_RED(DMA2D_ColorStruct->OutputRed));
355 assert_param(IS_LL_DMA2D_BLUE(DMA2D_ColorStruct->OutputBlue));
356 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_ColorStruct->OutputAlpha));
357
358 /* DMA2D OCOLR register configuration ------------------------------------------*/
359 if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
360 {
361 outgreen = DMA2D_ColorStruct->OutputGreen << 8U;
362 outred = DMA2D_ColorStruct->OutputRed << 16U;
363 outalpha = DMA2D_ColorStruct->OutputAlpha << 24U;
364 }
365 else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888)
366 {
367 outgreen = DMA2D_ColorStruct->OutputGreen << 8U;
368 outred = DMA2D_ColorStruct->OutputRed << 16U;
369 outalpha = 0x00000000U;
370 }
371 else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565)
372 {
373 outgreen = DMA2D_ColorStruct->OutputGreen << 5U;
374 outred = DMA2D_ColorStruct->OutputRed << 11U;
375 outalpha = 0x00000000U;
376 }
377 else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
378 {
379 outgreen = DMA2D_ColorStruct->OutputGreen << 5U;
380 outred = DMA2D_ColorStruct->OutputRed << 10U;
381 outalpha = DMA2D_ColorStruct->OutputAlpha << 15U;
382 }
383 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
384 {
385 outgreen = DMA2D_ColorStruct->OutputGreen << 4U;
386 outred = DMA2D_ColorStruct->OutputRed << 8U;
387 outalpha = DMA2D_ColorStruct->OutputAlpha << 12U;
388 }
389 LL_DMA2D_SetOutputColor(DMA2Dx, (outgreen | outred | DMA2D_ColorStruct->OutputBlue | outalpha));
390}
391
392/**
393 * @brief Return DMA2D output Blue color.
394 * @param DMA2Dx DMA2D Instance.
395 * @param ColorMode This parameter can be one of the following values:
396 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
397 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
398 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
399 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
400 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
401 * @retval Output Blue color value between Min_Data=0 and Max_Data=0xFF
402 */
403uint32_t LL_DMA2D_GetOutputBlueColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode)
404{
405 uint32_t color;
406
407 /* Check the parameters */
408 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
409 assert_param(IS_LL_DMA2D_OCMODE(ColorMode));
410
411 /* DMA2D OCOLR register reading ------------------------------------------*/
412 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
413 {
414 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFFU));
415 }
416 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888)
417 {
418 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFFU));
419 }
420 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565)
421 {
422 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x1FU));
423 }
424 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
425 {
426 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x1FU));
427 }
428 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
429 {
430 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFU));
431 }
432
433 return color;
434}
435
436/**
437 * @brief Return DMA2D output Green color.
438 * @param DMA2Dx DMA2D Instance.
439 * @param ColorMode This parameter can be one of the following values:
440 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
441 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
442 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
443 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
444 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
445 * @retval Output Green color value between Min_Data=0 and Max_Data=0xFF
446 */
447uint32_t LL_DMA2D_GetOutputGreenColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode)
448{
449 uint32_t color;
450
451 /* Check the parameters */
452 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
453 assert_param(IS_LL_DMA2D_OCMODE(ColorMode));
454
455 /* DMA2D OCOLR register reading ------------------------------------------*/
456 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
457 {
458 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF00U) >> 8U);
459 }
460 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888)
461 {
462 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF00U) >> 8U);
463 }
464 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565)
465 {
466 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x7E0U) >> 5U);
467 }
468 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
469 {
470 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x3E0U) >> 5U);
471 }
472 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
473 {
474 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF0U) >> 4U);
475 }
476
477 return color;
478}
479
480/**
481 * @brief Return DMA2D output Red color.
482 * @param DMA2Dx DMA2D Instance.
483 * @param ColorMode This parameter can be one of the following values:
484 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
485 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
486 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
487 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
488 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
489 * @retval Output Red color value between Min_Data=0 and Max_Data=0xFF
490 */
491uint32_t LL_DMA2D_GetOutputRedColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode)
492{
493 uint32_t color;
494
495 /* Check the parameters */
496 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
497 assert_param(IS_LL_DMA2D_OCMODE(ColorMode));
498
499 /* DMA2D OCOLR register reading ------------------------------------------*/
500 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
501 {
502 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF0000U) >> 16U);
503 }
504 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888)
505 {
506 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF0000U) >> 16U);
507 }
508 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565)
509 {
510 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF800U) >> 11U);
511 }
512 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
513 {
514 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x7C00U) >> 10U);
515 }
516 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
517 {
518 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF00U) >> 8U);
519 }
520
521 return color;
522}
523
524/**
525 * @brief Return DMA2D output Alpha color.
526 * @param DMA2Dx DMA2D Instance.
527 * @param ColorMode This parameter can be one of the following values:
528 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
529 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
530 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
531 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
532 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
533 * @retval Output Alpha color value between Min_Data=0 and Max_Data=0xFF
534 */
535uint32_t LL_DMA2D_GetOutputAlphaColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode)
536{
537 uint32_t color;
538
539 /* Check the parameters */
540 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
541 assert_param(IS_LL_DMA2D_OCMODE(ColorMode));
542
543 /* DMA2D OCOLR register reading ------------------------------------------*/
544 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
545 {
546 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF000000U) >> 24U);
547 }
548 else if ((ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888) || (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565))
549 {
550 color = 0x0U;
551 }
552 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
553 {
554 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x8000U) >> 15U);
555 }
556 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
557 {
558 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF000U) >> 12U);
559 }
560
561 return color;
562}
563
564/**
565 * @brief Configure DMA2D transfer size.
566 * @param DMA2Dx DMA2D Instance
567 * @param NbrOfLines Value between Min_Data=0 and Max_Data=0xFFFF
568 * @param NbrOfPixelsPerLines Value between Min_Data=0 and Max_Data=0x3FFF
569 * @retval None
570 */
571void LL_DMA2D_ConfigSize(DMA2D_TypeDef *DMA2Dx, uint32_t NbrOfLines, uint32_t NbrOfPixelsPerLines)
572{
573 MODIFY_REG(DMA2Dx->NLR, (DMA2D_NLR_PL | DMA2D_NLR_NL), \
574 ((NbrOfPixelsPerLines << DMA2D_NLR_PL_Pos) | NbrOfLines));
575}
576
577/**
578 * @}
579 */
580
581/**
582 * @}
583 */
584
585/**
586 * @}
587 */
588
589#endif /* defined (DMA2D) */
590
591/**
592 * @}
593 */
594
595#endif /* USE_FULL_LL_DRIVER */
596
597/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
598
Note: See TracBrowser for help on using the repository browser.