2 ******************************************************************************
\r
3 * @file stm32f7xx_hal_dma2d.c
\r
4 * @author MCD Application Team
\r
6 * @date 24-March-2015
\r
7 * @brief DMA2D HAL module driver.
\r
8 * This file provides firmware functions to manage the following
\r
9 * functionalities of the DMA2D peripheral:
\r
10 * + Initialization and de-initialization functions
\r
11 * + IO operation functions
\r
12 * + Peripheral Control functions
\r
13 * + Peripheral State and Errors functions
\r
16 ==============================================================================
\r
17 ##### How to use this driver #####
\r
18 ==============================================================================
\r
20 (#) Program the required configuration through following parameters:
\r
21 the Transfer Mode, the output color mode and the output offset using
\r
22 HAL_DMA2D_Init() function.
\r
24 (#) Program the required configuration through following parameters:
\r
25 the input color mode, the input color, input alpha value, alpha mode
\r
26 and the input offset using HAL_DMA2D_ConfigLayer() function for foreground
\r
27 or/and background layer.
\r
29 *** Polling mode IO operation ***
\r
30 =================================
\r
32 (+) Configure the pdata, Destination and data length and Enable
\r
33 the transfer using HAL_DMA2D_Start()
\r
34 (+) Wait for end of transfer using HAL_DMA2D_PollForTransfer(), at this stage
\r
35 user can specify the value of timeout according to his end application.
\r
37 *** Interrupt mode IO operation ***
\r
38 ===================================
\r
40 (#) Configure the pdata, Destination and data length and Enable
\r
41 the transfer using HAL_DMA2D_Start_IT()
\r
42 (#) Use HAL_DMA2D_IRQHandler() called under DMA2D_IRQHandler() Interrupt subroutine
\r
43 (#) At the end of data transfer HAL_DMA2D_IRQHandler() function is executed and user can
\r
44 add his own function by customization of function pointer XferCpltCallback and
\r
45 XferErrorCallback (i.e a member of DMA2D handle structure).
\r
47 -@- In Register-to-Memory transfer mode, the pdata parameter is the register
\r
48 color, in Memory-to-memory or memory-to-memory with pixel format
\r
49 conversion the pdata is the source address.
\r
51 -@- Configure the foreground source address, the background source address,
\r
52 the Destination and data length and Enable the transfer using
\r
53 HAL_DMA2D_BlendingStart() in polling mode and HAL_DMA2D_BlendingStart_IT()
\r
56 -@- HAL_DMA2D_BlendingStart() and HAL_DMA2D_BlendingStart_IT() functions
\r
57 are used if the memory to memory with blending transfer mode is selected.
\r
59 (#) Optionally, configure and enable the CLUT using HAL_DMA2D_ConfigCLUT()
\r
60 HAL_DMA2D_EnableCLUT() functions.
\r
62 (#) Optionally, configure and enable LineInterrupt using the following function:
\r
63 HAL_DMA2D_ProgramLineEvent().
\r
65 (#) The transfer can be suspended, continued and aborted using the following
\r
66 functions: HAL_DMA2D_Suspend(), HAL_DMA2D_Resume(), HAL_DMA2D_Abort().
\r
68 (#) To control DMA2D state you can use the following function: HAL_DMA2D_GetState()
\r
70 *** DMA2D HAL driver macros list ***
\r
71 =============================================
\r
73 Below the list of most used macros in DMA2D HAL driver :
\r
75 (+) __HAL_DMA2D_ENABLE: Enable the DMA2D peripheral.
\r
76 (+) __HAL_DMA2D_DISABLE: Disable the DMA2D peripheral.
\r
77 (+) __HAL_DMA2D_GET_FLAG: Get the DMA2D pending flags.
\r
78 (+) __HAL_DMA2D_CLEAR_FLAG: Clear the DMA2D pending flags.
\r
79 (+) __HAL_DMA2D_ENABLE_IT: Enable the specified DMA2D interrupts.
\r
80 (+) __HAL_DMA2D_DISABLE_IT: Disable the specified DMA2D interrupts.
\r
81 (+) __HAL_DMA2D_GET_IT_SOURCE: Check whether the specified DMA2D interrupt has occurred or not.
\r
84 (@) You can refer to the DMA2D HAL driver header file for more useful macros
\r
87 ******************************************************************************
\r
90 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
\r
92 * Redistribution and use in source and binary forms, with or without modification,
\r
93 * are permitted provided that the following conditions are met:
\r
94 * 1. Redistributions of source code must retain the above copyright notice,
\r
95 * this list of conditions and the following disclaimer.
\r
96 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
97 * this list of conditions and the following disclaimer in the documentation
\r
98 * and/or other materials provided with the distribution.
\r
99 * 3. Neither the name of STMicroelectronics nor the names of its contributors
\r
100 * may be used to endorse or promote products derived from this software
\r
101 * without specific prior written permission.
\r
103 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
\r
104 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
\r
105 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
\r
106 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
\r
107 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
108 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
\r
109 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
\r
110 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
\r
111 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
\r
112 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
114 ******************************************************************************
\r
117 /* Includes ------------------------------------------------------------------*/
\r
118 #include "stm32f7xx_hal.h"
\r
120 /** @addtogroup STM32F7xx_HAL_Driver
\r
123 /** @addtogroup DMA2D
\r
124 * @brief DMA2D HAL module driver
\r
128 #ifdef HAL_DMA2D_MODULE_ENABLED
\r
130 /* Private types -------------------------------------------------------------*/
\r
131 /* Private define ------------------------------------------------------------*/
\r
132 /** @addtogroup DMA2D_Private_Defines
\r
135 #define HAL_TIMEOUT_DMA2D_ABORT ((uint32_t)1000) /* 1s */
\r
136 #define HAL_TIMEOUT_DMA2D_SUSPEND ((uint32_t)1000) /* 1s */
\r
141 /* Private variables ---------------------------------------------------------*/
\r
142 /* Private constants ---------------------------------------------------------*/
\r
143 /* Private macro -------------------------------------------------------------*/
\r
144 /* Private function prototypes -----------------------------------------------*/
\r
145 /** @addtogroup DMA2D_Private_Functions_Prototypes
\r
148 static void DMA2D_SetConfig(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height);
\r
153 /* Private functions ---------------------------------------------------------*/
\r
154 /* Exported functions --------------------------------------------------------*/
\r
155 /** @addtogroup DMA2D_Exported_Functions
\r
159 /** @defgroup DMA2D_Group1 Initialization and Configuration functions
\r
160 * @brief Initialization and Configuration functions
\r
163 ===============================================================================
\r
164 ##### Initialization and Configuration functions #####
\r
165 ===============================================================================
\r
166 [..] This section provides functions allowing to:
\r
167 (+) Initialize and configure the DMA2D
\r
168 (+) De-initialize the DMA2D
\r
175 * @brief Initializes the DMA2D according to the specified
\r
176 * parameters in the DMA2D_InitTypeDef and create the associated handle.
\r
177 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
178 * the configuration information for the DMA2D.
\r
179 * @retval HAL status
\r
181 HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d)
\r
185 /* Check the DMA2D peripheral state */
\r
191 /* Check the parameters */
\r
192 assert_param(IS_DMA2D_ALL_INSTANCE(hdma2d->Instance));
\r
193 assert_param(IS_DMA2D_MODE(hdma2d->Init.Mode));
\r
194 assert_param(IS_DMA2D_CMODE(hdma2d->Init.ColorMode));
\r
195 assert_param(IS_DMA2D_OFFSET(hdma2d->Init.OutputOffset));
\r
197 if(hdma2d->State == HAL_DMA2D_STATE_RESET)
\r
199 /* Init the low level hardware */
\r
200 HAL_DMA2D_MspInit(hdma2d);
\r
203 /* Change DMA2D peripheral state */
\r
204 hdma2d->State = HAL_DMA2D_STATE_BUSY;
\r
206 /* DMA2D CR register configuration -------------------------------------------*/
\r
207 /* Get the CR register value */
\r
208 tmp = hdma2d->Instance->CR;
\r
210 /* Clear Mode bits */
\r
211 tmp &= (uint32_t)~DMA2D_CR_MODE;
\r
213 /* Prepare the value to be wrote to the CR register */
\r
214 tmp |= hdma2d->Init.Mode;
\r
216 /* Write to DMA2D CR register */
\r
217 hdma2d->Instance->CR = tmp;
\r
219 /* DMA2D OPFCCR register configuration ---------------------------------------*/
\r
220 /* Get the OPFCCR register value */
\r
221 tmp = hdma2d->Instance->OPFCCR;
\r
223 /* Clear Color Mode bits */
\r
224 tmp &= (uint32_t)~DMA2D_OPFCCR_CM;
\r
226 /* Prepare the value to be wrote to the OPFCCR register */
\r
227 tmp |= hdma2d->Init.ColorMode;
\r
229 /* Write to DMA2D OPFCCR register */
\r
230 hdma2d->Instance->OPFCCR = tmp;
\r
232 /* DMA2D OOR register configuration ------------------------------------------*/
\r
233 /* Get the OOR register value */
\r
234 tmp = hdma2d->Instance->OOR;
\r
236 /* Clear Offset bits */
\r
237 tmp &= (uint32_t)~DMA2D_OOR_LO;
\r
239 /* Prepare the value to be wrote to the OOR register */
\r
240 tmp |= hdma2d->Init.OutputOffset;
\r
242 /* Write to DMA2D OOR register */
\r
243 hdma2d->Instance->OOR = tmp;
\r
245 /* Update error code */
\r
246 hdma2d->ErrorCode = HAL_DMA2D_ERROR_NONE;
\r
248 /* Initialize the DMA2D state*/
\r
249 hdma2d->State = HAL_DMA2D_STATE_READY;
\r
255 * @brief Deinitializes the DMA2D peripheral registers to their default reset
\r
257 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
258 * the configuration information for the DMA2D.
\r
262 HAL_StatusTypeDef HAL_DMA2D_DeInit(DMA2D_HandleTypeDef *hdma2d)
\r
264 /* Check the DMA2D peripheral state */
\r
270 /* DeInit the low level hardware */
\r
271 HAL_DMA2D_MspDeInit(hdma2d);
\r
273 /* Update error code */
\r
274 hdma2d->ErrorCode = HAL_DMA2D_ERROR_NONE;
\r
276 /* Initialize the DMA2D state*/
\r
277 hdma2d->State = HAL_DMA2D_STATE_RESET;
\r
280 __HAL_UNLOCK(hdma2d);
\r
286 * @brief Initializes the DMA2D MSP.
\r
287 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
288 * the configuration information for the DMA2D.
\r
291 __weak void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d)
\r
293 /* NOTE : This function Should not be modified, when the callback is needed,
\r
294 the HAL_DMA2D_MspInit could be implemented in the user file
\r
299 * @brief DeInitializes the DMA2D MSP.
\r
300 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
301 * the configuration information for the DMA2D.
\r
304 __weak void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d)
\r
306 /* NOTE : This function Should not be modified, when the callback is needed,
\r
307 the HAL_DMA2D_MspDeInit could be implemented in the user file
\r
315 /** @defgroup DMA2D_Group2 IO operation functions
\r
316 * @brief IO operation functions
\r
319 ===============================================================================
\r
320 ##### IO operation functions #####
\r
321 ===============================================================================
\r
322 [..] This section provides functions allowing to:
\r
323 (+) Configure the pdata, destination address and data size and
\r
324 Start DMA2D transfer.
\r
325 (+) Configure the source for foreground and background, destination address
\r
326 and data size and Start MultiBuffer DMA2D transfer.
\r
327 (+) Configure the pdata, destination address and data size and
\r
328 Start DMA2D transfer with interrupt.
\r
329 (+) Configure the source for foreground and background, destination address
\r
330 and data size and Start MultiBuffer DMA2D transfer with interrupt.
\r
331 (+) Abort DMA2D transfer.
\r
332 (+) Suspend DMA2D transfer.
\r
333 (+) Continue DMA2D transfer.
\r
334 (+) Poll for transfer complete.
\r
335 (+) handle DMA2D interrupt request.
\r
342 * @brief Start the DMA2D Transfer.
\r
343 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
344 * the configuration information for the DMA2D.
\r
345 * @param pdata: Configure the source memory Buffer address if
\r
346 * the memory to memory or memory to memory with pixel format
\r
347 * conversion DMA2D mode is selected, and configure
\r
348 * the color value if register to memory DMA2D mode is selected.
\r
349 * @param DstAddress: The destination memory Buffer address.
\r
350 * @param Width: The width of data to be transferred from source to destination.
\r
351 * @param Height: The height of data to be transferred from source to destination.
\r
352 * @retval HAL status
\r
354 HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
\r
356 /* Process locked */
\r
357 __HAL_LOCK(hdma2d);
\r
359 /* Change DMA2D peripheral state */
\r
360 hdma2d->State = HAL_DMA2D_STATE_BUSY;
\r
362 /* Check the parameters */
\r
363 assert_param(IS_DMA2D_LINE(Height));
\r
364 assert_param(IS_DMA2D_PIXEL(Width));
\r
366 /* Disable the Peripheral */
\r
367 __HAL_DMA2D_DISABLE(hdma2d);
\r
369 /* Configure the source, destination address and the data size */
\r
370 DMA2D_SetConfig(hdma2d, pdata, DstAddress, Width, Height);
\r
372 /* Enable the Peripheral */
\r
373 __HAL_DMA2D_ENABLE(hdma2d);
\r
379 * @brief Start the DMA2D Transfer with interrupt enabled.
\r
380 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
381 * the configuration information for the DMA2D.
\r
382 * @param pdata: Configure the source memory Buffer address if
\r
383 * the memory to memory or memory to memory with pixel format
\r
384 * conversion DMA2D mode is selected, and configure
\r
385 * the color value if register to memory DMA2D mode is selected.
\r
386 * @param DstAddress: The destination memory Buffer address.
\r
387 * @param Width: The width of data to be transferred from source to destination.
\r
388 * @param Height: The height of data to be transferred from source to destination.
\r
389 * @retval HAL status
\r
391 HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
\r
393 /* Process locked */
\r
394 __HAL_LOCK(hdma2d);
\r
396 /* Change DMA2D peripheral state */
\r
397 hdma2d->State = HAL_DMA2D_STATE_BUSY;
\r
399 /* Check the parameters */
\r
400 assert_param(IS_DMA2D_LINE(Height));
\r
401 assert_param(IS_DMA2D_PIXEL(Width));
\r
403 /* Disable the Peripheral */
\r
404 __HAL_DMA2D_DISABLE(hdma2d);
\r
406 /* Configure the source, destination address and the data size */
\r
407 DMA2D_SetConfig(hdma2d, pdata, DstAddress, Width, Height);
\r
409 /* Enable the transfer complete interrupt */
\r
410 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TC);
\r
412 /* Enable the transfer Error interrupt */
\r
413 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TE);
\r
415 /* Enable the Peripheral */
\r
416 __HAL_DMA2D_ENABLE(hdma2d);
\r
418 /* Enable the configuration error interrupt */
\r
419 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CE);
\r
425 * @brief Start the multi-source DMA2D Transfer.
\r
426 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
427 * the configuration information for the DMA2D.
\r
428 * @param SrcAddress1: The source memory Buffer address of the foreground layer.
\r
429 * @param SrcAddress2: The source memory Buffer address of the background layer.
\r
430 * @param DstAddress: The destination memory Buffer address
\r
431 * @param Width: The width of data to be transferred from source to destination.
\r
432 * @param Height: The height of data to be transferred from source to destination.
\r
433 * @retval HAL status
\r
435 HAL_StatusTypeDef HAL_DMA2D_BlendingStart(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height)
\r
437 /* Process locked */
\r
438 __HAL_LOCK(hdma2d);
\r
440 /* Change DMA2D peripheral state */
\r
441 hdma2d->State = HAL_DMA2D_STATE_BUSY;
\r
443 /* Check the parameters */
\r
444 assert_param(IS_DMA2D_LINE(Height));
\r
445 assert_param(IS_DMA2D_PIXEL(Width));
\r
447 /* Disable the Peripheral */
\r
448 __HAL_DMA2D_DISABLE(hdma2d);
\r
450 /* Configure DMA2D Stream source2 address */
\r
451 hdma2d->Instance->BGMAR = SrcAddress2;
\r
453 /* Configure the source, destination address and the data size */
\r
454 DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
\r
456 /* Enable the Peripheral */
\r
457 __HAL_DMA2D_ENABLE(hdma2d);
\r
463 * @brief Start the multi-source DMA2D Transfer with interrupt enabled.
\r
464 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
465 * the configuration information for the DMA2D.
\r
466 * @param SrcAddress1: The source memory Buffer address of the foreground layer.
\r
467 * @param SrcAddress2: The source memory Buffer address of the background layer.
\r
468 * @param DstAddress: The destination memory Buffer address.
\r
469 * @param Width: The width of data to be transferred from source to destination.
\r
470 * @param Height: The height of data to be transferred from source to destination.
\r
471 * @retval HAL status
\r
473 HAL_StatusTypeDef HAL_DMA2D_BlendingStart_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height)
\r
475 /* Process locked */
\r
476 __HAL_LOCK(hdma2d);
\r
478 /* Change DMA2D peripheral state */
\r
479 hdma2d->State = HAL_DMA2D_STATE_BUSY;
\r
481 /* Check the parameters */
\r
482 assert_param(IS_DMA2D_LINE(Height));
\r
483 assert_param(IS_DMA2D_PIXEL(Width));
\r
485 /* Disable the Peripheral */
\r
486 __HAL_DMA2D_DISABLE(hdma2d);
\r
488 /* Configure DMA2D Stream source2 address */
\r
489 hdma2d->Instance->BGMAR = SrcAddress2;
\r
491 /* Configure the source, destination address and the data size */
\r
492 DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
\r
494 /* Enable the configuration error interrupt */
\r
495 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CE);
\r
497 /* Enable the transfer complete interrupt */
\r
498 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TC);
\r
500 /* Enable the transfer Error interrupt */
\r
501 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TE);
\r
503 /* Enable the Peripheral */
\r
504 __HAL_DMA2D_ENABLE(hdma2d);
\r
510 * @brief Abort the DMA2D Transfer.
\r
511 * @param hdma2d : pointer to a DMA2D_HandleTypeDef structure that contains
\r
512 * the configuration information for the DMA2D.
\r
513 * @retval HAL status
\r
515 HAL_StatusTypeDef HAL_DMA2D_Abort(DMA2D_HandleTypeDef *hdma2d)
\r
517 uint32_t tickstart = 0;
\r
519 /* Disable the DMA2D */
\r
520 __HAL_DMA2D_DISABLE(hdma2d);
\r
523 tickstart = HAL_GetTick();
\r
525 /* Check if the DMA2D is effectively disabled */
\r
526 while((hdma2d->Instance->CR & DMA2D_CR_START) != 0)
\r
528 if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DMA2D_ABORT)
\r
530 /* Update error code */
\r
531 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
\r
533 /* Change the DMA2D state */
\r
534 hdma2d->State= HAL_DMA2D_STATE_TIMEOUT;
\r
536 /* Process Unlocked */
\r
537 __HAL_UNLOCK(hdma2d);
\r
539 return HAL_TIMEOUT;
\r
542 /* Process Unlocked */
\r
543 __HAL_UNLOCK(hdma2d);
\r
545 /* Change the DMA2D state*/
\r
546 hdma2d->State = HAL_DMA2D_STATE_READY;
\r
552 * @brief Suspend the DMA2D Transfer.
\r
553 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
554 * the configuration information for the DMA2D.
\r
555 * @retval HAL status
\r
557 HAL_StatusTypeDef HAL_DMA2D_Suspend(DMA2D_HandleTypeDef *hdma2d)
\r
559 uint32_t tickstart = 0;
\r
561 /* Suspend the DMA2D transfer */
\r
562 hdma2d->Instance->CR |= DMA2D_CR_SUSP;
\r
565 tickstart = HAL_GetTick();
\r
567 /* Check if the DMA2D is effectively suspended */
\r
568 while((hdma2d->Instance->CR & DMA2D_CR_SUSP) != DMA2D_CR_SUSP)
\r
570 if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DMA2D_SUSPEND)
\r
572 /* Update error code */
\r
573 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
\r
575 /* Change the DMA2D state */
\r
576 hdma2d->State= HAL_DMA2D_STATE_TIMEOUT;
\r
578 return HAL_TIMEOUT;
\r
581 /* Change the DMA2D state*/
\r
582 hdma2d->State = HAL_DMA2D_STATE_SUSPEND;
\r
588 * @brief Resume the DMA2D Transfer.
\r
589 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
590 * the configuration information for the DMA2D.
\r
591 * @retval HAL status
\r
593 HAL_StatusTypeDef HAL_DMA2D_Resume(DMA2D_HandleTypeDef *hdma2d)
\r
595 /* Resume the DMA2D transfer */
\r
596 hdma2d->Instance->CR &= ~DMA2D_CR_SUSP;
\r
598 /* Change the DMA2D state*/
\r
599 hdma2d->State = HAL_DMA2D_STATE_BUSY;
\r
605 * @brief Polling for transfer complete or CLUT loading.
\r
606 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
607 * the configuration information for the DMA2D.
\r
608 * @param Timeout: Timeout duration
\r
609 * @retval HAL status
\r
611 HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout)
\r
613 uint32_t tmp, tmp1;
\r
614 uint32_t tickstart = 0;
\r
616 /* Polling for DMA2D transfer */
\r
617 if((hdma2d->Instance->CR & DMA2D_CR_START) != 0)
\r
620 tickstart = HAL_GetTick();
\r
622 while(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TC) == RESET)
\r
624 tmp = __HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CE);
\r
625 tmp1 = __HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TE);
\r
627 if((tmp != RESET) || (tmp1 != RESET))
\r
629 /* Clear the transfer and configuration error flags */
\r
630 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CE);
\r
631 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TE);
\r
633 /* Change DMA2D state */
\r
634 hdma2d->State= HAL_DMA2D_STATE_ERROR;
\r
636 /* Process unlocked */
\r
637 __HAL_UNLOCK(hdma2d);
\r
641 /* Check for the Timeout */
\r
642 if(Timeout != HAL_MAX_DELAY)
\r
644 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
\r
646 /* Process unlocked */
\r
647 __HAL_UNLOCK(hdma2d);
\r
649 /* Update error code */
\r
650 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
\r
652 /* Change the DMA2D state */
\r
653 hdma2d->State= HAL_DMA2D_STATE_TIMEOUT;
\r
655 return HAL_TIMEOUT;
\r
660 /* Polling for CLUT loading */
\r
661 if((hdma2d->Instance->FGPFCCR & DMA2D_FGPFCCR_START) != 0)
\r
664 tickstart = HAL_GetTick();
\r
666 while(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CTC) == RESET)
\r
668 if((__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CAE) != RESET))
\r
670 /* Clear the transfer and configuration error flags */
\r
671 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CAE);
\r
673 /* Change DMA2D state */
\r
674 hdma2d->State= HAL_DMA2D_STATE_ERROR;
\r
678 /* Check for the Timeout */
\r
679 if(Timeout != HAL_MAX_DELAY)
\r
681 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
\r
683 /* Update error code */
\r
684 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
\r
686 /* Change the DMA2D state */
\r
687 hdma2d->State= HAL_DMA2D_STATE_TIMEOUT;
\r
689 return HAL_TIMEOUT;
\r
694 /* Clear the transfer complete flag */
\r
695 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TC);
\r
697 /* Clear the CLUT loading flag */
\r
698 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CTC);
\r
700 /* Change DMA2D state */
\r
701 hdma2d->State = HAL_DMA2D_STATE_READY;
\r
703 /* Process unlocked */
\r
704 __HAL_UNLOCK(hdma2d);
\r
709 * @brief Handles DMA2D interrupt request.
\r
710 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
711 * the configuration information for the DMA2D.
\r
712 * @retval HAL status
\r
714 void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d)
\r
716 /* Transfer Error Interrupt management ***************************************/
\r
717 if(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TE) != RESET)
\r
719 if(__HAL_DMA2D_GET_IT_SOURCE(hdma2d, DMA2D_IT_TE) != RESET)
\r
721 /* Disable the transfer Error interrupt */
\r
722 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TE);
\r
724 /* Update error code */
\r
725 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TE;
\r
727 /* Clear the transfer error flag */
\r
728 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TE);
\r
730 /* Change DMA2D state */
\r
731 hdma2d->State = HAL_DMA2D_STATE_ERROR;
\r
733 /* Process Unlocked */
\r
734 __HAL_UNLOCK(hdma2d);
\r
736 if(hdma2d->XferErrorCallback != NULL)
\r
738 /* Transfer error Callback */
\r
739 hdma2d->XferErrorCallback(hdma2d);
\r
743 /* Configuration Error Interrupt management **********************************/
\r
744 if(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CE) != RESET)
\r
746 if(__HAL_DMA2D_GET_IT_SOURCE(hdma2d, DMA2D_IT_CE) != RESET)
\r
748 /* Disable the Configuration Error interrupt */
\r
749 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CE);
\r
751 /* Clear the Configuration error flag */
\r
752 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CE);
\r
754 /* Update error code */
\r
755 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CE;
\r
757 /* Change DMA2D state */
\r
758 hdma2d->State = HAL_DMA2D_STATE_ERROR;
\r
760 /* Process Unlocked */
\r
761 __HAL_UNLOCK(hdma2d);
\r
763 if(hdma2d->XferErrorCallback != NULL)
\r
765 /* Transfer error Callback */
\r
766 hdma2d->XferErrorCallback(hdma2d);
\r
770 /* Transfer Complete Interrupt management ************************************/
\r
771 if(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TC) != RESET)
\r
773 if(__HAL_DMA2D_GET_IT_SOURCE(hdma2d, DMA2D_IT_TC) != RESET)
\r
775 /* Disable the transfer complete interrupt */
\r
776 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TC);
\r
778 /* Clear the transfer complete flag */
\r
779 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TC);
\r
781 /* Update error code */
\r
782 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_NONE;
\r
784 /* Change DMA2D state */
\r
785 hdma2d->State = HAL_DMA2D_STATE_READY;
\r
787 /* Process Unlocked */
\r
788 __HAL_UNLOCK(hdma2d);
\r
790 if(hdma2d->XferCpltCallback != NULL)
\r
792 /* Transfer complete Callback */
\r
793 hdma2d->XferCpltCallback(hdma2d);
\r
803 /** @defgroup DMA2D_Group3 Peripheral Control functions
\r
804 * @brief Peripheral Control functions
\r
807 ===============================================================================
\r
808 ##### Peripheral Control functions #####
\r
809 ===============================================================================
\r
810 [..] This section provides functions allowing to:
\r
811 (+) Configure the DMA2D foreground or/and background parameters.
\r
812 (+) Configure the DMA2D CLUT transfer.
\r
813 (+) Enable DMA2D CLUT.
\r
814 (+) Disable DMA2D CLUT.
\r
815 (+) Configure the line watermark
\r
821 * @brief Configure the DMA2D Layer according to the specified
\r
822 * parameters in the DMA2D_InitTypeDef and create the associated handle.
\r
823 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
824 * the configuration information for the DMA2D.
\r
825 * @param LayerIdx: DMA2D Layer index.
\r
826 * This parameter can be one of the following values:
\r
827 * 0(background) / 1(foreground)
\r
828 * @retval HAL status
\r
830 HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
\r
832 DMA2D_LayerCfgTypeDef *pLayerCfg = &hdma2d->LayerCfg[LayerIdx];
\r
836 /* Process locked */
\r
837 __HAL_LOCK(hdma2d);
\r
839 /* Change DMA2D peripheral state */
\r
840 hdma2d->State = HAL_DMA2D_STATE_BUSY;
\r
842 /* Check the parameters */
\r
843 assert_param(IS_DMA2D_LAYER(LayerIdx));
\r
844 assert_param(IS_DMA2D_OFFSET(pLayerCfg->InputOffset));
\r
845 if(hdma2d->Init.Mode != DMA2D_R2M)
\r
847 assert_param(IS_DMA2D_INPUT_COLOR_MODE(pLayerCfg->InputColorMode));
\r
848 if(hdma2d->Init.Mode != DMA2D_M2M)
\r
850 assert_param(IS_DMA2D_ALPHA_MODE(pLayerCfg->AlphaMode));
\r
854 /* Configure the background DMA2D layer */
\r
857 /* DMA2D BGPFCR register configuration -----------------------------------*/
\r
858 /* Get the BGPFCCR register value */
\r
859 tmp = hdma2d->Instance->BGPFCCR;
\r
861 /* Clear Input color mode, alpha value and alpha mode bits */
\r
862 tmp &= (uint32_t)~(DMA2D_BGPFCCR_CM | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_ALPHA);
\r
864 if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
\r
866 /* Prepare the value to be wrote to the BGPFCCR register */
\r
867 tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | ((pLayerCfg->InputAlpha) & 0xFF000000));
\r
871 /* Prepare the value to be wrote to the BGPFCCR register */
\r
872 tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | (pLayerCfg->InputAlpha << 24));
\r
875 /* Write to DMA2D BGPFCCR register */
\r
876 hdma2d->Instance->BGPFCCR = tmp;
\r
878 /* DMA2D BGOR register configuration -------------------------------------*/
\r
879 /* Get the BGOR register value */
\r
880 tmp = hdma2d->Instance->BGOR;
\r
882 /* Clear colors bits */
\r
883 tmp &= (uint32_t)~DMA2D_BGOR_LO;
\r
885 /* Prepare the value to be wrote to the BGOR register */
\r
886 tmp |= pLayerCfg->InputOffset;
\r
888 /* Write to DMA2D BGOR register */
\r
889 hdma2d->Instance->BGOR = tmp;
\r
891 if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
\r
893 /* Prepare the value to be wrote to the BGCOLR register */
\r
894 tmp |= ((pLayerCfg->InputAlpha) & 0x00FFFFFF);
\r
896 /* Write to DMA2D BGCOLR register */
\r
897 hdma2d->Instance->BGCOLR = tmp;
\r
900 /* Configure the foreground DMA2D layer */
\r
903 /* DMA2D FGPFCR register configuration -----------------------------------*/
\r
904 /* Get the FGPFCCR register value */
\r
905 tmp = hdma2d->Instance->FGPFCCR;
\r
907 /* Clear Input color mode, alpha value and alpha mode bits */
\r
908 tmp &= (uint32_t)~(DMA2D_FGPFCCR_CM | DMA2D_FGPFCCR_AM | DMA2D_FGPFCCR_ALPHA);
\r
910 if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
\r
912 /* Prepare the value to be wrote to the FGPFCCR register */
\r
913 tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | ((pLayerCfg->InputAlpha) & 0xFF000000));
\r
917 /* Prepare the value to be wrote to the FGPFCCR register */
\r
918 tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | (pLayerCfg->InputAlpha << 24));
\r
921 /* Write to DMA2D FGPFCCR register */
\r
922 hdma2d->Instance->FGPFCCR = tmp;
\r
924 /* DMA2D FGOR register configuration -------------------------------------*/
\r
925 /* Get the FGOR register value */
\r
926 tmp = hdma2d->Instance->FGOR;
\r
928 /* Clear colors bits */
\r
929 tmp &= (uint32_t)~DMA2D_FGOR_LO;
\r
931 /* Prepare the value to be wrote to the FGOR register */
\r
932 tmp |= pLayerCfg->InputOffset;
\r
934 /* Write to DMA2D FGOR register */
\r
935 hdma2d->Instance->FGOR = tmp;
\r
937 if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
\r
939 /* Prepare the value to be wrote to the FGCOLR register */
\r
940 tmp |= ((pLayerCfg->InputAlpha) & 0x00FFFFFF);
\r
942 /* Write to DMA2D FGCOLR register */
\r
943 hdma2d->Instance->FGCOLR = tmp;
\r
946 /* Initialize the DMA2D state*/
\r
947 hdma2d->State = HAL_DMA2D_STATE_READY;
\r
949 /* Process unlocked */
\r
950 __HAL_UNLOCK(hdma2d);
\r
956 * @brief Configure the DMA2D CLUT Transfer.
\r
957 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
958 * the configuration information for the DMA2D.
\r
959 * @param CLUTCfg: pointer to a DMA2D_CLUTCfgTypeDef structure that contains
\r
960 * the configuration information for the color look up table.
\r
961 * @param LayerIdx: DMA2D Layer index.
\r
962 * This parameter can be one of the following values:
\r
963 * 0(background) / 1(foreground)
\r
964 * @retval HAL status
\r
966 HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
\r
968 uint32_t tmp = 0, tmp1 = 0;
\r
970 /* Check the parameters */
\r
971 assert_param(IS_DMA2D_LAYER(LayerIdx));
\r
972 assert_param(IS_DMA2D_CLUT_CM(CLUTCfg.CLUTColorMode));
\r
973 assert_param(IS_DMA2D_CLUT_SIZE(CLUTCfg.Size));
\r
975 /* Configure the CLUT of the background DMA2D layer */
\r
978 /* Get the BGCMAR register value */
\r
979 tmp = hdma2d->Instance->BGCMAR;
\r
981 /* Clear CLUT address bits */
\r
982 tmp &= (uint32_t)~DMA2D_BGCMAR_MA;
\r
984 /* Prepare the value to be wrote to the BGCMAR register */
\r
985 tmp |= (uint32_t)CLUTCfg.pCLUT;
\r
987 /* Write to DMA2D BGCMAR register */
\r
988 hdma2d->Instance->BGCMAR = tmp;
\r
990 /* Get the BGPFCCR register value */
\r
991 tmp = hdma2d->Instance->BGPFCCR;
\r
993 /* Clear CLUT size and CLUT address bits */
\r
994 tmp &= (uint32_t)~(DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM);
\r
996 /* Get the CLUT size */
\r
997 tmp1 = CLUTCfg.Size << 16;
\r
999 /* Prepare the value to be wrote to the BGPFCCR register */
\r
1000 tmp |= (CLUTCfg.CLUTColorMode | tmp1);
\r
1002 /* Write to DMA2D BGPFCCR register */
\r
1003 hdma2d->Instance->BGPFCCR = tmp;
\r
1005 /* Configure the CLUT of the foreground DMA2D layer */
\r
1008 /* Get the FGCMAR register value */
\r
1009 tmp = hdma2d->Instance->FGCMAR;
\r
1011 /* Clear CLUT address bits */
\r
1012 tmp &= (uint32_t)~DMA2D_FGCMAR_MA;
\r
1014 /* Prepare the value to be wrote to the FGCMAR register */
\r
1015 tmp |= (uint32_t)CLUTCfg.pCLUT;
\r
1017 /* Write to DMA2D FGCMAR register */
\r
1018 hdma2d->Instance->FGCMAR = tmp;
\r
1020 /* Get the FGPFCCR register value */
\r
1021 tmp = hdma2d->Instance->FGPFCCR;
\r
1023 /* Clear CLUT size and CLUT address bits */
\r
1024 tmp &= (uint32_t)~(DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM);
\r
1026 /* Get the CLUT size */
\r
1027 tmp1 = CLUTCfg.Size << 8;
\r
1029 /* Prepare the value to be wrote to the FGPFCCR register */
\r
1030 tmp |= (CLUTCfg.CLUTColorMode | tmp1);
\r
1032 /* Write to DMA2D FGPFCCR register */
\r
1033 hdma2d->Instance->FGPFCCR = tmp;
\r
1040 * @brief Enable the DMA2D CLUT Transfer.
\r
1041 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
1042 * the configuration information for the DMA2D.
\r
1043 * @param LayerIdx: DMA2D Layer index.
\r
1044 * This parameter can be one of the following values:
\r
1045 * 0(background) / 1(foreground)
\r
1046 * @retval HAL status
\r
1048 HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
\r
1050 /* Check the parameters */
\r
1051 assert_param(IS_DMA2D_LAYER(LayerIdx));
\r
1055 /* Enable the CLUT loading for the background */
\r
1056 hdma2d->Instance->BGPFCCR |= DMA2D_BGPFCCR_START;
\r
1060 /* Enable the CLUT loading for the foreground */
\r
1061 hdma2d->Instance->FGPFCCR |= DMA2D_FGPFCCR_START;
\r
1068 * @brief Disable the DMA2D CLUT Transfer.
\r
1069 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
1070 * the configuration information for the DMA2D.
\r
1071 * @param LayerIdx: DMA2D Layer index.
\r
1072 * This parameter can be one of the following values:
\r
1073 * 0(background) / 1(foreground)
\r
1074 * @retval HAL status
\r
1076 HAL_StatusTypeDef HAL_DMA2D_DisableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
\r
1078 /* Check the parameters */
\r
1079 assert_param(IS_DMA2D_LAYER(LayerIdx));
\r
1083 /* Disable the CLUT loading for the background */
\r
1084 hdma2d->Instance->BGPFCCR &= ~DMA2D_BGPFCCR_START;
\r
1088 /* Disable the CLUT loading for the foreground */
\r
1089 hdma2d->Instance->FGPFCCR &= ~DMA2D_FGPFCCR_START;
\r
1096 * @brief Define the configuration of the line watermark .
\r
1097 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
1098 * the configuration information for the DMA2D.
\r
1099 * @param Line: Line Watermark configuration.
\r
1100 * @retval HAL status
\r
1103 HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line)
\r
1105 /* Process locked */
\r
1106 __HAL_LOCK(hdma2d);
\r
1108 /* Change DMA2D peripheral state */
\r
1109 hdma2d->State = HAL_DMA2D_STATE_BUSY;
\r
1111 /* Check the parameters */
\r
1112 assert_param(IS_DMA2D_LineWatermark(Line));
\r
1114 /* Sets the Line watermark configuration */
\r
1115 DMA2D->LWR = (uint32_t)Line;
\r
1117 /* Initialize the DMA2D state*/
\r
1118 hdma2d->State = HAL_DMA2D_STATE_READY;
\r
1120 /* Process unlocked */
\r
1121 __HAL_UNLOCK(hdma2d);
\r
1130 /** @defgroup DMA2D_Group4 Peripheral State functions
\r
1131 * @brief Peripheral State functions
\r
1134 ===============================================================================
\r
1135 ##### Peripheral State and Errors functions #####
\r
1136 ===============================================================================
\r
1138 This subsection provides functions allowing to :
\r
1139 (+) Check the DMA2D state
\r
1140 (+) Get error code
\r
1147 * @brief Return the DMA2D state
\r
1148 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
1149 * the configuration information for the DMA2D.
\r
1150 * @retval HAL state
\r
1152 HAL_DMA2D_StateTypeDef HAL_DMA2D_GetState(DMA2D_HandleTypeDef *hdma2d)
\r
1154 return hdma2d->State;
\r
1158 * @brief Return the DMA2D error code
\r
1159 * @param hdma2d : pointer to a DMA2D_HandleTypeDef structure that contains
\r
1160 * the configuration information for DMA2D.
\r
1161 * @retval DMA2D Error Code
\r
1163 uint32_t HAL_DMA2D_GetError(DMA2D_HandleTypeDef *hdma2d)
\r
1165 return hdma2d->ErrorCode;
\r
1174 * @brief Set the DMA2D Transfer parameter.
\r
1175 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
\r
1176 * the configuration information for the specified DMA2D.
\r
1177 * @param pdata: The source memory Buffer address
\r
1178 * @param DstAddress: The destination memory Buffer address
\r
1179 * @param Width: The width of data to be transferred from source to destination.
\r
1180 * @param Height: The height of data to be transferred from source to destination.
\r
1181 * @retval HAL status
\r
1183 static void DMA2D_SetConfig(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
\r
1186 uint32_t tmp1 = 0;
\r
1187 uint32_t tmp2 = 0;
\r
1188 uint32_t tmp3 = 0;
\r
1189 uint32_t tmp4 = 0;
\r
1191 tmp = Width << 16;
\r
1193 /* Configure DMA2D data size */
\r
1194 hdma2d->Instance->NLR = (Height | tmp);
\r
1196 /* Configure DMA2D destination address */
\r
1197 hdma2d->Instance->OMAR = DstAddress;
\r
1199 /* Register to memory DMA2D mode selected */
\r
1200 if (hdma2d->Init.Mode == DMA2D_R2M)
\r
1202 tmp1 = pdata & DMA2D_OCOLR_ALPHA_1;
\r
1203 tmp2 = pdata & DMA2D_OCOLR_RED_1;
\r
1204 tmp3 = pdata & DMA2D_OCOLR_GREEN_1;
\r
1205 tmp4 = pdata & DMA2D_OCOLR_BLUE_1;
\r
1207 /* Prepare the value to be wrote to the OCOLR register according to the color mode */
\r
1208 if (hdma2d->Init.ColorMode == DMA2D_ARGB8888)
\r
1210 tmp = (tmp3 | tmp2 | tmp1| tmp4);
\r
1212 else if (hdma2d->Init.ColorMode == DMA2D_RGB888)
\r
1214 tmp = (tmp3 | tmp2 | tmp4);
\r
1216 else if (hdma2d->Init.ColorMode == DMA2D_RGB565)
\r
1218 tmp2 = (tmp2 >> 19);
\r
1219 tmp3 = (tmp3 >> 10);
\r
1220 tmp4 = (tmp4 >> 3 );
\r
1221 tmp = ((tmp3 << 5) | (tmp2 << 11) | tmp4);
\r
1223 else if (hdma2d->Init.ColorMode == DMA2D_ARGB1555)
\r
1225 tmp1 = (tmp1 >> 31);
\r
1226 tmp2 = (tmp2 >> 19);
\r
1227 tmp3 = (tmp3 >> 11);
\r
1228 tmp4 = (tmp4 >> 3 );
\r
1229 tmp = ((tmp3 << 5) | (tmp2 << 10) | (tmp1 << 15) | tmp4);
\r
1231 else /* DMA2D_CMode = DMA2D_ARGB4444 */
\r
1233 tmp1 = (tmp1 >> 28);
\r
1234 tmp2 = (tmp2 >> 20);
\r
1235 tmp3 = (tmp3 >> 12);
\r
1236 tmp4 = (tmp4 >> 4 );
\r
1237 tmp = ((tmp3 << 4) | (tmp2 << 8) | (tmp1 << 12) | tmp4);
\r
1239 /* Write to DMA2D OCOLR register */
\r
1240 hdma2d->Instance->OCOLR = tmp;
\r
1242 else /* M2M, M2M_PFC or M2M_Blending DMA2D Mode */
\r
1244 /* Configure DMA2D source address */
\r
1245 hdma2d->Instance->FGMAR = pdata;
\r
1252 #endif /* HAL_DMA2D_MODULE_ENABLED */
\r
1261 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r