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