STM32F439xx 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) 2017 STMicroelectronics</center></h2> 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00028 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00030 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 * 00033 ****************************************************************************** 00034 */ 00035 #if defined(USE_FULL_LL_DRIVER) 00036 00037 /* Includes ------------------------------------------------------------------*/ 00038 #include "stm32f4xx_ll_dma2d.h" 00039 #include "stm32f4xx_ll_bus.h" 00040 #ifdef USE_FULL_ASSERT 00041 #include "stm32_assert.h" 00042 #else 00043 #define assert_param(expr) ((void)0U) 00044 #endif 00045 00046 /** @addtogroup STM32F4xx_LL_Driver 00047 * @{ 00048 */ 00049 00050 #if defined (DMA2D) 00051 00052 /** @addtogroup DMA2D_LL 00053 * @{ 00054 */ 00055 00056 /* Private types -------------------------------------------------------------*/ 00057 /* Private variables ---------------------------------------------------------*/ 00058 /* Private constants ---------------------------------------------------------*/ 00059 /** @addtogroup DMA2D_LL_Private_Constants DMA2D Private Constants 00060 * @{ 00061 */ 00062 #define LL_DMA2D_COLOR 0xFFU /*!< Maximum output color setting */ 00063 #define LL_DMA2D_NUMBEROFLINES DMA2D_NLR_NL /*!< Maximum number of lines */ 00064 #define LL_DMA2D_NUMBEROFPIXELS (DMA2D_NLR_PL >> DMA2D_NLR_PL_Pos) /*!< Maximum number of pixels per lines */ 00065 #define LL_DMA2D_OFFSET_MAX 0x3FFFU /*!< Maximum output line offset expressed in pixels */ 00066 #define LL_DMA2D_CLUTSIZE_MAX 0xFFU /*!< Maximum CLUT size */ 00067 /** 00068 * @} 00069 */ 00070 /* Private macros ------------------------------------------------------------*/ 00071 /** @addtogroup DMA2D_LL_Private_Macros 00072 * @{ 00073 */ 00074 #define IS_LL_DMA2D_MODE(MODE) (((MODE) == LL_DMA2D_MODE_M2M) || \ 00075 ((MODE) == LL_DMA2D_MODE_M2M_PFC) || \ 00076 ((MODE) == LL_DMA2D_MODE_M2M_BLEND) || \ 00077 ((MODE) == LL_DMA2D_MODE_R2M)) 00078 00079 #define IS_LL_DMA2D_OCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB8888) || \ 00080 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB888) || \ 00081 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_RGB565) || \ 00082 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB1555) || \ 00083 ((MODE_ARGB) == LL_DMA2D_OUTPUT_MODE_ARGB4444)) 00084 00085 #define IS_LL_DMA2D_GREEN(GREEN) ((GREEN) <= LL_DMA2D_COLOR) 00086 #define IS_LL_DMA2D_RED(RED) ((RED) <= LL_DMA2D_COLOR) 00087 #define IS_LL_DMA2D_BLUE(BLUE) ((BLUE) <= LL_DMA2D_COLOR) 00088 #define IS_LL_DMA2D_ALPHA(ALPHA) ((ALPHA) <= LL_DMA2D_COLOR) 00089 00090 #define IS_LL_DMA2D_OFFSET(OFFSET) ((OFFSET) <= LL_DMA2D_OFFSET_MAX) 00091 00092 #define IS_LL_DMA2D_LINE(LINES) ((LINES) <= LL_DMA2D_NUMBEROFLINES) 00093 #define IS_LL_DMA2D_PIXEL(PIXELS) ((PIXELS) <= LL_DMA2D_NUMBEROFPIXELS) 00094 00095 #define IS_LL_DMA2D_LCMODE(MODE_ARGB) (((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB8888) || \ 00096 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB888) || \ 00097 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_RGB565) || \ 00098 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB1555) || \ 00099 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_ARGB4444) || \ 00100 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L8) || \ 00101 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL44) || \ 00102 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_AL88) || \ 00103 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_L4) || \ 00104 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A8) || \ 00105 ((MODE_ARGB) == LL_DMA2D_INPUT_MODE_A4)) 00106 00107 #define IS_LL_DMA2D_CLUTCMODE(CLUTCMODE) (((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_ARGB8888) || \ 00108 ((CLUTCMODE) == LL_DMA2D_CLUT_COLOR_MODE_RGB888)) 00109 00110 #define IS_LL_DMA2D_CLUTSIZE(SIZE) ((SIZE) <= LL_DMA2D_CLUTSIZE_MAX) 00111 00112 #define IS_LL_DMA2D_ALPHAMODE(MODE) (((MODE) == LL_DMA2D_ALPHA_MODE_NO_MODIF) || \ 00113 ((MODE) == LL_DMA2D_ALPHA_MODE_REPLACE) || \ 00114 ((MODE) == LL_DMA2D_ALPHA_MODE_COMBINE)) 00115 /** 00116 * @} 00117 */ 00118 00119 /* Private function prototypes -----------------------------------------------*/ 00120 00121 /* Exported functions --------------------------------------------------------*/ 00122 /** @addtogroup DMA2D_LL_Exported_Functions 00123 * @{ 00124 */ 00125 00126 /** @addtogroup DMA2D_LL_EF_Init_Functions Initialization and De-initialization Functions 00127 * @{ 00128 */ 00129 00130 /** 00131 * @brief De-initialize DMA2D registers (registers restored to their default values). 00132 * @param DMA2Dx DMA2D Instance 00133 * @retval An ErrorStatus enumeration value: 00134 * - SUCCESS: DMA2D registers are de-initialized 00135 * - ERROR: DMA2D registers are not de-initialized 00136 */ 00137 ErrorStatus LL_DMA2D_DeInit(DMA2D_TypeDef *DMA2Dx) 00138 { 00139 ErrorStatus status = SUCCESS; 00140 00141 /* Check the parameters */ 00142 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); 00143 00144 if (DMA2Dx == DMA2D) 00145 { 00146 /* Force reset of DMA2D clock */ 00147 LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_DMA2D); 00148 00149 /* Release reset of DMA2D clock */ 00150 LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_DMA2D); 00151 } 00152 else 00153 { 00154 status = ERROR; 00155 } 00156 00157 return (status); 00158 } 00159 00160 /** 00161 * @brief Initialize DMA2D registers according to the specified parameters in DMA2D_InitStruct. 00162 * @note DMA2D transfers must be disabled to set initialization bits in configuration registers, 00163 * otherwise ERROR result is returned. 00164 * @param DMA2Dx DMA2D Instance 00165 * @param DMA2D_InitStruct pointer to a LL_DMA2D_InitTypeDef structure 00166 * that contains the configuration information for the specified DMA2D peripheral. 00167 * @retval An ErrorStatus enumeration value: 00168 * - SUCCESS: DMA2D registers are initialized according to DMA2D_InitStruct content 00169 * - ERROR: Issue occurred during DMA2D registers initialization 00170 */ 00171 ErrorStatus LL_DMA2D_Init(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_InitTypeDef *DMA2D_InitStruct) 00172 { 00173 ErrorStatus status = ERROR; 00174 LL_DMA2D_ColorTypeDef DMA2D_ColorStruct; 00175 uint32_t tmp = 0U, tmp1 = 0U, tmp2 = 0U; 00176 00177 /* Check the parameters */ 00178 assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); 00179 assert_param(IS_LL_DMA2D_MODE(DMA2D_InitStruct->Mode)); 00180 assert_param(IS_LL_DMA2D_OCMODE(DMA2D_InitStruct->ColorMode)); 00181 assert_param(IS_LL_DMA2D_LINE(DMA2D_InitStruct->NbrOfLines)); 00182 assert_param(IS_LL_DMA2D_PIXEL(DMA2D_InitStruct->NbrOfPixelsPerLines)); 00183 assert_param(IS_LL_DMA2D_GREEN(DMA2D_InitStruct->OutputGreen)); 00184 assert_param(IS_LL_DMA2D_RED(DMA2D_InitStruct->OutputRed)); 00185 assert_param(IS_LL_DMA2D_BLUE(DMA2D_InitStruct->OutputBlue)); 00186 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_InitStruct->OutputAlpha)); 00187 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_InitStruct->LineOffset)); 00188 00189 /* DMA2D transfers must be disabled to configure bits in initialization registers */ 00190 tmp = LL_DMA2D_IsTransferOngoing(DMA2Dx); 00191 tmp1 = LL_DMA2D_FGND_IsEnabledCLUTLoad(DMA2Dx); 00192 tmp2 = LL_DMA2D_BGND_IsEnabledCLUTLoad(DMA2Dx); 00193 if ((tmp == 0U) && (tmp1 == 0U) && (tmp2 == 0U)) 00194 { 00195 /* DMA2D CR register configuration -------------------------------------------*/ 00196 LL_DMA2D_SetMode(DMA2Dx, DMA2D_InitStruct->Mode); 00197 00198 /* DMA2D OPFCCR register configuration ---------------------------------------*/ 00199 MODIFY_REG(DMA2Dx->OPFCCR, DMA2D_OPFCCR_CM, DMA2D_InitStruct->ColorMode); 00200 00201 /* DMA2D OOR register configuration ------------------------------------------*/ 00202 LL_DMA2D_SetLineOffset(DMA2Dx, DMA2D_InitStruct->LineOffset); 00203 00204 /* DMA2D NLR register configuration ------------------------------------------*/ 00205 LL_DMA2D_ConfigSize(DMA2Dx, DMA2D_InitStruct->NbrOfLines, DMA2D_InitStruct->NbrOfPixelsPerLines); 00206 00207 /* DMA2D OMAR register configuration ------------------------------------------*/ 00208 LL_DMA2D_SetOutputMemAddr(DMA2Dx, DMA2D_InitStruct->OutputMemoryAddress); 00209 00210 /* DMA2D OCOLR register configuration ------------------------------------------*/ 00211 DMA2D_ColorStruct.ColorMode = DMA2D_InitStruct->ColorMode; 00212 DMA2D_ColorStruct.OutputBlue = DMA2D_InitStruct->OutputBlue; 00213 DMA2D_ColorStruct.OutputGreen = DMA2D_InitStruct->OutputGreen; 00214 DMA2D_ColorStruct.OutputRed = DMA2D_InitStruct->OutputRed; 00215 DMA2D_ColorStruct.OutputAlpha = DMA2D_InitStruct->OutputAlpha; 00216 LL_DMA2D_ConfigOutputColor(DMA2Dx, &DMA2D_ColorStruct); 00217 00218 status = SUCCESS; 00219 } 00220 /* If DMA2D transfers are not disabled, return ERROR */ 00221 00222 return (status); 00223 } 00224 00225 /** 00226 * @brief Set each @ref LL_DMA2D_InitTypeDef field to default value. 00227 * @param DMA2D_InitStruct pointer to a @ref LL_DMA2D_InitTypeDef structure 00228 * whose fields will be set to default values. 00229 * @retval None 00230 */ 00231 void LL_DMA2D_StructInit(LL_DMA2D_InitTypeDef *DMA2D_InitStruct) 00232 { 00233 /* Set DMA2D_InitStruct fields to default values */ 00234 DMA2D_InitStruct->Mode = LL_DMA2D_MODE_M2M; 00235 DMA2D_InitStruct->ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB8888; 00236 DMA2D_InitStruct->NbrOfLines = 0x0U; 00237 DMA2D_InitStruct->NbrOfPixelsPerLines = 0x0U; 00238 DMA2D_InitStruct->LineOffset = 0x0U; 00239 DMA2D_InitStruct->OutputBlue = 0x0U; 00240 DMA2D_InitStruct->OutputGreen = 0x0U; 00241 DMA2D_InitStruct->OutputRed = 0x0U; 00242 DMA2D_InitStruct->OutputAlpha = 0x0U; 00243 DMA2D_InitStruct->OutputMemoryAddress = 0x0U; 00244 } 00245 00246 /** 00247 * @brief Configure the foreground or background according to the specified parameters 00248 * in the LL_DMA2D_LayerCfgTypeDef structure. 00249 * @param DMA2Dx DMA2D Instance 00250 * @param DMA2D_LayerCfg pointer to a LL_DMA2D_LayerCfgTypeDef structure that contains 00251 * the configuration information for the specified layer. 00252 * @param LayerIdx DMA2D Layer index. 00253 * This parameter can be one of the following values: 00254 * 0(background) / 1(foreground) 00255 * @retval None 00256 */ 00257 void LL_DMA2D_ConfigLayer(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_LayerCfgTypeDef *DMA2D_LayerCfg, uint32_t LayerIdx) 00258 { 00259 /* Check the parameters */ 00260 assert_param(IS_LL_DMA2D_OFFSET(DMA2D_LayerCfg->LineOffset)); 00261 assert_param(IS_LL_DMA2D_LCMODE(DMA2D_LayerCfg->ColorMode)); 00262 assert_param(IS_LL_DMA2D_CLUTCMODE(DMA2D_LayerCfg->CLUTColorMode)); 00263 assert_param(IS_LL_DMA2D_CLUTSIZE(DMA2D_LayerCfg->CLUTSize)); 00264 assert_param(IS_LL_DMA2D_ALPHAMODE(DMA2D_LayerCfg->AlphaMode)); 00265 assert_param(IS_LL_DMA2D_GREEN(DMA2D_LayerCfg->Green)); 00266 assert_param(IS_LL_DMA2D_RED(DMA2D_LayerCfg->Red)); 00267 assert_param(IS_LL_DMA2D_BLUE(DMA2D_LayerCfg->Blue)); 00268 assert_param(IS_LL_DMA2D_ALPHA(DMA2D_LayerCfg->Alpha)); 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 = 0U; 00347 uint32_t outred = 0U; 00348 uint32_t outalpha = 0U; 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 = 0U; 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 = 0U; 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 = 0U; 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 = 0U; 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****/