annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_dma2d.c @ 80:cc2bb7bb8456

Added Spanish language
author heinrichsweikamp
date Sat, 06 Oct 2018 15:02:11 +0200
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file stm32f4xx_hal_dma2d.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author MCD Application Team
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V1.2.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 26-December-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief DMA2D HAL module driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * This file provides firmware functions to manage the following
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * functionalities of the DMA2D peripheral:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * + Initialization and de-initialization functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * + IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * + Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * + Peripheral State and Errors functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 ##### How to use this driver #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 ==============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 (#) Program the required configuration through following parameters:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 the Transfer Mode, the output color mode and the output offset using
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 HAL_DMA2D_Init() function.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 (#) Program the required configuration through following parameters:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 the input color mode, the input color, input alpha value, alpha mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 and the input offset using HAL_DMA2D_ConfigLayer() function for foreground
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 or/and background layer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 *** Polling mode IO operation ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 =================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 (+) Configure the pdata, Destination and data length and Enable
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 the transfer using HAL_DMA2D_Start()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 (+) Wait for end of transfer using HAL_DMA2D_PollForTransfer(), at this stage
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 user can specify the value of timeout according to his end application.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 *** Interrupt mode IO operation ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 ===================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 (#) Configure the pdata, Destination and data length and Enable
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41 the transfer using HAL_DMA2D_Start_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 (#) Use HAL_DMA2D_IRQHandler() called under DMA2D_IRQHandler() Interrupt subroutine
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 (#) At the end of data transfer HAL_DMA2D_IRQHandler() function is executed and user can
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 add his own function by customization of function pointer XferCpltCallback and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 XferErrorCallback (i.e a member of DMA2D handle structure).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 -@- In Register-to-Memory transfer mode, the pdata parameter is the register
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 color, in Memory-to-memory or memory-to-memory with pixel format
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 conversion the pdata is the source address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 -@- Configure the foreground source address, the background source address,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 the Destination and data length and Enable the transfer using
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 HAL_DMA2D_BlendingStart() in polling mode and HAL_DMA2D_BlendingStart_IT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 in interrupt mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 -@- HAL_DMA2D_BlendingStart() and HAL_DMA2D_BlendingStart_IT() functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 are used if the memory to memory with blending transfer mode is selected.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 (#) Optionally, configure and enable the CLUT using HAL_DMA2D_ConfigCLUT()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 HAL_DMA2D_EnableCLUT() functions.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 (#) Optionally, configure and enable LineInterrupt using the following function:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 HAL_DMA2D_ProgramLineEvent().
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 (#) The transfer can be suspended, continued and aborted using the following
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 functions: HAL_DMA2D_Suspend(), HAL_DMA2D_Resume(), HAL_DMA2D_Abort().
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 (#) To control DMA2D state you can use the following function: HAL_DMA2D_GetState()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 *** DMA2D HAL driver macros list ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 =============================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 Below the list of most used macros in DMA2D HAL driver :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 (+) __HAL_DMA2D_ENABLE: Enable the DMA2D peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 (+) __HAL_DMA2D_DISABLE: Disable the DMA2D peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 (+) __HAL_DMA2D_GET_FLAG: Get the DMA2D pending flags.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 (+) __HAL_DMA2D_CLEAR_FLAG: Clear the DMA2D pending flags.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 (+) __HAL_DMA2D_ENABLE_IT: Enable the specified DMA2D interrupts.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 (+) __HAL_DMA2D_DISABLE_IT: Disable the specified DMA2D interrupts.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 (+) __HAL_DMA2D_GET_IT_SOURCE: Check whether the specified DMA2D interrupt has occurred or not.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 (@) You can refer to the DMA2D HAL driver header file for more useful macros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 /** @addtogroup DMA2D
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 * @brief DMA2D HAL module driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 #ifdef HAL_DMA2D_MODULE_ENABLED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 /* Private types -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 /** @addtogroup DMA2D_Private_Defines
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 #define HAL_TIMEOUT_DMA2D_ABORT ((uint32_t)1000) /* 1s */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 #define HAL_TIMEOUT_DMA2D_SUSPEND ((uint32_t)1000) /* 1s */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 /* Private constants ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 /** @addtogroup DMA2D_Private_Functions_Prototypes
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 static void DMA2D_SetConfig(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 /** @addtogroup DMA2D_Exported_Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 /** @defgroup DMA2D_Group1 Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 ##### Initialization and Configuration functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 (+) Initialize and configure the DMA2D
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 (+) De-initialize the DMA2D
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 * @brief Initializes the DMA2D according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 * parameters in the DMA2D_InitTypeDef and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 HAL_StatusTypeDef HAL_DMA2D_Init(DMA2D_HandleTypeDef *hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 uint32_t tmp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 /* Check the DMA2D peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 if(hdma2d == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 assert_param(IS_DMA2D_ALL_INSTANCE(hdma2d->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 assert_param(IS_DMA2D_MODE(hdma2d->Init.Mode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 assert_param(IS_DMA2D_CMODE(hdma2d->Init.ColorMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 assert_param(IS_DMA2D_OFFSET(hdma2d->Init.OutputOffset));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199 if(hdma2d->State == HAL_DMA2D_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 /* Init the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 HAL_DMA2D_MspInit(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 /* Change DMA2D peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 hdma2d->State = HAL_DMA2D_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 /* DMA2D CR register configuration -------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 /* Get the CR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 tmp = hdma2d->Instance->CR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 /* Clear Mode bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 tmp &= (uint32_t)~DMA2D_CR_MODE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 /* Prepare the value to be wrote to the CR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 tmp |= hdma2d->Init.Mode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 /* Write to DMA2D CR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 hdma2d->Instance->CR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 /* DMA2D OPFCCR register configuration ---------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 /* Get the OPFCCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 tmp = hdma2d->Instance->OPFCCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 /* Clear Color Mode bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 tmp &= (uint32_t)~DMA2D_OPFCCR_CM;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 /* Prepare the value to be wrote to the OPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 tmp |= hdma2d->Init.ColorMode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 /* Write to DMA2D OPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 hdma2d->Instance->OPFCCR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 /* DMA2D OOR register configuration ------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 /* Get the OOR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 tmp = hdma2d->Instance->OOR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 /* Clear Offset bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 tmp &= (uint32_t)~DMA2D_OOR_LO;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 /* Prepare the value to be wrote to the OOR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 tmp |= hdma2d->Init.OutputOffset;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 /* Write to DMA2D OOR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 hdma2d->Instance->OOR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 hdma2d->ErrorCode = HAL_DMA2D_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 /* Initialize the DMA2D state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 hdma2d->State = HAL_DMA2D_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 * @brief Deinitializes the DMA2D peripheral registers to their default reset
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 * values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 HAL_StatusTypeDef HAL_DMA2D_DeInit(DMA2D_HandleTypeDef *hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 /* Check the DMA2D peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 if(hdma2d == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 /* DeInit the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 HAL_DMA2D_MspDeInit(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 hdma2d->ErrorCode = HAL_DMA2D_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 /* Initialize the DMA2D state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 hdma2d->State = HAL_DMA2D_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 * @brief Initializes the DMA2D MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 __weak void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 the HAL_DMA2D_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 * @brief DeInitializes the DMA2D MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 __weak void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 the HAL_DMA2D_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 /** @defgroup DMA2D_Group2 IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 * @brief IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 ##### IO operation functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 (+) Configure the pdata, destination address and data size and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 Start DMA2D transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 (+) Configure the source for foreground and background, destination address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 and data size and Start MultiBuffer DMA2D transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 (+) Configure the pdata, destination address and data size and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 Start DMA2D transfer with interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331 (+) Configure the source for foreground and background, destination address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 and data size and Start MultiBuffer DMA2D transfer with interrupt.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 (+) Abort DMA2D transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 (+) Suspend DMA2D transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 (+) Continue DMA2D transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 (+) Poll for transfer complete.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 (+) handle DMA2D interrupt request.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 * @brief Start the DMA2D Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 * @param pdata: Configure the source memory Buffer address if
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 * the memory to memory or memory to memory with pixel format
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 * conversion DMA2D mode is selected, and configure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 * the color value if register to memory DMA2D mode is selected.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 * @param DstAddress: The destination memory Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 * @param Width: The width of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 * @param Height: The height of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 HAL_StatusTypeDef HAL_DMA2D_Start(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 /* Process locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 __HAL_LOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 /* Change DMA2D peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 hdma2d->State = HAL_DMA2D_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 assert_param(IS_DMA2D_LINE(Height));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 assert_param(IS_DMA2D_PIXEL(Width));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 __HAL_DMA2D_DISABLE(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 /* Configure the source, destination address and the data size */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 DMA2D_SetConfig(hdma2d, pdata, DstAddress, Width, Height);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 __HAL_DMA2D_ENABLE(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 * @brief Start the DMA2D Transfer with interrupt enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 * @param pdata: Configure the source memory Buffer address if
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 * the memory to memory or memory to memory with pixel format
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 * conversion DMA2D mode is selected, and configure
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 * the color value if register to memory DMA2D mode is selected.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 * @param DstAddress: The destination memory Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 * @param Width: The width of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 * @param Height: The height of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 HAL_StatusTypeDef HAL_DMA2D_Start_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 /* Process locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 __HAL_LOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 /* Change DMA2D peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 hdma2d->State = HAL_DMA2D_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 assert_param(IS_DMA2D_LINE(Height));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 assert_param(IS_DMA2D_PIXEL(Width));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406 __HAL_DMA2D_DISABLE(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 /* Configure the source, destination address and the data size */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 DMA2D_SetConfig(hdma2d, pdata, DstAddress, Width, Height);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 /* Enable the transfer complete interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 /* Enable the transfer Error interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 __HAL_DMA2D_ENABLE(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 /* Enable the configuration error interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 * @brief Start the multi-source DMA2D Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 * @param SrcAddress1: The source memory Buffer address of the foreground layer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 * @param SrcAddress2: The source memory Buffer address of the background layer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 * @param DstAddress: The destination memory Buffer address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 * @param Width: The width of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 * @param Height: The height of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 HAL_StatusTypeDef HAL_DMA2D_BlendingStart(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 /* Process locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 __HAL_LOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 /* Change DMA2D peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 hdma2d->State = HAL_DMA2D_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 assert_param(IS_DMA2D_LINE(Height));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 assert_param(IS_DMA2D_PIXEL(Width));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 __HAL_DMA2D_DISABLE(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 /* Configure DMA2D Stream source2 address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 hdma2d->Instance->BGMAR = SrcAddress2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 /* Configure the source, destination address and the data size */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 __HAL_DMA2D_ENABLE(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 * @brief Start the multi-source DMA2D Transfer with interrupt enabled.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 * @param SrcAddress1: The source memory Buffer address of the foreground layer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 * @param SrcAddress2: The source memory Buffer address of the background layer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 * @param DstAddress: The destination memory Buffer address.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471 * @param Width: The width of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 * @param Height: The height of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 HAL_StatusTypeDef HAL_DMA2D_BlendingStart_IT(DMA2D_HandleTypeDef *hdma2d, uint32_t SrcAddress1, uint32_t SrcAddress2, uint32_t DstAddress, uint32_t Width, uint32_t Height)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 /* Process locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 __HAL_LOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 /* Change DMA2D peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 hdma2d->State = HAL_DMA2D_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 assert_param(IS_DMA2D_LINE(Height));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 assert_param(IS_DMA2D_PIXEL(Width));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 /* Disable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 __HAL_DMA2D_DISABLE(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 /* Configure DMA2D Stream source2 address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 hdma2d->Instance->BGMAR = SrcAddress2;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 /* Configure the source, destination address and the data size */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 DMA2D_SetConfig(hdma2d, SrcAddress1, DstAddress, Width, Height);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 /* Enable the configuration error interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_CE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 /* Enable the transfer complete interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 /* Enable the transfer Error interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 __HAL_DMA2D_ENABLE_IT(hdma2d, DMA2D_IT_TE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 /* Enable the Peripheral */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 __HAL_DMA2D_ENABLE(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 * @brief Abort the DMA2D Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 * @param hdma2d : pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 HAL_StatusTypeDef HAL_DMA2D_Abort(DMA2D_HandleTypeDef *hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 /* Disable the DMA2D */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 __HAL_DMA2D_DISABLE(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 /* Check if the DMA2D is effectively disabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 while((hdma2d->Instance->CR & DMA2D_CR_START) != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DMA2D_ABORT)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 /* Change the DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 hdma2d->State= HAL_DMA2D_STATE_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 /* Change the DMA2D state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 hdma2d->State = HAL_DMA2D_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 * @brief Suspend the DMA2D Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 HAL_StatusTypeDef HAL_DMA2D_Suspend(DMA2D_HandleTypeDef *hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 /* Suspend the DMA2D transfer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 hdma2d->Instance->CR |= DMA2D_CR_SUSP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 /* Check if the DMA2D is effectively suspended */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570 while((hdma2d->Instance->CR & DMA2D_CR_SUSP) != DMA2D_CR_SUSP)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DMA2D_SUSPEND)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 /* Change the DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 hdma2d->State= HAL_DMA2D_STATE_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 /* Change the DMA2D state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 hdma2d->State = HAL_DMA2D_STATE_SUSPEND;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 * @brief Resume the DMA2D Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 HAL_StatusTypeDef HAL_DMA2D_Resume(DMA2D_HandleTypeDef *hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 /* Resume the DMA2D transfer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598 hdma2d->Instance->CR &= ~DMA2D_CR_SUSP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 /* Change the DMA2D state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 hdma2d->State = HAL_DMA2D_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 * @brief Polling for transfer complete or CLUT loading.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 * @param Timeout: Timeout duration
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
611 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
612 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
613 HAL_StatusTypeDef HAL_DMA2D_PollForTransfer(DMA2D_HandleTypeDef *hdma2d, uint32_t Timeout)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 uint32_t tmp, tmp1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 /* Polling for DMA2D transfer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 if((hdma2d->Instance->CR & DMA2D_CR_START) != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 while(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TC) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626 tmp = __HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 tmp1 = __HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 if((tmp != RESET) || (tmp1 != RESET))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 /* Clear the transfer and configuration error flags */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 /* Change DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636 hdma2d->State= HAL_DMA2D_STATE_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 /* Check for the Timeout */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 if(Timeout != HAL_MAX_DELAY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 /* Change the DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 hdma2d->State= HAL_DMA2D_STATE_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662 /* Polling for CLUT loading */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 if((hdma2d->Instance->FGPFCCR & DMA2D_FGPFCCR_START) != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 while(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CTC) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 if((__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CAE) != RESET))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 /* Clear the transfer and configuration error flags */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CAE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 /* Change DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676 hdma2d->State= HAL_DMA2D_STATE_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 /* Check for the Timeout */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 if(Timeout != HAL_MAX_DELAY)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688 /* Change the DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 hdma2d->State= HAL_DMA2D_STATE_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
692 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
693 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
694 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
695 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
696 /* Clear the transfer complete flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 /* Clear the CLUT loading flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CTC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 /* Change DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 hdma2d->State = HAL_DMA2D_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
709 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
710 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
711 * @brief Handles DMA2D interrupt request.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 void HAL_DMA2D_IRQHandler(DMA2D_HandleTypeDef *hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 /* Transfer Error Interrupt management ***************************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 if(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TE) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 if(__HAL_DMA2D_GET_IT_SOURCE(hdma2d, DMA2D_IT_TE) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723 /* Disable the transfer Error interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_TE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729 /* Clear the transfer error flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 /* Change DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733 hdma2d->State = HAL_DMA2D_STATE_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 if(hdma2d->XferErrorCallback != NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 /* Transfer error Callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741 hdma2d->XferErrorCallback(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 /* Configuration Error Interrupt management **********************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 if(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_CE) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 if(__HAL_DMA2D_GET_IT_SOURCE(hdma2d, DMA2D_IT_CE) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 /* Disable the Configuration Error interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_CE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 /* Clear the Configuration error flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_CE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_CE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 /* Change DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 hdma2d->State = HAL_DMA2D_STATE_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 if(hdma2d->XferErrorCallback != NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 /* Transfer error Callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 hdma2d->XferErrorCallback(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 /* Transfer Complete Interrupt management ************************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 if(__HAL_DMA2D_GET_FLAG(hdma2d, DMA2D_FLAG_TC) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 if(__HAL_DMA2D_GET_IT_SOURCE(hdma2d, DMA2D_IT_TC) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 /* Disable the transfer complete interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 __HAL_DMA2D_DISABLE_IT(hdma2d, DMA2D_IT_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 /* Clear the transfer complete flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 __HAL_DMA2D_CLEAR_FLAG(hdma2d, DMA2D_FLAG_TC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 hdma2d->ErrorCode |= HAL_DMA2D_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 /* Change DMA2D state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 hdma2d->State = HAL_DMA2D_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 if(hdma2d->XferCpltCallback != NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 /* Transfer complete Callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795 hdma2d->XferCpltCallback(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 /** @defgroup DMA2D_Group3 Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 * @brief Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 ##### Peripheral Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 (+) Configure the DMA2D foreground or/and background parameters.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 (+) Configure the DMA2D CLUT transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 (+) Enable DMA2D CLUT.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 (+) Disable DMA2D CLUT.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 (+) Configure the line watermark
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
820 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
821 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
822 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
823 * @brief Configure the DMA2D Layer according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 * parameters in the DMA2D_InitTypeDef and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
827 * @param LayerIdx: DMA2D Layer index.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
828 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
829 * 0(background) / 1(foreground)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
830 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
831 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
832 HAL_StatusTypeDef HAL_DMA2D_ConfigLayer(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
833 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
834 DMA2D_LayerCfgTypeDef *pLayerCfg = &hdma2d->LayerCfg[LayerIdx];
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
835
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
836 uint32_t tmp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
837
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
838 /* Process locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
839 __HAL_LOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
840
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
841 /* Change DMA2D peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
842 hdma2d->State = HAL_DMA2D_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
843
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
844 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
845 assert_param(IS_DMA2D_LAYER(LayerIdx));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
846 assert_param(IS_DMA2D_OFFSET(pLayerCfg->InputOffset));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
847 if(hdma2d->Init.Mode != DMA2D_R2M)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
848 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
849 assert_param(IS_DMA2D_INPUT_COLOR_MODE(pLayerCfg->InputColorMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
850 if(hdma2d->Init.Mode != DMA2D_M2M)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
851 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
852 assert_param(IS_DMA2D_ALPHA_MODE(pLayerCfg->AlphaMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
853 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
854 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
855
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
856 /* Configure the background DMA2D layer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
857 if(LayerIdx == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
858 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
859 /* DMA2D BGPFCR register configuration -----------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
860 /* Get the BGPFCCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
861 tmp = hdma2d->Instance->BGPFCCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
862
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
863 /* Clear Input color mode, alpha value and alpha mode bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
864 tmp &= (uint32_t)~(DMA2D_BGPFCCR_CM | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_ALPHA);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
865
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
866 if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
867 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
868 /* Prepare the value to be wrote to the BGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
869 tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | ((pLayerCfg->InputAlpha) & 0xFF000000));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
870 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
871 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
872 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
873 /* Prepare the value to be wrote to the BGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
874 tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | (pLayerCfg->InputAlpha << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
875 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
876
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
877 /* Write to DMA2D BGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
878 hdma2d->Instance->BGPFCCR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
879
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
880 /* DMA2D BGOR register configuration -------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
881 /* Get the BGOR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
882 tmp = hdma2d->Instance->BGOR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
883
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
884 /* Clear colors bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
885 tmp &= (uint32_t)~DMA2D_BGOR_LO;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
886
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
887 /* Prepare the value to be wrote to the BGOR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
888 tmp |= pLayerCfg->InputOffset;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
889
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
890 /* Write to DMA2D BGOR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
891 hdma2d->Instance->BGOR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
892
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
893 if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
894 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
895 /* Prepare the value to be wrote to the BGCOLR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
896 tmp |= ((pLayerCfg->InputAlpha) & 0x00FFFFFF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
897
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
898 /* Write to DMA2D BGCOLR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
899 hdma2d->Instance->BGCOLR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
900 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
901 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
902 /* Configure the foreground DMA2D layer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
903 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
904 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
905 /* DMA2D FGPFCR register configuration -----------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
906 /* Get the FGPFCCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
907 tmp = hdma2d->Instance->FGPFCCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
908
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
909 /* Clear Input color mode, alpha value and alpha mode bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
910 tmp &= (uint32_t)~(DMA2D_FGPFCCR_CM | DMA2D_FGPFCCR_AM | DMA2D_FGPFCCR_ALPHA);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
911
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
912 if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
913 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
914 /* Prepare the value to be wrote to the FGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
915 tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | ((pLayerCfg->InputAlpha) & 0xFF000000));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
916 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
917 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
918 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
919 /* Prepare the value to be wrote to the FGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
920 tmp |= (pLayerCfg->InputColorMode | (pLayerCfg->AlphaMode << 16) | (pLayerCfg->InputAlpha << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
921 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
922
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
923 /* Write to DMA2D FGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
924 hdma2d->Instance->FGPFCCR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
925
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
926 /* DMA2D FGOR register configuration -------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
927 /* Get the FGOR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
928 tmp = hdma2d->Instance->FGOR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
929
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
930 /* Clear colors bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
931 tmp &= (uint32_t)~DMA2D_FGOR_LO;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
932
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
933 /* Prepare the value to be wrote to the FGOR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
934 tmp |= pLayerCfg->InputOffset;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
935
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
936 /* Write to DMA2D FGOR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
937 hdma2d->Instance->FGOR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
938
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
939 if ((pLayerCfg->InputColorMode == CM_A4) || (pLayerCfg->InputColorMode == CM_A8))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
940 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
941 /* Prepare the value to be wrote to the FGCOLR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
942 tmp |= ((pLayerCfg->InputAlpha) & 0x00FFFFFF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
943
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
944 /* Write to DMA2D FGCOLR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
945 hdma2d->Instance->FGCOLR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
946 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
947 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
948 /* Initialize the DMA2D state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
949 hdma2d->State = HAL_DMA2D_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
950
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
951 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
952 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
953
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
954 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
955 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
956
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
957 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
958 * @brief Configure the DMA2D CLUT Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
959 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
960 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
961 * @param CLUTCfg: pointer to a DMA2D_CLUTCfgTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
962 * the configuration information for the color look up table.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
963 * @param LayerIdx: DMA2D Layer index.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
964 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
965 * 0(background) / 1(foreground)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
966 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
967 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
968 HAL_StatusTypeDef HAL_DMA2D_ConfigCLUT(DMA2D_HandleTypeDef *hdma2d, DMA2D_CLUTCfgTypeDef CLUTCfg, uint32_t LayerIdx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
969 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
970 uint32_t tmp = 0, tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
971
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
972 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
973 assert_param(IS_DMA2D_LAYER(LayerIdx));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
974 assert_param(IS_DMA2D_CLUT_CM(CLUTCfg.CLUTColorMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
975 assert_param(IS_DMA2D_CLUT_SIZE(CLUTCfg.Size));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
976
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
977 /* Configure the CLUT of the background DMA2D layer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
978 if(LayerIdx == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
979 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
980 /* Get the BGCMAR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
981 tmp = hdma2d->Instance->BGCMAR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
982
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
983 /* Clear CLUT address bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
984 tmp &= (uint32_t)~DMA2D_BGCMAR_MA;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
985
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
986 /* Prepare the value to be wrote to the BGCMAR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
987 tmp |= (uint32_t)CLUTCfg.pCLUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
988
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
989 /* Write to DMA2D BGCMAR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
990 hdma2d->Instance->BGCMAR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
991
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
992 /* Get the BGPFCCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
993 tmp = hdma2d->Instance->BGPFCCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
994
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
995 /* Clear CLUT size and CLUT address bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
996 tmp &= (uint32_t)~(DMA2D_BGPFCCR_CS | DMA2D_BGPFCCR_CCM);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
997
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
998 /* Get the CLUT size */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
999 tmp1 = CLUTCfg.Size << 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1000
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1001 /* Prepare the value to be wrote to the BGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1002 tmp |= (CLUTCfg.CLUTColorMode | tmp1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1003
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1004 /* Write to DMA2D BGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1005 hdma2d->Instance->BGPFCCR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1006 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1007 /* Configure the CLUT of the foreground DMA2D layer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1008 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1009 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1010 /* Get the FGCMAR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1011 tmp = hdma2d->Instance->FGCMAR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1012
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1013 /* Clear CLUT address bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1014 tmp &= (uint32_t)~DMA2D_FGCMAR_MA;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1015
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1016 /* Prepare the value to be wrote to the FGCMAR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1017 tmp |= (uint32_t)CLUTCfg.pCLUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1018
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1019 /* Write to DMA2D FGCMAR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1020 hdma2d->Instance->FGCMAR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1021
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1022 /* Get the FGPFCCR register value */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1023 tmp = hdma2d->Instance->FGPFCCR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1024
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1025 /* Clear CLUT size and CLUT address bits */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1026 tmp &= (uint32_t)~(DMA2D_FGPFCCR_CS | DMA2D_FGPFCCR_CCM);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1027
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1028 /* Get the CLUT size */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1029 tmp1 = CLUTCfg.Size << 8;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1030
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1031 /* Prepare the value to be wrote to the FGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1032 tmp |= (CLUTCfg.CLUTColorMode | tmp1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1033
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1034 /* Write to DMA2D FGPFCCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1035 hdma2d->Instance->FGPFCCR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1036 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1037
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1038 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1039 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1040
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1041 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1042 * @brief Enable the DMA2D CLUT Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1043 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1044 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1045 * @param LayerIdx: DMA2D Layer index.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1046 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1047 * 0(background) / 1(foreground)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1048 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1049 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1050 HAL_StatusTypeDef HAL_DMA2D_EnableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1051 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1052 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1053 assert_param(IS_DMA2D_LAYER(LayerIdx));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1054
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1055 if(LayerIdx == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1056 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1057 /* Enable the CLUT loading for the background */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1058 hdma2d->Instance->BGPFCCR |= DMA2D_BGPFCCR_START;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1059 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1060 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1061 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1062 /* Enable the CLUT loading for the foreground */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1063 hdma2d->Instance->FGPFCCR |= DMA2D_FGPFCCR_START;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1064 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1065
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1066 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1067 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1068
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1069 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1070 * @brief Disable the DMA2D CLUT Transfer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1071 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1072 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1073 * @param LayerIdx: DMA2D Layer index.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1074 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1075 * 0(background) / 1(foreground)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1076 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1077 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1078 HAL_StatusTypeDef HAL_DMA2D_DisableCLUT(DMA2D_HandleTypeDef *hdma2d, uint32_t LayerIdx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1079 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1080 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1081 assert_param(IS_DMA2D_LAYER(LayerIdx));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1082
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1083 if(LayerIdx == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1084 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1085 /* Disable the CLUT loading for the background */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1086 hdma2d->Instance->BGPFCCR &= ~DMA2D_BGPFCCR_START;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1087 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1088 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1089 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1090 /* Disable the CLUT loading for the foreground */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1091 hdma2d->Instance->FGPFCCR &= ~DMA2D_FGPFCCR_START;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1092 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1093
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1094 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1095 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1096
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1097 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1098 * @brief Define the configuration of the line watermark .
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1099 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1100 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1101 * @param Line: Line Watermark configuration.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1102 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1103 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1104
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1105 HAL_StatusTypeDef HAL_DMA2D_ProgramLineEvent(DMA2D_HandleTypeDef *hdma2d, uint32_t Line)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1106 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1107 /* Process locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1108 __HAL_LOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1109
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1110 /* Change DMA2D peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1111 hdma2d->State = HAL_DMA2D_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1112
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1113 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1114 assert_param(IS_DMA2D_LineWatermark(Line));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1115
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1116 /* Sets the Line watermark configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1117 DMA2D->LWR = (uint32_t)Line;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1118
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1119 /* Initialize the DMA2D state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1120 hdma2d->State = HAL_DMA2D_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1121
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1122 /* Process unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1123 __HAL_UNLOCK(hdma2d);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1124
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1125 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1126 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1127
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1128 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1129 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1130 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1131
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1132 /** @defgroup DMA2D_Group4 Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1133 * @brief Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1134 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1135 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1136 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1137 ##### Peripheral State and Errors functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1138 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1139 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1140 This subsection provides functions allowing to :
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1141 (+) Check the DMA2D state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1142 (+) Get error code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1143
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1144 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1145 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1146 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1147
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1148 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1149 * @brief Return the DMA2D state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1150 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1151 * the configuration information for the DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1152 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1153 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1154 HAL_DMA2D_StateTypeDef HAL_DMA2D_GetState(DMA2D_HandleTypeDef *hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1155 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1156 return hdma2d->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1157 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1158
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1159 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1160 * @brief Return the DMA2D error code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1161 * @param hdma2d : pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1162 * the configuration information for DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1163 * @retval DMA2D Error Code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1164 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1165 uint32_t HAL_DMA2D_GetError(DMA2D_HandleTypeDef *hdma2d)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1166 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1167 return hdma2d->ErrorCode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1168 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1169
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1170 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1171 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1172 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1173
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1174
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1175 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1176 * @brief Set the DMA2D Transfer parameter.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1177 * @param hdma2d: pointer to a DMA2D_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1178 * the configuration information for the specified DMA2D.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1179 * @param pdata: The source memory Buffer address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1180 * @param DstAddress: The destination memory Buffer address
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1181 * @param Width: The width of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1182 * @param Height: The height of data to be transferred from source to destination.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1183 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1184 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1185 static void DMA2D_SetConfig(DMA2D_HandleTypeDef *hdma2d, uint32_t pdata, uint32_t DstAddress, uint32_t Width, uint32_t Height)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1186 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1187 uint32_t tmp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1188 uint32_t tmp1 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1189 uint32_t tmp2 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1190 uint32_t tmp3 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1191 uint32_t tmp4 = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1192
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1193 tmp = Width << 16;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1194
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1195 /* Configure DMA2D data size */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1196 hdma2d->Instance->NLR = (Height | tmp);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1197
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1198 /* Configure DMA2D destination address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1199 hdma2d->Instance->OMAR = DstAddress;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1200
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1201 /* Register to memory DMA2D mode selected */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1202 if (hdma2d->Init.Mode == DMA2D_R2M)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1203 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1204 tmp1 = pdata & DMA2D_OCOLR_ALPHA_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1205 tmp2 = pdata & DMA2D_OCOLR_RED_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1206 tmp3 = pdata & DMA2D_OCOLR_GREEN_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1207 tmp4 = pdata & DMA2D_OCOLR_BLUE_1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1208
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1209 /* Prepare the value to be wrote to the OCOLR register according to the color mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1210 if (hdma2d->Init.ColorMode == DMA2D_ARGB8888)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1211 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1212 tmp = (tmp3 | tmp2 | tmp1| tmp4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1213 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1214 else if (hdma2d->Init.ColorMode == DMA2D_RGB888)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1215 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1216 tmp = (tmp3 | tmp2 | tmp4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1217 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1218 else if (hdma2d->Init.ColorMode == DMA2D_RGB565)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1219 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1220 tmp2 = (tmp2 >> 19);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1221 tmp3 = (tmp3 >> 10);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1222 tmp4 = (tmp4 >> 3 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1223 tmp = ((tmp3 << 5) | (tmp2 << 11) | tmp4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1224 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1225 else if (hdma2d->Init.ColorMode == DMA2D_ARGB1555)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1226 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1227 tmp1 = (tmp1 >> 31);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1228 tmp2 = (tmp2 >> 19);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1229 tmp3 = (tmp3 >> 11);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1230 tmp4 = (tmp4 >> 3 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1231 tmp = ((tmp3 << 5) | (tmp2 << 10) | (tmp1 << 15) | tmp4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1232 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1233 else /* DMA2D_CMode = DMA2D_ARGB4444 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1234 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1235 tmp1 = (tmp1 >> 28);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1236 tmp2 = (tmp2 >> 20);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1237 tmp3 = (tmp3 >> 12);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1238 tmp4 = (tmp4 >> 4 );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1239 tmp = ((tmp3 << 4) | (tmp2 << 8) | (tmp1 << 12) | tmp4);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1240 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1241 /* Write to DMA2D OCOLR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1242 hdma2d->Instance->OCOLR = tmp;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1243 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1244 else /* M2M, M2M_PFC or M2M_Blending DMA2D Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1245 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1246 /* Configure DMA2D source address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1247 hdma2d->Instance->FGMAR = pdata;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1248 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1249 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1250
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1251 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1252 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1253 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1254 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1255 #endif /* HAL_DMA2D_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1256 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1257 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1258 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1259
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1260 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1261 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1262 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1263
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1264 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/