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