/** * @brief Return DMA2D output Blue color. * @param DMA2Dx DMA2D Instance. * @param ColorMode This parameter can be one of the following values: * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444 * @retval Output Blue color value between Min_Data=0 and Max_Data=0xFF */ uint32_t LL_DMA2D_GetOutputBlueColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode) { uint32_t color = 0U; /* Check the parameters */ assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); assert_param(IS_LL_DMA2D_OCMODE(ColorMode)); /* DMA2D OCOLR register reading ------------------------------------------*/ if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888) { color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFFU)); } else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888) { color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFFU)); } else if (ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565) { color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x1FU)); } else if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555) { color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0x1FU)); } else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */ { color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFU)); } return color; }
/** * @brief Initialize DMA2D registers according to the specified parameters in DMA2D_InitStruct. * @note DMA2D transfers must be disabled to set initialization bits in configuration registers, * otherwise ERROR result is returned. * @param DMA2Dx DMA2D Instance * @param DMA2D_InitStruct: pointer to a LL_DMA2D_InitTypeDef structure * that contains the configuration information for the specified DMA2D peripheral. * @retval An ErrorStatus enumeration value: * - SUCCESS: DMA2D registers are initialized according to DMA2D_InitStruct content * - ERROR: Issue occurred during DMA2D registers initialization */ ErrorStatus LL_DMA2D_Init(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_InitTypeDef *DMA2D_InitStruct) { ErrorStatus status = ERROR; LL_DMA2D_ColorTypeDef DMA2D_ColorStruct; uint32_t tmp = 0U, tmp1 = 0U, tmp2 = 0U; /* Check the parameters */ assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); assert_param(IS_LL_DMA2D_MODE(DMA2D_InitStruct->Mode)); assert_param(IS_LL_DMA2D_OCMODE(DMA2D_InitStruct->ColorMode)); assert_param(IS_LL_DMA2D_LINE(DMA2D_InitStruct->NbrOfLines)); assert_param(IS_LL_DMA2D_PIXEL(DMA2D_InitStruct->NbrOfPixelsPerLines)); assert_param(IS_LL_DMA2D_GREEN(DMA2D_InitStruct->OutputGreen)); assert_param(IS_LL_DMA2D_RED(DMA2D_InitStruct->OutputRed)); assert_param(IS_LL_DMA2D_BLUE(DMA2D_InitStruct->OutputBlue)); assert_param(IS_LL_DMA2D_ALPHA(DMA2D_InitStruct->OutputAlpha)); assert_param(IS_LL_DMA2D_OFFSET(DMA2D_InitStruct->LineOffset)); assert_param(IS_LL_DMA2D_ALPHAINV(DMA2D_InitStruct->AlphaInversionMode)); assert_param(IS_LL_DMA2D_RBSWAP(DMA2D_InitStruct->RBSwapMode)); /* DMA2D transfers must be disabled to configure bits in initialization registers */ tmp = LL_DMA2D_IsTransferOngoing(DMA2Dx); tmp1 = LL_DMA2D_FGND_IsEnabledCLUTLoad(DMA2Dx); tmp2 = LL_DMA2D_BGND_IsEnabledCLUTLoad(DMA2Dx); if ((tmp == 0U) && (tmp1 == 0U) && (tmp2 == 0U)) { /* DMA2D CR register configuration -------------------------------------------*/ LL_DMA2D_SetMode(DMA2Dx, DMA2D_InitStruct->Mode); /* DMA2D OPFCCR register configuration ---------------------------------------*/ MODIFY_REG(DMA2Dx->OPFCCR, (DMA2D_OPFCCR_CM | DMA2D_OPFCCR_RBS | DMA2D_OPFCCR_AI), \ (DMA2D_InitStruct->ColorMode | DMA2D_InitStruct->AlphaInversionMode | DMA2D_InitStruct->RBSwapMode)); /* DMA2D OOR register configuration ------------------------------------------*/ LL_DMA2D_SetLineOffset(DMA2Dx, DMA2D_InitStruct->LineOffset); /* DMA2D NLR register configuration ------------------------------------------*/ LL_DMA2D_ConfigSize(DMA2Dx, DMA2D_InitStruct->NbrOfLines, DMA2D_InitStruct->NbrOfPixelsPerLines); /* DMA2D OMAR register configuration ------------------------------------------*/ LL_DMA2D_SetOutputMemAddr(DMA2Dx, DMA2D_InitStruct->OutputMemoryAddress); /* DMA2D OCOLR register configuration ------------------------------------------*/ DMA2D_ColorStruct.ColorMode = DMA2D_InitStruct->ColorMode; DMA2D_ColorStruct.OutputBlue = DMA2D_InitStruct->OutputBlue; DMA2D_ColorStruct.OutputGreen = DMA2D_InitStruct->OutputGreen; DMA2D_ColorStruct.OutputRed = DMA2D_InitStruct->OutputRed; DMA2D_ColorStruct.OutputAlpha = DMA2D_InitStruct->OutputAlpha; LL_DMA2D_ConfigOutputColor(DMA2Dx, &DMA2D_ColorStruct); status = SUCCESS; } /* If DMA2D transfers are not disabled, return ERROR */ return (status); }
/** * @brief Return DMA2D output Green color. * @param DMA2Dx DMA2D Instance. * @param ColorMode This parameter can be one of the following values: * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB8888 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB888 * @arg @ref LL_DMA2D_OUTPUT_MODE_RGB565 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB1555 * @arg @ref LL_DMA2D_OUTPUT_MODE_ARGB4444 * @retval Output Green color value between Min_Data=0 and Max_Data=0xFF */ uint32_t LL_DMA2D_GetOutputGreenColor(DMA2D_TypeDef *DMA2Dx, uint32_t ColorMode) { uint32_t color = 0U; /* Check the parameters */ assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); assert_param(IS_LL_DMA2D_OCMODE(ColorMode)); /* DMA2D OCOLR register reading ------------------------------------------*/ if (ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888) { color = (uint32_t)(READ_BIT(DMA2Dx->OCOLR, 0xFF00U) >> 8U); }
/** * @brief Initialize DMA2D output color register according to the specified parameters * in DMA2D_ColorStruct. * @param DMA2Dx DMA2D Instance * @param DMA2D_ColorStruct: pointer to a LL_DMA2D_ColorTypeDef structure that contains * the color configuration information for the specified DMA2D peripheral. * @retval None */ void LL_DMA2D_ConfigOutputColor(DMA2D_TypeDef *DMA2Dx, LL_DMA2D_ColorTypeDef *DMA2D_ColorStruct) { uint32_t outgreen = 0U; uint32_t outred = 0U; uint32_t outalpha = 0U; /* Check the parameters */ assert_param(IS_DMA2D_ALL_INSTANCE(DMA2Dx)); assert_param(IS_LL_DMA2D_OCMODE(DMA2D_ColorStruct->ColorMode)); assert_param(IS_LL_DMA2D_GREEN(DMA2D_ColorStruct->OutputGreen)); assert_param(IS_LL_DMA2D_RED(DMA2D_ColorStruct->OutputRed)); assert_param(IS_LL_DMA2D_BLUE(DMA2D_ColorStruct->OutputBlue)); assert_param(IS_LL_DMA2D_ALPHA(DMA2D_ColorStruct->OutputAlpha)); /* DMA2D OCOLR register configuration ------------------------------------------*/ if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB8888) { outgreen = DMA2D_ColorStruct->OutputGreen << 8U; outred = DMA2D_ColorStruct->OutputRed << 16U; outalpha = DMA2D_ColorStruct->OutputAlpha << 24U; } else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_RGB888) { outgreen = DMA2D_ColorStruct->OutputGreen << 8U; outred = DMA2D_ColorStruct->OutputRed << 16U; outalpha = 0x00000000U; } else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_RGB565) { outgreen = DMA2D_ColorStruct->OutputGreen << 5U; outred = DMA2D_ColorStruct->OutputRed << 11U; outalpha = 0x00000000U; } else if (DMA2D_ColorStruct->ColorMode == LL_DMA2D_OUTPUT_MODE_ARGB1555) { outgreen = DMA2D_ColorStruct->OutputGreen << 5U; outred = DMA2D_ColorStruct->OutputRed << 10U; outalpha = DMA2D_ColorStruct->OutputAlpha << 15U; } else /* ColorMode = LL_DMA2D_OUTPUT_MODE_ARGB4444 */ { outgreen = DMA2D_ColorStruct->OutputGreen << 4U; outred = DMA2D_ColorStruct->OutputRed << 8U; outalpha = DMA2D_ColorStruct->OutputAlpha << 12U; } LL_DMA2D_SetOutputColor(DMA2Dx, (outgreen | outred | DMA2D_ColorStruct->OutputBlue | outalpha)); }