Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / lib / main / STM32F4 / Drivers / STM32F4xx_HAL_Driver / Src / stm32f4xx_ll_dma2d.c
blobc940353b055338116de66a59af924ca71aaab028
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_ll_dma2d.c
4 * @author MCD Application Team
5 * @version V1.7.1
6 * @date 14-April-2017
7 * @brief DMA2D LL module driver.
8 ******************************************************************************
9 * @attention
11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
37 #if defined(USE_FULL_LL_DRIVER)
39 /* Includes ------------------------------------------------------------------*/
40 #include "stm32f4xx_ll_dma2d.h"
41 #include "stm32f4xx_ll_bus.h"
42 #ifdef USE_FULL_ASSERT
43 #include "stm32_assert.h"
44 #else
45 #define assert_param(expr) ((void)0U)
46 #endif
48 /** @addtogroup STM32F4xx_LL_Driver
49 * @{
52 #if defined (DMA2D)
54 /** @addtogroup DMA2D_LL
55 * @{
58 /* Private types -------------------------------------------------------------*/
59 /* Private variables ---------------------------------------------------------*/
60 /* Private constants ---------------------------------------------------------*/
61 /** @addtogroup DMA2D_LL_Private_Constants DMA2D Private Constants
62 * @{
64 #define LL_DMA2D_COLOR 0xFFU /*!< Maximum output color setting */
65 #define LL_DMA2D_NUMBEROFLINES DMA2D_NLR_NL /*!< Maximum number of lines */
66 #define LL_DMA2D_NUMBEROFPIXELS (DMA2D_NLR_PL >> DMA2D_NLR_PL_Pos) /*!< Maximum number of pixels per lines */
67 #define LL_DMA2D_OFFSET_MAX 0x3FFFU /*!< Maximum output line offset expressed in pixels */
68 #define LL_DMA2D_CLUTSIZE_MAX 0xFFU /*!< Maximum CLUT size */
69 /**
70 * @}
72 /* Private macros ------------------------------------------------------------*/
73 /** @addtogroup DMA2D_LL_Private_Macros
74 * @{
76 #define IS_LL_DMA2D_MODE(MODE) (((MODE) == LL_DMA2D_MODE_M2M) || \
77 ((MODE) == LL_DMA2D_MODE_M2M_PFC) || \
78 ((MODE) == LL_DMA2D_MODE_M2M_BLEND) || \
79 ((MODE) == LL_DMA2D_MODE_R2M))
81 #define IS_LL_DMA2D_OCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB8888) || \
82 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB888) || \
83 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB565) || \
84 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB1555) || \
85 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB4444))
87 #define IS_LL_DMA2D_GREEN(GREEN) ((GREEN) <= LL_DMA2D_COLOR)
88 #define IS_LL_DMA2D_RED(RED) ((RED) <= LL_DMA2D_COLOR)
89 #define IS_LL_DMA2D_BLUE(BLUE) ((BLUE) <= LL_DMA2D_COLOR)
90 #define IS_LL_DMA2D_ALPHA(ALPHA) ((ALPHA) <= LL_DMA2D_COLOR)
92 #define IS_LL_DMA2D_OFFSET(OFFSET) ((OFFSET) <= LL_DMA2D_OFFSET_MAX)
94 #define IS_LL_DMA2D_LINE(LINES) ((LINES) <= LL_DMA2D_NUMBEROFLINES)
95 #define IS_LL_DMA2D_PIXEL(PIXELS) ((PIXELS) <= LL_DMA2D_NUMBEROFPIXELS)
97 #define IS_LL_DMA2D_LCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB8888) || \
98 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB888) || \
99 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB565) || \
100 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB1555) || \
101 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB4444) || \
102 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L8) || \
103 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL44) || \
104 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL88) || \
105 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L4) || \
106 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A8) || \
107 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A4))
109 #define IS_LL_DMA2D_CLUTCMODE(CLUTCMODE) (((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_ARGB8888) || \
110 ((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_RGB888))
112 #define IS_LL_DMA2D_CLUTSIZE(SIZE) ((SIZE) <= LL_DMA2D_CLUTSIZE_MAX)
114 #define IS_LL_DMA2D_ALPHAMODE(MODE) (((MODE) == LL_DMA2D_ALPHA_MODE_NO_MODIF) || \
115 ((MODE) == LL_DMA2D_ALPHA_MODE_REPLACE) || \
116 ((MODE) == LL_DMA2D_ALPHA_MODE_COMBINE))
118 * @}
121 /* Private function prototypes -----------------------------------------------*/
123 /* Exported functions --------------------------------------------------------*/
124 /** @addtogroup DMA2D_LL_Exported_Functions
125 * @{
128 /** @addtogroup DMA2D_LL_EF_Init_Functions Initialization and De-initialization Functions
129 * @{
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(DMA2D_TypeDef *DMA2Dx)
141 ErrorStatus status = SUCCESS;
143 /* Check the parameters */
144 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
146 if (DMA2Dx == DMA2D)
148 /* Force reset of DMA2D clock */
149 LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_DMA2D);
151 /* Release reset of DMA2D clock */
152 LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_DMA2D);
154 else
156 status = ERROR;
159 return (status);
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;
177 uint32_t tmp = 0U, tmp1 = 0U, tmp2 = 0U;
179 /* Check the parameters */
180 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
181 assert_param(IS_LL_DMA2D_MODE(DMA2D_InitStruct->Mode));
182 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_InitStruct->ColorMode));
183 assert_param(IS_LL_DMA2D_LINE(DMA2D_InitStruct->NbrOfLines));
184 assert_param(IS_LL_DMA2D_PIXEL(DMA2D_InitStruct->NbrOfPixelsPerLines));
185 assert_param(IS_LL_DMA2D_GREEN(DMA2D_InitStruct->OutputGreen));
186 assert_param(IS_LL_DMA2D_RED(DMA2D_InitStruct->OutputRed));
187 assert_param(IS_LL_DMA2D_BLUE(DMA2D_InitStruct->OutputBlue));
188 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_InitStruct->OutputAlpha));
189 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_InitStruct->LineOffset));
191 /* DMA2D transfers must be disabled to configure bits in initialization registers */
192 tmp = LL_DMA2D_IsTransferOngoing(DMA2Dx);
193 tmp1 = LL_DMA2D_FGND_IsEnabledCLUTLoad(DMA2Dx);
194 tmp2 = LL_DMA2D_BGND_IsEnabledCLUTLoad(DMA2Dx);
195 if ((tmp == 0U) && (tmp1 == 0U) && (tmp2 == 0U))
197 /* DMA2D CR register configuration -------------------------------------------*/
198 LL_DMA2D_SetMode(DMA2Dx, DMA2D_InitStruct->Mode);
200 /* DMA2D OPFCCR register configuration ---------------------------------------*/
201 MODIFY_REG(DMA2Dx->OPFCCR, DMA2D_OPFCCR_CM, DMA2D_InitStruct->ColorMode);
203 /* DMA2D OOR register configuration ------------------------------------------*/
204 LL_DMA2D_SetLineOffset(DMA2Dx, DMA2D_InitStruct->LineOffset);
206 /* DMA2D NLR register configuration ------------------------------------------*/
207 LL_DMA2D_ConfigSize(DMA2Dx, DMA2D_InitStruct->NbrOfLines, DMA2D_InitStruct->NbrOfPixelsPerLines);
209 /* DMA2D OMAR register configuration ------------------------------------------*/
210 LL_DMA2D_SetOutputMemAddr(DMA2Dx, DMA2D_InitStruct->OutputMemoryAddress);
212 /* DMA2D OCOLR register configuration ------------------------------------------*/
213 DMA2D_ColorStruct.ColorMode = DMA2D_InitStruct->ColorMode;
214 DMA2D_ColorStruct.OutputBlue = DMA2D_InitStruct->OutputBlue;
215 DMA2D_ColorStruct.OutputGreen = DMA2D_InitStruct->OutputGreen;
216 DMA2D_ColorStruct.OutputRed = DMA2D_InitStruct->OutputRed;
217 DMA2D_ColorStruct.OutputAlpha = DMA2D_InitStruct->OutputAlpha;
218 LL_DMA2D_ConfigOutputColor(DMA2Dx, &DMA2D_ColorStruct);
220 status = SUCCESS;
222 /* If DMA2D transfers are not disabled, return ERROR */
224 return (status);
228 * @brief Set each @ref LL_DMA2D_InitTypeDef field to default value.
229 * @param DMA2D_InitStruct: pointer to a @ref LL_DMA2D_InitTypeDef structure
230 * whose fields will be set to default values.
231 * @retval None
233 void LL_DMA2D_StructInit(LL_DMA2D_InitTypeDef *DMA2D_InitStruct)
235 /* Set DMA2D_InitStruct fields to default values */
236 DMA2D_InitStruct->Mode = LL_DMA2D_MODE_M2M;
237 DMA2D_InitStruct->ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB8888;
238 DMA2D_InitStruct->NbrOfLines = 0x0U;
239 DMA2D_InitStruct->NbrOfPixelsPerLines = 0x0U;
240 DMA2D_InitStruct->LineOffset = 0x0U;
241 DMA2D_InitStruct->OutputBlue = 0x0U;
242 DMA2D_InitStruct->OutputGreen = 0x0U;
243 DMA2D_InitStruct->OutputRed = 0x0U;
244 DMA2D_InitStruct->OutputAlpha = 0x0U;
245 DMA2D_InitStruct->OutputMemoryAddress = 0x0U;
249 * @brief Configure the foreground or background according to the specified parameters
250 * in the LL_DMA2D_LayerCfgTypeDef structure.
251 * @param DMA2Dx DMA2D Instance
252 * @param DMA2D_LayerCfg: pointer to a LL_DMA2D_LayerCfgTypeDef structure that contains
253 * the configuration information for the specified layer.
254 * @param LayerIdx: DMA2D Layer index.
255 * This parameter can be one of the following values:
256 * 0(background) / 1(foreground)
257 * @retval None
259 void LL_DMA2D_ConfigLayer(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_LayerCfgTypeDef *DMA2D_LayerCfg, uint32_t LayerIdx)
261 /* Check the parameters */
262 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_LayerCfg->LineOffset));
263 assert_param(IS_LL_DMA2D_LCMODE(DMA2D_LayerCfg->ColorMode));
264 assert_param(IS_LL_DMA2D_CLUTCMODE(DMA2D_LayerCfg->CLUTColorMode));
265 assert_param(IS_LL_DMA2D_CLUTSIZE(DMA2D_LayerCfg->CLUTSize));
266 assert_param(IS_LL_DMA2D_ALPHAMODE(DMA2D_LayerCfg->AlphaMode));
267 assert_param(IS_LL_DMA2D_GREEN(DMA2D_LayerCfg->Green));
268 assert_param(IS_LL_DMA2D_RED(DMA2D_LayerCfg->Red));
269 assert_param(IS_LL_DMA2D_BLUE(DMA2D_LayerCfg->Blue));
270 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_LayerCfg->Alpha));
272 if (LayerIdx == 0U)
274 /* Configure the background memory address */
275 LL_DMA2D_BGND_SetMemAddr(DMA2Dx, DMA2D_LayerCfg->MemoryAddress);
277 /* Configure the background line offset */
278 LL_DMA2D_BGND_SetLineOffset(DMA2Dx, DMA2D_LayerCfg->LineOffset);
280 /* Configure the background Alpha value, Alpha mode, CLUT size, CLUT Color mode and Color mode */
281 MODIFY_REG(DMA2Dx->BGPFCCR, \
282 (DMA2D_BGPFCCR_ALPHA | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM | DMA2D_BGPFCCR_CM), \
283 ((DMA2D_LayerCfg->Alpha << DMA2D_BGPFCCR_ALPHA_Pos) | DMA2D_LayerCfg->AlphaMode | \
284 (DMA2D_LayerCfg->CLUTSize << DMA2D_BGPFCCR_CS_Pos) | DMA2D_LayerCfg->CLUTColorMode | \
285 DMA2D_LayerCfg->ColorMode));
287 /* Configure the background color */
288 LL_DMA2D_BGND_SetColor(DMA2Dx, DMA2D_LayerCfg->Red, DMA2D_LayerCfg->Green, DMA2D_LayerCfg->Blue);
290 /* Configure the background CLUT memory address */
291 LL_DMA2D_BGND_SetCLUTMemAddr(DMA2Dx, DMA2D_LayerCfg->CLUTMemoryAddress);
293 else
295 /* Configure the foreground memory address */
296 LL_DMA2D_FGND_SetMemAddr(DMA2Dx, DMA2D_LayerCfg->MemoryAddress);
298 /* Configure the foreground line offset */
299 LL_DMA2D_FGND_SetLineOffset(DMA2Dx, DMA2D_LayerCfg->LineOffset);
301 /* Configure the foreground Alpha value, Alpha mode, CLUT size, CLUT Color mode and Color mode */
302 MODIFY_REG(DMA2Dx->FGPFCCR, \
303 (DMA2D_FGPFCCR_ALPHA | DMA2D_FGPFCCR_AM | DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM | DMA2D_FGPFCCR_CM), \
304 ((DMA2D_LayerCfg->Alpha << DMA2D_FGPFCCR_ALPHA_Pos) | DMA2D_LayerCfg->AlphaMode | \
305 (DMA2D_LayerCfg->CLUTSize << DMA2D_FGPFCCR_CS_Pos) | DMA2D_LayerCfg->CLUTColorMode | \
306 DMA2D_LayerCfg->ColorMode));
308 /* Configure the foreground color */
309 LL_DMA2D_FGND_SetColor(DMA2Dx, DMA2D_LayerCfg->Red, DMA2D_LayerCfg->Green, DMA2D_LayerCfg->Blue);
311 /* Configure the foreground CLUT memory address */
312 LL_DMA2D_FGND_SetCLUTMemAddr(DMA2Dx, DMA2D_LayerCfg->CLUTMemoryAddress);
317 * @brief Set each @ref LL_DMA2D_LayerCfgTypeDef field to default value.
318 * @param DMA2D_LayerCfg: pointer to a @ref LL_DMA2D_LayerCfgTypeDef structure
319 * whose fields will be set to default values.
320 * @retval None
322 void LL_DMA2D_LayerCfgStructInit(LL_DMA2D_LayerCfgTypeDef *DMA2D_LayerCfg)
324 /* Set DMA2D_LayerCfg fields to default values */
325 DMA2D_LayerCfg->MemoryAddress = 0x0U;
326 DMA2D_LayerCfg->ColorMode = LL_DMA2D_INPUT_MODE_ARGB8888;
327 DMA2D_LayerCfg->LineOffset = 0x0U;
328 DMA2D_LayerCfg->CLUTColorMode = LL_DMA2D_CLUT_COLOR_MODE_ARGB8888;
329 DMA2D_LayerCfg->CLUTSize = 0x0U;
330 DMA2D_LayerCfg->AlphaMode = LL_DMA2D_ALPHA_MODE_NO_MODIF;
331 DMA2D_LayerCfg->Alpha = 0x0U;
332 DMA2D_LayerCfg->Blue = 0x0U;
333 DMA2D_LayerCfg->Green = 0x0U;
334 DMA2D_LayerCfg->Red = 0x0U;
335 DMA2D_LayerCfg->CLUTMemoryAddress = 0x0U;
339 * @brief Initialize DMA2D output color register according to the specified parameters
340 * in DMA2D_ColorStruct.
341 * @param DMA2Dx DMA2D Instance
342 * @param DMA2D_ColorStruct: pointer to a LL_DMA2D_ColorTypeDef structure that contains
343 * the color configuration information for the specified DMA2D peripheral.
344 * @retval None
346 void LL_DMA2D_ConfigOutputColor(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_ColorTypeDef *DMA2D_ColorStruct)
348 uint32_t outgreen = 0U;
349 uint32_t outred = 0U;
350 uint32_t outalpha = 0U;
352 /* Check the parameters */
353 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
354 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_ColorStruct->ColorMode));
355 assert_param(IS_LL_DMA2D_GREEN(DMA2D_ColorStruct->OutputGreen));
356 assert_param(IS_LL_DMA2D_RED(DMA2D_ColorStruct->OutputRed));
357 assert_param(IS_LL_DMA2D_BLUE(DMA2D_ColorStruct->OutputBlue));
358 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_ColorStruct->OutputAlpha));
360 /* DMA2D OCOLR register configuration ------------------------------------------*/
361 if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
363 outgreen = DMA2D_ColorStruct->OutputGreen << 8U;
364 outred = DMA2D_ColorStruct->OutputRed << 16U;
365 outalpha = DMA2D_ColorStruct->OutputAlpha << 24U;
367 else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888)
369 outgreen = DMA2D_ColorStruct->OutputGreen << 8U;
370 outred = DMA2D_ColorStruct->OutputRed << 16U;
371 outalpha = 0x00000000U;
373 else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565)
375 outgreen = DMA2D_ColorStruct->OutputGreen << 5U;
376 outred = DMA2D_ColorStruct->OutputRed << 11U;
377 outalpha = 0x00000000U;
379 else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
381 outgreen = DMA2D_ColorStruct->OutputGreen << 5U;
382 outred = DMA2D_ColorStruct->OutputRed << 10U;
383 outalpha = DMA2D_ColorStruct->OutputAlpha << 15U;
385 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
387 outgreen = DMA2D_ColorStruct->OutputGreen << 4U;
388 outred = DMA2D_ColorStruct->OutputRed << 8U;
389 outalpha = DMA2D_ColorStruct->OutputAlpha << 12U;
391 LL_DMA2D_SetOutputColor(DMA2Dx, (outgreen | outred | DMA2D_ColorStruct->OutputBlue | outalpha));
395 * @brief Return DMA2D output Blue color.
396 * @param DMA2Dx DMA2D Instance.
397 * @param ColorMode This parameter can be one of the following values:
398 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
399 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
400 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
401 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
402 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
403 * @retval Output Blue color value between Min_Data=0 and Max_Data=0xFF
405 uint32_t LL_DMA2D_GetOutputBlueColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode)
407 uint32_t color = 0U;
409 /* Check the parameters */
410 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
411 assert_param(IS_LL_DMA2D_OCMODE(ColorMode));
413 /* DMA2D OCOLR register reading ------------------------------------------*/
414 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
416 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFFU));
418 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888)
420 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFFU));
422 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565)
424 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x1FU));
426 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
428 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x1FU));
430 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
432 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFU));
435 return color;
439 * @brief Return DMA2D output Green color.
440 * @param DMA2Dx DMA2D Instance.
441 * @param ColorMode This parameter can be one of the following values:
442 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
443 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
444 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
445 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
446 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
447 * @retval Output Green color value between Min_Data=0 and Max_Data=0xFF
449 uint32_t LL_DMA2D_GetOutputGreenColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode)
451 uint32_t color = 0U;
453 /* Check the parameters */
454 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
455 assert_param(IS_LL_DMA2D_OCMODE(ColorMode));
457 /* DMA2D OCOLR register reading ------------------------------------------*/
458 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
460 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF00U) >> 8U);
462 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888)
464 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF00U) >> 8U);
466 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565)
468 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x7E0U) >> 5U);
470 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
472 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x3E0U) >> 5U);
474 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
476 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF0U) >> 4U);
479 return color;
483 * @brief Return DMA2D output Red color.
484 * @param DMA2Dx DMA2D Instance.
485 * @param ColorMode This parameter can be one of the following values:
486 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
487 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
488 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
489 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
490 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
491 * @retval Output Red color value between Min_Data=0 and Max_Data=0xFF
493 uint32_t LL_DMA2D_GetOutputRedColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode)
495 uint32_t color = 0U;
497 /* Check the parameters */
498 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
499 assert_param(IS_LL_DMA2D_OCMODE(ColorMode));
501 /* DMA2D OCOLR register reading ------------------------------------------*/
502 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
504 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF0000U) >> 16U);
506 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888)
508 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF0000U) >> 16U);
510 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565)
512 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF800U) >> 11U);
514 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
516 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x7C00U) >> 10U);
518 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
520 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF00U) >> 8U);
523 return color;
527 * @brief Return DMA2D output Alpha color.
528 * @param DMA2Dx DMA2D Instance.
529 * @param ColorMode This parameter can be one of the following values:
530 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888
531 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888
532 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565
533 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555
534 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444
535 * @retval Output Alpha color value between Min_Data=0 and Max_Data=0xFF
537 uint32_t LL_DMA2D_GetOutputAlphaColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode)
539 uint32_t color = 0U;
541 /* Check the parameters */
542 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx));
543 assert_param(IS_LL_DMA2D_OCMODE(ColorMode));
545 /* DMA2D OCOLR register reading ------------------------------------------*/
546 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888)
548 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF000000U) >> 24U);
550 else if ((ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888) || (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565))
552 color = 0x0U;
554 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555)
556 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x8000U) >> 15U);
558 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */
560 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF000U) >> 12U);
563 return color;
567 * @brief Configure DMA2D transfer size.
568 * @param DMA2Dx DMA2D Instance
569 * @param NbrOfLines Value between Min_Data=0 and Max_Data=0xFFFF
570 * @param NbrOfPixelsPerLines Value between Min_Data=0 and Max_Data=0x3FFF
571 * @retval None
573 void LL_DMA2D_ConfigSize(DMA2D_TypeDef *DMA2Dx, uint32_t NbrOfLines, uint32_t NbrOfPixelsPerLines)
575 MODIFY_REG(DMA2Dx->NLR, (DMA2D_NLR_PL | DMA2D_NLR_NL), \
576 ((NbrOfPixelsPerLines << DMA2D_NLR_PL_Pos) | NbrOfLines));
580 * @}
584 * @}
588 * @}
591 #endif /* defined (DMA2D) */
594 * @}
597 #endif /* USE_FULL_LL_DRIVER */
599 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/