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