STM32F479xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_ll_dma2d.c 00004 * @author MCD Application Team 00005 * @brief DMA2D LL module driver. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© Copyright (c) 2016 STMicroelectronics. 00010 * All rights reserved.</center></h2> 00011 * 00012 * This software component is licensed by ST under BSD 3-Clause license, 00013 * the "License"; You may not use this file except in compliance with the 00014 * License. You may obtain a copy of the License at: 00015 * opensource.org/licenses/BSD-3-Clause 00016 * 00017 ****************************************************************************** 00018 */ 00019 #if defined(USE_FULL_LL_DRIVER) 00020 00021 /* Includes ------------------------------------------------------------------*/ 00022 #include "stm32f4xx_ll_dma2d.h" 00023 #include "stm32f4xx_ll_bus.h" 00024 #ifdef USE_FULL_ASSERT 00025 #include "stm32_assert.h" 00026 #else 00027 #define assert_param(expr) ((void)0U) 00028 #endif /* USE_FULL_ASSERT */ 00029 00030 /** @addtogroup STM32F4xx_LL_Driver 00031 * @{ 00032 */ 00033 00034 #if defined (DMA2D) 00035 00036 /** @addtogroup DMA2D_LL 00037 * @{ 00038 */ 00039 00040 /* Private types -------------------------------------------------------------*/ 00041 /* Private variables ---------------------------------------------------------*/ 00042 /* Private constants ---------------------------------------------------------*/ 00043 /** @addtogroup DMA2D_LL_Private_Constants DMA2D Private Constants 00044 * @{ 00045 */ 00046 #define LL_DMA2D_COLOR 0xFFU /*!< Maximum output color setting */ 00047 #define LL_DMA2D_NUMBEROFLINES DMA2D_NLR_NL /*!< Maximum number of lines */ 00048 #define LL_DMA2D_NUMBEROFPIXELS (DMA2D_NLR_PL >> DMA2D_NLR_PL_Pos) /*!< Maximum number of pixels per lines */ 00049 #define LL_DMA2D_OFFSET_MAX 0x3FFFU /*!< Maximum output line offset expressed in pixels */ 00050 #define LL_DMA2D_CLUTSIZE_MAX 0xFFU /*!< Maximum CLUT size */ 00051 /** 00052 * @} 00053 */ 00054 /* Private macros ------------------------------------------------------------*/ 00055 /** @addtogroup DMA2D_LL_Private_Macros 00056 * @{ 00057 */ 00058 #define IS_LL_DMA2D_MODE(MODE) (((MODE) == LL_DMA2D_MODE_M2M) || \ 00059 ((MODE) == LL_DMA2D_MODE_M2M_PFC) || \ 00060 ((MODE) == LL_DMA2D_MODE_M2M_BLEND) || \ 00061 ((MODE) == LL_DMA2D_MODE_R2M)) 00062 00063 #define IS_LL_DMA2D_OCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB8888) || \ 00064 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB888) || \ 00065 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB565) || \ 00066 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB1555) || \ 00067 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB4444)) 00068 00069 #define IS_LL_DMA2D_GREEN(GREEN) ((GREEN) <= LL_DMA2D_COLOR) 00070 #define IS_LL_DMA2D_RED(RED) ((RED) <= LL_DMA2D_COLOR) 00071 #define IS_LL_DMA2D_BLUE(BLUE) ((BLUE) <= LL_DMA2D_COLOR) 00072 #define IS_LL_DMA2D_ALPHA(ALPHA) ((ALPHA) <= LL_DMA2D_COLOR) 00073 00074 00075 #define IS_LL_DMA2D_OFFSET(OFFSET) ((OFFSET) <= LL_DMA2D_OFFSET_MAX) 00076 00077 #define IS_LL_DMA2D_LINE(LINES) ((LINES) <= LL_DMA2D_NUMBEROFLINES) 00078 #define IS_LL_DMA2D_PIXEL(PIXELS) ((PIXELS) <= LL_DMA2D_NUMBEROFPIXELS) 00079 00080 00081 00082 #define IS_LL_DMA2D_LCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB8888) || \ 00083 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB888) || \ 00084 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB565) || \ 00085 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB1555) || \ 00086 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB4444) || \ 00087 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L8) || \ 00088 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL44) || \ 00089 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL88) || \ 00090 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L4) || \ 00091 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A8) || \ 00092 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A4)) 00093 00094 #define IS_LL_DMA2D_CLUTCMODE(CLUTCMODE) (((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_ARGB8888) || \ 00095 ((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_RGB888)) 00096 00097 #define IS_LL_DMA2D_CLUTSIZE(SIZE) ((SIZE) <= LL_DMA2D_CLUTSIZE_MAX) 00098 00099 #define IS_LL_DMA2D_ALPHAMODE(MODE) (((MODE) == LL_DMA2D_ALPHA_MODE_NO_MODIF) || \ 00100 ((MODE) == LL_DMA2D_ALPHA_MODE_REPLACE) || \ 00101 ((MODE) == LL_DMA2D_ALPHA_MODE_COMBINE)) 00102 00103 00104 /** 00105 * @} 00106 */ 00107 00108 /* Private function prototypes -----------------------------------------------*/ 00109 00110 /* Exported functions --------------------------------------------------------*/ 00111 /** @addtogroup DMA2D_LL_Exported_Functions 00112 * @{ 00113 */ 00114 00115 /** @addtogroup DMA2D_LL_EF_Init_Functions Initialization and De-initialization Functions 00116 * @{ 00117 */ 00118 00119 /** 00120 * @brief De-initialize DMA2D registers (registers restored to their default values). 00121 * @param DMA2Dx DMA2D Instance 00122 * @retval An ErrorStatus enumeration value: 00123 * - SUCCESS: DMA2D registers are de-initialized 00124 * - ERROR: DMA2D registers are not de-initialized 00125 */ 00126 ErrorStatus LL_DMA2D_DeInit(DMA2D_TypeDef *DMA2Dx) 00127 { 00128 ErrorStatus status = SUCCESS; 00129 00130 /* Check the parameters */ 00131 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); 00132 00133 if (DMA2Dx == DMA2D) 00134 { 00135 /* Force reset of DMA2D clock */ 00136 LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_DMA2D); 00137 00138 /* Release reset of DMA2D clock */ 00139 LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_DMA2D); 00140 } 00141 else 00142 { 00143 status = ERROR; 00144 } 00145 00146 return (status); 00147 } 00148 00149 /** 00150 * @brief Initialize DMA2D registers according to the specified parameters in DMA2D_InitStruct. 00151 * @note DMA2D transfers must be disabled to set initialization bits in configuration registers, 00152 * otherwise ERROR result is returned. 00153 * @param DMA2Dx DMA2D Instance 00154 * @param DMA2D_InitStruct pointer to a LL_DMA2D_InitTypeDef structure 00155 * that contains the configuration information for the specified DMA2D peripheral. 00156 * @retval An ErrorStatus enumeration value: 00157 * - SUCCESS: DMA2D registers are initialized according to DMA2D_InitStruct content 00158 * - ERROR: Issue occurred during DMA2D registers initialization 00159 */ 00160 ErrorStatus LL_DMA2D_Init(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_InitTypeDef *DMA2D_InitStruct) 00161 { 00162 ErrorStatus status = ERROR; 00163 LL_DMA2D_ColorTypeDef dma2d_colorstruct; 00164 uint32_t tmp; 00165 uint32_t tmp1; 00166 uint32_t tmp2; 00167 uint32_t regMask; 00168 uint32_t regValue; 00169 00170 /* Check the parameters */ 00171 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); 00172 assert_param(IS_LL_DMA2D_MODE(DMA2D_InitStruct->Mode)); 00173 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_InitStruct->ColorMode)); 00174 assert_param(IS_LL_DMA2D_LINE(DMA2D_InitStruct->NbrOfLines)); 00175 assert_param(IS_LL_DMA2D_PIXEL(DMA2D_InitStruct->NbrOfPixelsPerLines)); 00176 assert_param(IS_LL_DMA2D_GREEN(DMA2D_InitStruct->OutputGreen)); 00177 assert_param(IS_LL_DMA2D_RED(DMA2D_InitStruct->OutputRed)); 00178 assert_param(IS_LL_DMA2D_BLUE(DMA2D_InitStruct->OutputBlue)); 00179 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_InitStruct->OutputAlpha)); 00180 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_InitStruct->LineOffset)); 00181 00182 /* DMA2D transfers must be disabled to configure bits in initialization registers */ 00183 tmp = LL_DMA2D_IsTransferOngoing(DMA2Dx); 00184 tmp1 = LL_DMA2D_FGND_IsEnabledCLUTLoad(DMA2Dx); 00185 tmp2 = LL_DMA2D_BGND_IsEnabledCLUTLoad(DMA2Dx); 00186 if ((tmp == 0U) && (tmp1 == 0U) && (tmp2 == 0U)) 00187 { 00188 /* DMA2D CR register configuration -------------------------------------------*/ 00189 LL_DMA2D_SetMode(DMA2Dx, DMA2D_InitStruct->Mode); 00190 00191 /* DMA2D OPFCCR register configuration ---------------------------------------*/ 00192 regMask = DMA2D_OPFCCR_CM; 00193 regValue = DMA2D_InitStruct->ColorMode; 00194 00195 00196 00197 00198 MODIFY_REG(DMA2Dx->OPFCCR, regMask, regValue); 00199 00200 /* DMA2D OOR register configuration ------------------------------------------*/ 00201 LL_DMA2D_SetLineOffset(DMA2Dx, DMA2D_InitStruct->LineOffset); 00202 00203 /* DMA2D NLR register configuration ------------------------------------------*/ 00204 LL_DMA2D_ConfigSize(DMA2Dx, DMA2D_InitStruct->NbrOfLines, DMA2D_InitStruct->NbrOfPixelsPerLines); 00205 00206 /* DMA2D OMAR register configuration ------------------------------------------*/ 00207 LL_DMA2D_SetOutputMemAddr(DMA2Dx, DMA2D_InitStruct->OutputMemoryAddress); 00208 00209 /* DMA2D OCOLR register configuration ------------------------------------------*/ 00210 dma2d_colorstruct.ColorMode = DMA2D_InitStruct->ColorMode; 00211 dma2d_colorstruct.OutputBlue = DMA2D_InitStruct->OutputBlue; 00212 dma2d_colorstruct.OutputGreen = DMA2D_InitStruct->OutputGreen; 00213 dma2d_colorstruct.OutputRed = DMA2D_InitStruct->OutputRed; 00214 dma2d_colorstruct.OutputAlpha = DMA2D_InitStruct->OutputAlpha; 00215 LL_DMA2D_ConfigOutputColor(DMA2Dx, &dma2d_colorstruct); 00216 00217 status = SUCCESS; 00218 } 00219 /* If DMA2D transfers are not disabled, return ERROR */ 00220 00221 return (status); 00222 } 00223 00224 /** 00225 * @brief Set each @ref LL_DMA2D_InitTypeDef field to default value. 00226 * @param DMA2D_InitStruct pointer to a @ref LL_DMA2D_InitTypeDef structure 00227 * whose fields will be set to default values. 00228 * @retval None 00229 */ 00230 void LL_DMA2D_StructInit(LL_DMA2D_InitTypeDef *DMA2D_InitStruct) 00231 { 00232 /* Set DMA2D_InitStruct fields to default values */ 00233 DMA2D_InitStruct->Mode = LL_DMA2D_MODE_M2M; 00234 DMA2D_InitStruct->ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB8888; 00235 DMA2D_InitStruct->NbrOfLines = 0x0U; 00236 DMA2D_InitStruct->NbrOfPixelsPerLines = 0x0U; 00237 DMA2D_InitStruct->LineOffset = 0x0U; 00238 DMA2D_InitStruct->OutputBlue = 0x0U; 00239 DMA2D_InitStruct->OutputGreen = 0x0U; 00240 DMA2D_InitStruct->OutputRed = 0x0U; 00241 DMA2D_InitStruct->OutputAlpha = 0x0U; 00242 DMA2D_InitStruct->OutputMemoryAddress = 0x0U; 00243 } 00244 00245 /** 00246 * @brief Configure the foreground or background according to the specified parameters 00247 * in the LL_DMA2D_LayerCfgTypeDef structure. 00248 * @param DMA2Dx DMA2D Instance 00249 * @param DMA2D_LayerCfg pointer to a LL_DMA2D_LayerCfgTypeDef structure that contains 00250 * the configuration information for the specified layer. 00251 * @param LayerIdx DMA2D Layer index. 00252 * This parameter can be one of the following values: 00253 * 0(background) / 1(foreground) 00254 * @retval None 00255 */ 00256 void LL_DMA2D_ConfigLayer(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_LayerCfgTypeDef *DMA2D_LayerCfg, uint32_t LayerIdx) 00257 { 00258 /* Check the parameters */ 00259 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_LayerCfg->LineOffset)); 00260 assert_param(IS_LL_DMA2D_LCMODE(DMA2D_LayerCfg->ColorMode)); 00261 assert_param(IS_LL_DMA2D_CLUTCMODE(DMA2D_LayerCfg->CLUTColorMode)); 00262 assert_param(IS_LL_DMA2D_CLUTSIZE(DMA2D_LayerCfg->CLUTSize)); 00263 assert_param(IS_LL_DMA2D_ALPHAMODE(DMA2D_LayerCfg->AlphaMode)); 00264 assert_param(IS_LL_DMA2D_GREEN(DMA2D_LayerCfg->Green)); 00265 assert_param(IS_LL_DMA2D_RED(DMA2D_LayerCfg->Red)); 00266 assert_param(IS_LL_DMA2D_BLUE(DMA2D_LayerCfg->Blue)); 00267 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_LayerCfg->Alpha)); 00268 00269 00270 if (LayerIdx == 0U) 00271 { 00272 /* Configure the background memory address */ 00273 LL_DMA2D_BGND_SetMemAddr(DMA2Dx, DMA2D_LayerCfg->MemoryAddress); 00274 00275 /* Configure the background line offset */ 00276 LL_DMA2D_BGND_SetLineOffset(DMA2Dx, DMA2D_LayerCfg->LineOffset); 00277 00278 /* Configure the background Alpha value, Alpha mode, CLUT size, CLUT Color mode and Color mode */ 00279 MODIFY_REG(DMA2Dx->BGPFCCR, \ 00280 (DMA2D_BGPFCCR_ALPHA | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM | DMA2D_BGPFCCR_CM), \ 00281 ((DMA2D_LayerCfg->Alpha << DMA2D_BGPFCCR_ALPHA_Pos) | DMA2D_LayerCfg->AlphaMode | \ 00282 (DMA2D_LayerCfg->CLUTSize << DMA2D_BGPFCCR_CS_Pos) | DMA2D_LayerCfg->CLUTColorMode | \ 00283 DMA2D_LayerCfg->ColorMode)); 00284 00285 /* Configure the background color */ 00286 LL_DMA2D_BGND_SetColor(DMA2Dx, DMA2D_LayerCfg->Red, DMA2D_LayerCfg->Green, DMA2D_LayerCfg->Blue); 00287 00288 /* Configure the background CLUT memory address */ 00289 LL_DMA2D_BGND_SetCLUTMemAddr(DMA2Dx, DMA2D_LayerCfg->CLUTMemoryAddress); 00290 } 00291 else 00292 { 00293 /* Configure the foreground memory address */ 00294 LL_DMA2D_FGND_SetMemAddr(DMA2Dx, DMA2D_LayerCfg->MemoryAddress); 00295 00296 /* Configure the foreground line offset */ 00297 LL_DMA2D_FGND_SetLineOffset(DMA2Dx, DMA2D_LayerCfg->LineOffset); 00298 00299 /* Configure the foreground Alpha value, Alpha mode, CLUT size, CLUT Color mode and Color mode */ 00300 MODIFY_REG(DMA2Dx->FGPFCCR, \ 00301 (DMA2D_FGPFCCR_ALPHA | DMA2D_FGPFCCR_AM | DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM | DMA2D_FGPFCCR_CM), \ 00302 ((DMA2D_LayerCfg->Alpha << DMA2D_FGPFCCR_ALPHA_Pos) | DMA2D_LayerCfg->AlphaMode | \ 00303 (DMA2D_LayerCfg->CLUTSize << DMA2D_FGPFCCR_CS_Pos) | DMA2D_LayerCfg->CLUTColorMode | \ 00304 DMA2D_LayerCfg->ColorMode)); 00305 00306 /* Configure the foreground color */ 00307 LL_DMA2D_FGND_SetColor(DMA2Dx, DMA2D_LayerCfg->Red, DMA2D_LayerCfg->Green, DMA2D_LayerCfg->Blue); 00308 00309 /* Configure the foreground CLUT memory address */ 00310 LL_DMA2D_FGND_SetCLUTMemAddr(DMA2Dx, DMA2D_LayerCfg->CLUTMemoryAddress); 00311 } 00312 } 00313 00314 /** 00315 * @brief Set each @ref LL_DMA2D_LayerCfgTypeDef field to default value. 00316 * @param DMA2D_LayerCfg pointer to a @ref LL_DMA2D_LayerCfgTypeDef structure 00317 * whose fields will be set to default values. 00318 * @retval None 00319 */ 00320 void LL_DMA2D_LayerCfgStructInit(LL_DMA2D_LayerCfgTypeDef *DMA2D_LayerCfg) 00321 { 00322 /* Set DMA2D_LayerCfg fields to default values */ 00323 DMA2D_LayerCfg->MemoryAddress = 0x0U; 00324 DMA2D_LayerCfg->ColorMode = LL_DMA2D_INPUT_MODE_ARGB8888; 00325 DMA2D_LayerCfg->LineOffset = 0x0U; 00326 DMA2D_LayerCfg->CLUTColorMode = LL_DMA2D_CLUT_COLOR_MODE_ARGB8888; 00327 DMA2D_LayerCfg->CLUTSize = 0x0U; 00328 DMA2D_LayerCfg->AlphaMode = LL_DMA2D_ALPHA_MODE_NO_MODIF; 00329 DMA2D_LayerCfg->Alpha = 0x0U; 00330 DMA2D_LayerCfg->Blue = 0x0U; 00331 DMA2D_LayerCfg->Green = 0x0U; 00332 DMA2D_LayerCfg->Red = 0x0U; 00333 DMA2D_LayerCfg->CLUTMemoryAddress = 0x0U; 00334 } 00335 00336 /** 00337 * @brief Initialize DMA2D output color register according to the specified parameters 00338 * in DMA2D_ColorStruct. 00339 * @param DMA2Dx DMA2D Instance 00340 * @param DMA2D_ColorStruct pointer to a LL_DMA2D_ColorTypeDef structure that contains 00341 * the color configuration information for the specified DMA2D peripheral. 00342 * @retval None 00343 */ 00344 void LL_DMA2D_ConfigOutputColor(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_ColorTypeDef *DMA2D_ColorStruct) 00345 { 00346 uint32_t outgreen; 00347 uint32_t outred; 00348 uint32_t outalpha; 00349 00350 /* Check the parameters */ 00351 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); 00352 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_ColorStruct->ColorMode)); 00353 assert_param(IS_LL_DMA2D_GREEN(DMA2D_ColorStruct->OutputGreen)); 00354 assert_param(IS_LL_DMA2D_RED(DMA2D_ColorStruct->OutputRed)); 00355 assert_param(IS_LL_DMA2D_BLUE(DMA2D_ColorStruct->OutputBlue)); 00356 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_ColorStruct->OutputAlpha)); 00357 00358 /* DMA2D OCOLR register configuration ------------------------------------------*/ 00359 if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888) 00360 { 00361 outgreen = DMA2D_ColorStruct->OutputGreen << 8U; 00362 outred = DMA2D_ColorStruct->OutputRed << 16U; 00363 outalpha = DMA2D_ColorStruct->OutputAlpha << 24U; 00364 } 00365 else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888) 00366 { 00367 outgreen = DMA2D_ColorStruct->OutputGreen << 8U; 00368 outred = DMA2D_ColorStruct->OutputRed << 16U; 00369 outalpha = 0x00000000U; 00370 } 00371 else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565) 00372 { 00373 outgreen = DMA2D_ColorStruct->OutputGreen << 5U; 00374 outred = DMA2D_ColorStruct->OutputRed << 11U; 00375 outalpha = 0x00000000U; 00376 } 00377 else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555) 00378 { 00379 outgreen = DMA2D_ColorStruct->OutputGreen << 5U; 00380 outred = DMA2D_ColorStruct->OutputRed << 10U; 00381 outalpha = DMA2D_ColorStruct->OutputAlpha << 15U; 00382 } 00383 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */ 00384 { 00385 outgreen = DMA2D_ColorStruct->OutputGreen << 4U; 00386 outred = DMA2D_ColorStruct->OutputRed << 8U; 00387 outalpha = DMA2D_ColorStruct->OutputAlpha << 12U; 00388 } 00389 LL_DMA2D_SetOutputColor(DMA2Dx, (outgreen | outred | DMA2D_ColorStruct->OutputBlue | outalpha)); 00390 } 00391 00392 /** 00393 * @brief Return DMA2D output Blue color. 00394 * @param DMA2Dx DMA2D Instance. 00395 * @param ColorMode This parameter can be one of the following values: 00396 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888 00397 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888 00398 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565 00399 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555 00400 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444 00401 * @retval Output Blue color value between Min_Data=0 and Max_Data=0xFF 00402 */ 00403 uint32_t LL_DMA2D_GetOutputBlueColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode) 00404 { 00405 uint32_t color; 00406 00407 /* Check the parameters */ 00408 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); 00409 assert_param(IS_LL_DMA2D_OCMODE(ColorMode)); 00410 00411 /* DMA2D OCOLR register reading ------------------------------------------*/ 00412 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888) 00413 { 00414 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFFU)); 00415 } 00416 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888) 00417 { 00418 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFFU)); 00419 } 00420 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565) 00421 { 00422 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x1FU)); 00423 } 00424 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555) 00425 { 00426 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x1FU)); 00427 } 00428 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */ 00429 { 00430 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFU)); 00431 } 00432 00433 return color; 00434 } 00435 00436 /** 00437 * @brief Return DMA2D output Green color. 00438 * @param DMA2Dx DMA2D Instance. 00439 * @param ColorMode This parameter can be one of the following values: 00440 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888 00441 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888 00442 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565 00443 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555 00444 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444 00445 * @retval Output Green color value between Min_Data=0 and Max_Data=0xFF 00446 */ 00447 uint32_t LL_DMA2D_GetOutputGreenColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode) 00448 { 00449 uint32_t color; 00450 00451 /* Check the parameters */ 00452 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); 00453 assert_param(IS_LL_DMA2D_OCMODE(ColorMode)); 00454 00455 /* DMA2D OCOLR register reading ------------------------------------------*/ 00456 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888) 00457 { 00458 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF00U) >> 8U); 00459 } 00460 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888) 00461 { 00462 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF00U) >> 8U); 00463 } 00464 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565) 00465 { 00466 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x7E0U) >> 5U); 00467 } 00468 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555) 00469 { 00470 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x3E0U) >> 5U); 00471 } 00472 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */ 00473 { 00474 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF0U) >> 4U); 00475 } 00476 00477 return color; 00478 } 00479 00480 /** 00481 * @brief Return DMA2D output Red color. 00482 * @param DMA2Dx DMA2D Instance. 00483 * @param ColorMode This parameter can be one of the following values: 00484 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888 00485 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888 00486 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565 00487 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555 00488 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444 00489 * @retval Output Red color value between Min_Data=0 and Max_Data=0xFF 00490 */ 00491 uint32_t LL_DMA2D_GetOutputRedColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode) 00492 { 00493 uint32_t color; 00494 00495 /* Check the parameters */ 00496 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); 00497 assert_param(IS_LL_DMA2D_OCMODE(ColorMode)); 00498 00499 /* DMA2D OCOLR register reading ------------------------------------------*/ 00500 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888) 00501 { 00502 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF0000U) >> 16U); 00503 } 00504 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888) 00505 { 00506 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF0000U) >> 16U); 00507 } 00508 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565) 00509 { 00510 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF800U) >> 11U); 00511 } 00512 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555) 00513 { 00514 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x7C00U) >> 10U); 00515 } 00516 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */ 00517 { 00518 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF00U) >> 8U); 00519 } 00520 00521 return color; 00522 } 00523 00524 /** 00525 * @brief Return DMA2D output Alpha color. 00526 * @param DMA2Dx DMA2D Instance. 00527 * @param ColorMode This parameter can be one of the following values: 00528 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888 00529 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888 00530 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565 00531 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555 00532 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444 00533 * @retval Output Alpha color value between Min_Data=0 and Max_Data=0xFF 00534 */ 00535 uint32_t LL_DMA2D_GetOutputAlphaColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode) 00536 { 00537 uint32_t color; 00538 00539 /* Check the parameters */ 00540 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); 00541 assert_param(IS_LL_DMA2D_OCMODE(ColorMode)); 00542 00543 /* DMA2D OCOLR register reading ------------------------------------------*/ 00544 if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888) 00545 { 00546 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF000000U) >> 24U); 00547 } 00548 else if ((ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888) || (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565)) 00549 { 00550 color = 0x0U; 00551 } 00552 else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555) 00553 { 00554 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x8000U) >> 15U); 00555 } 00556 else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */ 00557 { 00558 color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xF000U) >> 12U); 00559 } 00560 00561 return color; 00562 } 00563 00564 /** 00565 * @brief Configure DMA2D transfer size. 00566 * @param DMA2Dx DMA2D Instance 00567 * @param NbrOfLines Value between Min_Data=0 and Max_Data=0xFFFF 00568 * @param NbrOfPixelsPerLines Value between Min_Data=0 and Max_Data=0x3FFF 00569 * @retval None 00570 */ 00571 void LL_DMA2D_ConfigSize(DMA2D_TypeDef *DMA2Dx, uint32_t NbrOfLines, uint32_t NbrOfPixelsPerLines) 00572 { 00573 MODIFY_REG(DMA2Dx->NLR, (DMA2D_NLR_PL | DMA2D_NLR_NL), \ 00574 ((NbrOfPixelsPerLines << DMA2D_NLR_PL_Pos) | NbrOfLines)); 00575 } 00576 00577 /** 00578 * @} 00579 */ 00580 00581 /** 00582 * @} 00583 */ 00584 00585 /** 00586 * @} 00587 */ 00588 00589 #endif /* defined (DMA2D) */ 00590 00591 /** 00592 * @} 00593 */ 00594 00595 #endif /* USE_FULL_LL_DRIVER */ 00596 00597 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00598