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