mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Wed Jun 11 09:45:09 2014 +0100
Revision:
226:b062af740e40
Parent:
106:ced8cbb51063
Child:
369:2e96f1b71984
Synchronized with git revision 42deb9ac55f9bdf9835e9c41dc757117d344ffda

Full URL: https://github.com/mbedmicro/mbed/commit/42deb9ac55f9bdf9835e9c41dc757117d344ffda/

[NUCLEO_F401RE] Remove call to Systick + bug fixes

Who changed what in which revision?

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