annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_dcmi.c @ 56:bab006305b58

language updates
author heinrichsweikamp
date Tue, 07 Aug 2018 17:03:36 +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_dcmi.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 DCMI 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 Digital Camera Interface (DCMI) 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 Error 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 The sequence below describes how to use this driver to capture image
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 from a camera module connected to the DCMI Interface.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 This sequence does not take into account the configuration of the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 camera module, which should be made before to configure and enable
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 the DCMI to capture images.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 (#) Program the required configuration through following parameters:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 horizontal and vertical polarity, pixel clock polarity, Capture Rate,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 Synchronization Mode, code of the frame delimiter and data width
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 using HAL_DCMI_Init() function.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 (#) Configure the DMA2_Stream1 channel1 to transfer Data from DCMI DR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 register to the destination memory buffer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 (#) Program the required configuration through following parameters:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 DCMI mode, destination memory Buffer address and the data length
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 and enable capture using HAL_DCMI_Start_DMA() function.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 (#) Optionally, configure and Enable the CROP feature to select a rectangular
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 window from the received image using HAL_DCMI_ConfigCrop()
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 and HAL_DCMI_EnableCROP() functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 (#) The capture can be stopped using HAL_DCMI_Stop() function.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 (#) To control DCMI state you can use the function HAL_DCMI_GetState().
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 *** DCMI HAL driver macros list ***
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 =============================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 Below the list of most used macros in DCMI HAL driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 (+) __HAL_DCMI_ENABLE: Enable the DCMI peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 (+) __HAL_DCMI_DISABLE: Disable the DCMI peripheral.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 (+) __HAL_DCMI_GET_FLAG: Get the DCMI pending flags.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 (+) __HAL_DCMI_CLEAR_FLAG: Clear the DCMI pending flags.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55 (+) __HAL_DCMI_ENABLE_IT: Enable the specified DCMI interrupts.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 (+) __HAL_DCMI_DISABLE_IT: Disable the specified DCMI interrupts.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 (+) __HAL_DCMI_GET_IT_SOURCE: Check whether the specified DCMI interrupt has occurred or not.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 (@) You can refer to the DCMI HAL driver header file for more useful macros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 /** @defgroup DCMI DCMI
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 * @brief DCMI HAL module driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 #ifdef HAL_DCMI_MODULE_ENABLED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 #if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 #define HAL_TIMEOUT_DCMI_STOP ((uint32_t)1000) /* 1s */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 static void DCMI_DMAError(DMA_HandleTypeDef *hdma);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 /* Exported functions --------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 /** @defgroup DCMI_Exported_Functions DCMI Exported Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 /** @defgroup DCMI_Exported_Functions_Group1 Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 * @brief Initialization and Configuration functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 ##### Initialization and Configuration functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 (+) Initialize and configure the DCMI
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 (+) De-initialize the DCMI
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 * @{
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 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 * @brief Initializes the DCMI according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 * parameters in the DCMI_InitTypeDef and create the associated handle.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 /* Check the DCMI peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 if(hdcmi == NULL)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 return HAL_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 /* Check function parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 if(hdcmi->State == HAL_DCMI_STATE_RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 /* Init the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 HAL_DCMI_MspInit(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 /* Change the DCMI state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 hdcmi->State = HAL_DCMI_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 /* Configures the HS, VS, DE and PC polarity */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL | DCMI_CR_VSPOL | DCMI_CR_EDM_0 |
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 DCMI_CR_EDM_1 | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG |
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 DCMI_CR_ESS);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 hdcmi->Instance->CR |= (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 hdcmi->Init.VSPolarity | hdcmi->Init.HSPolarity | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode | \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 hdcmi->Init.JPEGMode);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 DCMI->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode) |
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 ((uint32_t)hdcmi->Init.SyncroCode.LineStartCode << 8)|
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 ((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << 16) |
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 ((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << 24));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188 /* Enable the Line interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 /* Enable the VSYNC interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_VSYNC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 /* Enable the Frame capture complete interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_FRAME);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 /* Enable the Synchronization error interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 /* Enable the Overflow interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_OVF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 /* Enable DCMI by setting DCMIEN bit */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 __HAL_DCMI_ENABLE(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 /* Initialize the DCMI state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 hdcmi->State = HAL_DCMI_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 * @brief Deinitializes the DCMI peripheral registers to their default reset
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 * values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 /* DeInit the low level hardware */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 HAL_DCMI_MspDeInit(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231 /* Initialize the DCMI state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 hdcmi->State = HAL_DCMI_STATE_RESET;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 /* Release Lock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 * @brief Initializes the DCMI MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 __weak void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 the HAL_DCMI_MspInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 * @brief DeInitializes the DCMI MSP.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 __weak void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 the HAL_DCMI_MspDeInit could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 /** @defgroup DCMI_Exported_Functions_Group2 IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 * @brief IO operation functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274 ##### IO operation functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 (+) Configure destination address and data length and
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 Enables DCMI DMA request and enables DCMI capture
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 (+) Stop the DCMI capture.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 (+) Handles DCMI interrupt request.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 */
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 * @brief Enables DCMI DMA request and enables DCMI capture
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 * @param DCMI_Mode: DCMI capture mode snapshot or continuous grab.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 * @param pData: The destination memory Buffer address (LCD Frame buffer).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 * @param Length: The length of capture to be transferred.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 /* Initialize the second memory address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 uint32_t SecondMemAddress = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 /* Check function parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 __HAL_LOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 /* Lock the DCMI peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 hdcmi->State = HAL_DCMI_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 /* Configure the DCMI Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 hdcmi->Instance->CR &= ~(DCMI_CR_CM);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 hdcmi->Instance->CR |= (uint32_t)(DCMI_Mode);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 /* Set the DMA memory0 conversion complete callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 hdcmi->DMA_Handle->XferCpltCallback = DCMI_DMAConvCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 /* Set the DMA error callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320 hdcmi->DMA_Handle->XferErrorCallback = DCMI_DMAError;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 if(Length <= 0xFFFF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 /* Enable the DMA Stream */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 HAL_DMA_Start_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, Length);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 else /* DCMI_DOUBLE_BUFFER Mode */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 /* Set the DMA memory1 conversion complete callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 hdcmi->DMA_Handle->XferM1CpltCallback = DCMI_DMAConvCplt;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 /* Initialize transfer parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 hdcmi->XferCount = 1;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 hdcmi->XferSize = Length;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 hdcmi->pBuffPtr = pData;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 /* Get the number of buffer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 while(hdcmi->XferSize > 0xFFFF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 hdcmi->XferSize = (hdcmi->XferSize/2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 hdcmi->XferCount = hdcmi->XferCount*2;
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 /* Update DCMI counter and transfer number*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 hdcmi->XferCount = (hdcmi->XferCount - 2);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 hdcmi->XferTransferNumber = hdcmi->XferCount;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 /* Update second memory address */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 SecondMemAddress = (uint32_t)(pData + (4*hdcmi->XferSize));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 /* Start DMA multi buffer transfer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 HAL_DMAEx_MultiBufferStart_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, SecondMemAddress, hdcmi->XferSize);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 /* Enable Capture */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 DCMI->CR |= DCMI_CR_CAPTURE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 * @brief Disable DCMI DMA request and Disable DCMI capture
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 /* Lock the DCMI peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 hdcmi->State = HAL_DCMI_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 __HAL_DCMI_DISABLE(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 /* Disable Capture */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 DCMI->CR &= ~(DCMI_CR_CAPTURE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383 /* Check if the DCMI capture effectively disabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 while((hdcmi->Instance->CR & DCMI_CR_CAPTURE) != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 if((HAL_GetTick() - tickstart ) > HAL_TIMEOUT_DCMI_STOP)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 hdcmi->ErrorCode |= HAL_DCMI_ERROR_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 /* Change DCMI state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 hdcmi->State = HAL_DCMI_STATE_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 /* Disable the DMA */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 HAL_DMA_Abort(hdcmi->DMA_Handle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 hdcmi->ErrorCode |= HAL_DCMI_ERROR_NONE;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 /* Change DCMI state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 hdcmi->State = HAL_DCMI_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 /* Return function status */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 * @brief Handles DCMI interrupt request.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 * the configuration information for the DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 /* Synchronization error interrupt management *******************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_ERRRI) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_ERR) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 /* Disable the Synchronization error interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_ERR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433 /* Clear the Synchronization error flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_ERRRI);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 hdcmi->ErrorCode |= HAL_DCMI_ERROR_SYNC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 /* Change DCMI state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 hdcmi->State = HAL_DCMI_STATE_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 /* Abort the DMA Transfer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 HAL_DMA_Abort(hdcmi->DMA_Handle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 /* Synchronization error Callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 HAL_DCMI_ErrorCallback(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 /* Overflow interrupt management ********************************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453 if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_OVFRI) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_OVF) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 /* Disable the Overflow interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_OVF);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 /* Clear the Overflow flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_OVFRI);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 /* Update error code */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 hdcmi->ErrorCode |= HAL_DCMI_ERROR_OVF;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 /* Change DCMI state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 hdcmi->State = HAL_DCMI_STATE_ERROR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 /* Abort the DMA Transfer */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 HAL_DMA_Abort(hdcmi->DMA_Handle);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 /* Overflow Callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 HAL_DCMI_ErrorCallback(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 /* Line Interrupt management ************************************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_LINERI) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_LINE) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 /* Clear the Line interrupt flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_LINERI);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 /* Line interrupt Callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 HAL_DCMI_LineEventCallback(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 /* VSYNC interrupt management ***********************************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_VSYNCRI) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_VSYNC) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 /* Disable the VSYNC interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_VSYNC);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 /* Clear the VSYNC flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_VSYNCRI);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 /* VSYNC Callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 HAL_DCMI_VsyncEventCallback(hdcmi);
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 /* End of Frame interrupt management ****************************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_FRAMERI) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 if(__HAL_DCMI_GET_IT_SOURCE(hdcmi, DCMI_IT_FRAME) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 /* Disable the End of Frame interrupt */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_FRAME);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 /* Clear the End of Frame flag */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_FRAMERI);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 /* End of Frame Callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 HAL_DCMI_FrameEventCallback(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 * @brief Error DCMI callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 __weak void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 the HAL_DCMI_ErrorCallback could be implemented in the user file
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 * @brief Line Event callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 __weak void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 the HAL_DCMI_LineEventCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 * @brief VSYNC Event callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 __weak void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 the HAL_DCMI_VsyncEventCallback could be implemented in the user file
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 * @brief Frame Event callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 __weak void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 /* NOTE : This function Should not be modified, when the callback is needed,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580 the HAL_DCMI_FrameEventCallback could be implemented in the user file
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
586 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
587
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
588 /** @defgroup DCMI_Exported_Functions_Group3 Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
589 * @brief Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
590 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
591 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
592 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
593 ##### Peripheral Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
594 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
595 [..] This section provides functions allowing to:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
596 (+) Configure the CROP feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
597 (+) Enable/Disable the CROP feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
598
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
599 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
600 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
601 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
602
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
603 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
604 * @brief Configure the DCMI CROP coordinate.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
605 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
606 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
607 * @param YSize: DCMI Line number
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
608 * @param XSize: DCMI Pixel per line
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
609 * @param X0: DCMI window X offset
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
610 * @param Y0: DCMI window Y offset
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_DCMI_ConfigCROP(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
614 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
615 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
616 __HAL_LOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
617
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
618 /* Lock the DCMI peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
619 hdcmi->State = HAL_DCMI_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
620
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
621 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
622 assert_param(IS_DCMI_WINDOW_COORDINATE(X0));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
623 assert_param(IS_DCMI_WINDOW_COORDINATE(YSize));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
624 assert_param(IS_DCMI_WINDOW_COORDINATE(XSize));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
625 assert_param(IS_DCMI_WINDOW_HEIGHT(Y0));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
626
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
627 /* Configure CROP */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
628 DCMI->CWSIZER = (XSize | (YSize << 16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
629 DCMI->CWSTRTR = (X0 | (Y0 << 16));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
630
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
631 /* Initialize the DCMI state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
632 hdcmi->State = HAL_DCMI_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
633
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
634 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
635 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
636
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
637 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
638 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
639
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
640 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
641 * @brief Disable the Crop feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
642 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
643 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
644 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
645 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
646 HAL_StatusTypeDef HAL_DCMI_DisableCROP(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
647 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
648 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
649 __HAL_LOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
650
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
651 /* Lock the DCMI peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
652 hdcmi->State = HAL_DCMI_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
653
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
654 /* Disable DCMI Crop feature */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
655 DCMI->CR &= ~(uint32_t)DCMI_CR_CROP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
656
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
657 /* Change the DCMI state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
658 hdcmi->State = HAL_DCMI_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
659
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
660 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
661 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
662
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
663 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
664 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
665
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
666 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
667 * @brief Enable the Crop feature.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
668 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
669 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
670 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
671 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
672 HAL_StatusTypeDef HAL_DCMI_EnableCROP(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
673 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
674 /* Process Locked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
675 __HAL_LOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
676
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
677 /* Lock the DCMI peripheral state */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
678 hdcmi->State = HAL_DCMI_STATE_BUSY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
679
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
680 /* Enable DCMI Crop feature */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
681 DCMI->CR |= (uint32_t)DCMI_CR_CROP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
682
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
683 /* Change the DCMI state*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
684 hdcmi->State = HAL_DCMI_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
685
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
686 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
687 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
688
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
689 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
690 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
691
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 /** @defgroup DCMI_Exported_Functions_Group4 Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
697 * @brief Peripheral State functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
698 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
699 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
700 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
701 ##### Peripheral State and Errors functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
702 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
703 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
704 This subsection provides functions allowing to
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
705 (+) Check the DCMI state.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
706 (+) Get the specific DCMI error flag.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
707
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
708 @endverbatim
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
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
712 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
713 * @brief Return the DCMI state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
714 * @param hdcmi: pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
715 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
716 * @retval HAL state
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
717 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
718 HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
719 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
720 return hdcmi->State;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
721 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
722
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
723 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
724 * @brief Return the DCMI error code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
725 * @param hdcmi : pointer to a DCMI_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
726 * the configuration information for DCMI.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
727 * @retval DCMI Error Code
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
728 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
729 uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
730 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
731 return hdcmi->ErrorCode;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
732 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
733
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
734 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
735 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
736 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
737 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
738 /** @defgroup DCMI_Private_Functions DCMI Private Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
739 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
740 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
741
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
742 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
743 * @brief DMA conversion complete callback.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
744 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
745 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
746 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
747 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
748 static void DCMI_DMAConvCplt(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
749 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
750 uint32_t tmp = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
751
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
752 DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
753 hdcmi->State= HAL_DCMI_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
754
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
755 if(hdcmi->XferCount != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
756 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
757 /* Update memory 0 address location */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
758 tmp = ((hdcmi->DMA_Handle->Instance->CR) & DMA_SxCR_CT);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
759 if(((hdcmi->XferCount % 2) == 0) && (tmp != 0))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
760 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
761 tmp = hdcmi->DMA_Handle->Instance->M0AR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
762 HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8*hdcmi->XferSize)), MEMORY0);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
763 hdcmi->XferCount--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
764 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
765 /* Update memory 1 address location */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
766 else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
767 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
768 tmp = hdcmi->DMA_Handle->Instance->M1AR;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
769 HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8*hdcmi->XferSize)), MEMORY1);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
770 hdcmi->XferCount--;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
771 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
772 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
773 /* Update memory 0 address location */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
774 else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) != 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
775 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
776 hdcmi->DMA_Handle->Instance->M0AR = hdcmi->pBuffPtr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
777 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
778 /* Update memory 1 address location */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
779 else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
780 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
781 tmp = hdcmi->pBuffPtr;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
782 hdcmi->DMA_Handle->Instance->M1AR = (tmp + (4*hdcmi->XferSize));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
783 hdcmi->XferCount = hdcmi->XferTransferNumber;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
784 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
785
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
786 if(__HAL_DCMI_GET_FLAG(hdcmi, DCMI_FLAG_FRAMERI) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
787 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
788 /* Process Unlocked */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
789 __HAL_UNLOCK(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
790
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
791 /* FRAME Callback */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
792 HAL_DCMI_FrameEventCallback(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
793 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
794 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
795
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
796 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
797 * @brief DMA error callback
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
798 * @param hdma: pointer to a DMA_HandleTypeDef structure that contains
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
799 * the configuration information for the specified DMA module.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
800 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
801 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
802 static void DCMI_DMAError(DMA_HandleTypeDef *hdma)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
803 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
804 DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
805 hdcmi->State= HAL_DCMI_STATE_READY;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
806 HAL_DCMI_ErrorCallback(hdcmi);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
807 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
808
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
809 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
810 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
811 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
812
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
813 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
814 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
815 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
816 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
817 #endif /* HAL_DCMI_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
818 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
819 * @}
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 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
824 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
825
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
826 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/