STM32F479xx HAL User Manual
stm32f4xx_hal_dcmi.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_dcmi.c
00004   * @author  MCD Application Team
00005   * @brief   DCMI HAL module driver
00006   *          This file provides firmware functions to manage the following
00007   *          functionalities of the Digital Camera Interface (DCMI) peripheral:
00008   *           + Initialization and de-initialization functions
00009   *           + IO operation functions
00010   *           + Peripheral Control functions
00011   *           + Peripheral State and Error functions
00012   *           
00013   @verbatim
00014   ==============================================================================
00015                         ##### How to use this driver #####
00016   ==============================================================================
00017   [..]
00018       The sequence below describes how to use this driver to capture image
00019       from a camera module connected to the DCMI Interface.
00020       This sequence does not take into account the configuration of the
00021       camera module, which should be made before to configure and enable
00022       the DCMI to capture images.
00023 
00024     (#) Program the required configuration through following parameters:
00025         horizontal and vertical polarity, pixel clock polarity, Capture Rate,
00026         Synchronization Mode, code of the frame delimiter and data width 
00027         using HAL_DCMI_Init() function.
00028 
00029     (#) Configure the DMA2_Stream1 channel1 to transfer Data from DCMI DR
00030         register to the destination memory buffer.
00031 
00032     (#) Program the required configuration through following parameters:
00033         DCMI mode, destination memory Buffer address and the data length
00034         and enable capture using HAL_DCMI_Start_DMA() function.
00035 
00036     (#) Optionally, configure and Enable the CROP feature to select a rectangular
00037         window from the received image using HAL_DCMI_ConfigCrop()
00038         and HAL_DCMI_EnableCROP() functions
00039 
00040     (#) The capture can be stopped using HAL_DCMI_Stop() function.
00041 
00042     (#) To control DCMI state you can use the function HAL_DCMI_GetState().
00043 
00044      *** DCMI HAL driver macros list ***
00045      =============================================
00046      [..]
00047        Below the list of most used macros in DCMI HAL driver.
00048        
00049       (+) __HAL_DCMI_ENABLE: Enable the DCMI peripheral.
00050       (+) __HAL_DCMI_DISABLE: Disable the DCMI peripheral.
00051       (+) __HAL_DCMI_GET_FLAG: Get the DCMI pending flags.
00052       (+) __HAL_DCMI_CLEAR_FLAG: Clear the DCMI pending flags.
00053       (+) __HAL_DCMI_ENABLE_IT: Enable the specified DCMI interrupts.
00054       (+) __HAL_DCMI_DISABLE_IT: Disable the specified DCMI interrupts.
00055       (+) __HAL_DCMI_GET_IT_SOURCE: Check whether the specified DCMI interrupt has occurred or not.
00056 
00057      [..]
00058        (@) You can refer to the DCMI HAL driver header file for more useful macros
00059       
00060     *** Callback registration ***
00061     =============================
00062 
00063     The compilation define USE_HAL_DCMI_REGISTER_CALLBACKS when set to 1
00064     allows the user to configure dynamically the driver callbacks.
00065     Use functions HAL_DCMI_RegisterCallback() to register a user callback.
00066 
00067     Function HAL_DCMI_RegisterCallback() allows to register following callbacks:
00068       (+) FrameEventCallback : DCMI Frame Event.
00069       (+) VsyncEventCallback : DCMI Vsync Event.
00070       (+) LineEventCallback  : DCMI Line Event.
00071       (+) ErrorCallback      : DCMI error.
00072       (+) MspInitCallback    : DCMI MspInit.
00073       (+) MspDeInitCallback  : DCMI MspDeInit.
00074     This function takes as parameters the HAL peripheral handle, the callback ID
00075     and a pointer to the user callback function.
00076 
00077     Use function HAL_DCMI_UnRegisterCallback() to reset a callback to the default
00078     weak (surcharged) function.
00079     HAL_DCMI_UnRegisterCallback() takes as parameters the HAL peripheral handle,
00080     and the callback ID.
00081     This function allows to reset following callbacks:
00082       (+) FrameEventCallback : DCMI Frame Event.
00083       (+) VsyncEventCallback : DCMI Vsync Event.
00084       (+) LineEventCallback  : DCMI Line Event.
00085       (+) ErrorCallback      : DCMI error.
00086       (+) MspInitCallback    : DCMI MspInit.
00087       (+) MspDeInitCallback  : DCMI MspDeInit.
00088 
00089     By default, after the HAL_DCMI_Init and if the state is HAL_DCMI_STATE_RESET
00090     all callbacks are reset to the corresponding legacy weak (surcharged) functions:
00091     examples FrameEventCallback(), HAL_DCMI_ErrorCallback().
00092     Exception done for MspInit and MspDeInit callbacks that are respectively
00093     reset to the legacy weak (surcharged) functions in the HAL_DCMI_Init
00094     and  HAL_DCMI_DeInit only when these callbacks are null (not registered beforehand).
00095     If not, MspInit or MspDeInit are not null, the HAL_DCMI_Init and HAL_DCMI_DeInit
00096     keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
00097 
00098     Callbacks can be registered/unregistered in READY state only.
00099     Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered
00100     in READY or RESET state, thus registered (user) MspInit/DeInit callbacks can be used
00101     during the Init/DeInit.
00102     In that case first register the MspInit/MspDeInit user callbacks
00103     using HAL_DCMI_RegisterCallback before calling HAL_DCMI_DeInit
00104     or HAL_DCMI_Init function.
00105 
00106     When the compilation define USE_HAL_DCMI_REGISTER_CALLBACKS is set to 0 or
00107     not defined, the callback registering feature is not available
00108     and weak (surcharged) callbacks are used.
00109         
00110   @endverbatim
00111   ******************************************************************************
00112   * @attention
00113   *
00114   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
00115   * All rights reserved.</center></h2>
00116   *
00117   * This software component is licensed by ST under BSD 3-Clause license,
00118   * the "License"; You may not use this file except in compliance with the
00119   * License. You may obtain a copy of the License at:
00120   *                        opensource.org/licenses/BSD-3-Clause
00121   *
00122   ******************************************************************************
00123   */
00124 
00125 /* Includes ------------------------------------------------------------------*/
00126 #include "stm32f4xx_hal.h"
00127 
00128 /** @addtogroup STM32F4xx_HAL_Driver
00129   * @{
00130   */
00131 /** @defgroup DCMI DCMI
00132   * @brief DCMI HAL module driver
00133   * @{
00134   */
00135 
00136 #ifdef HAL_DCMI_MODULE_ENABLED
00137 
00138 #if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) ||\
00139     defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) ||\
00140     defined(STM32F479xx)
00141 /* Private typedef -----------------------------------------------------------*/
00142 /* Private define ------------------------------------------------------------*/
00143 #define HAL_TIMEOUT_DCMI_STOP    14U  /* Set timeout to 1s  */
00144 /* Private macro -------------------------------------------------------------*/
00145 /* Private variables ---------------------------------------------------------*/
00146 /* Private function prototypes -----------------------------------------------*/
00147 static void       DCMI_DMAXferCplt(DMA_HandleTypeDef *hdma);
00148 static void       DCMI_DMAError(DMA_HandleTypeDef *hdma);
00149 
00150 /* Exported functions --------------------------------------------------------*/
00151 
00152 /** @defgroup DCMI_Exported_Functions DCMI Exported Functions
00153   * @{
00154   */
00155 
00156 /** @defgroup DCMI_Exported_Functions_Group1 Initialization and Configuration functions
00157   *  @brief   Initialization and Configuration functions
00158   *
00159 @verbatim
00160  ===============================================================================
00161                 ##### Initialization and Configuration functions #####
00162  ===============================================================================
00163     [..]  This section provides functions allowing to:
00164       (+) Initialize and configure the DCMI
00165       (+) De-initialize the DCMI 
00166 
00167 @endverbatim
00168   * @{
00169   */
00170 
00171 /**
00172   * @brief  Initializes the DCMI according to the specified
00173   *         parameters in the DCMI_InitTypeDef and create the associated handle.
00174   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00175   *                the configuration information for DCMI.
00176   * @retval HAL status
00177   */
00178 __weak HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi)
00179 {
00180   /* Check the DCMI peripheral state */
00181   if(hdcmi == NULL)
00182   {
00183      return HAL_ERROR;
00184   }
00185 
00186   /* Check function parameters */
00187   assert_param(IS_DCMI_ALL_INSTANCE(hdcmi->Instance));
00188   assert_param(IS_DCMI_PCKPOLARITY(hdcmi->Init.PCKPolarity));
00189   assert_param(IS_DCMI_VSPOLARITY(hdcmi->Init.VSPolarity));
00190   assert_param(IS_DCMI_HSPOLARITY(hdcmi->Init.HSPolarity));
00191   assert_param(IS_DCMI_SYNCHRO(hdcmi->Init.SynchroMode));
00192   assert_param(IS_DCMI_CAPTURE_RATE(hdcmi->Init.CaptureRate));
00193   assert_param(IS_DCMI_EXTENDED_DATA(hdcmi->Init.ExtendedDataMode));
00194   assert_param(IS_DCMI_MODE_JPEG(hdcmi->Init.JPEGMode));
00195 
00196   if(hdcmi->State == HAL_DCMI_STATE_RESET)
00197   {
00198     /* Allocate lock resource and initialize it */
00199     hdcmi->Lock = HAL_UNLOCKED;
00200     /* Init the low level hardware */
00201   /* Init the DCMI Callback settings */
00202 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00203     hdcmi->FrameEventCallback = HAL_DCMI_FrameEventCallback; /* Legacy weak FrameEventCallback  */ 
00204     hdcmi->VsyncEventCallback = HAL_DCMI_VsyncEventCallback; /* Legacy weak VsyncEventCallback  */ 
00205     hdcmi->LineEventCallback  = HAL_DCMI_LineEventCallback;  /* Legacy weak LineEventCallback   */  
00206     hdcmi->ErrorCallback      = HAL_DCMI_ErrorCallback;      /* Legacy weak ErrorCallback       */ 
00207     
00208     if(hdcmi->MspInitCallback == NULL)  
00209     {
00210       /* Legacy weak MspInit Callback        */
00211       hdcmi->MspInitCallback = HAL_DCMI_MspInit;
00212     }
00213     /* Initialize the low level hardware (MSP) */
00214     hdcmi->MspInitCallback(hdcmi);
00215 #else  
00216     /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */
00217     HAL_DCMI_MspInit(hdcmi);
00218 #endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS) */
00219     HAL_DCMI_MspInit(hdcmi);
00220   }
00221 
00222   /* Change the DCMI state */
00223   hdcmi->State = HAL_DCMI_STATE_BUSY;
00224 
00225   /* Set DCMI parameters */
00226   /* Configures the HS, VS, DE and PC polarity */
00227   hdcmi->Instance->CR &= ~(DCMI_CR_PCKPOL | DCMI_CR_HSPOL  | DCMI_CR_VSPOL  | DCMI_CR_EDM_0 |
00228                            DCMI_CR_EDM_1  | DCMI_CR_FCRC_0 | DCMI_CR_FCRC_1 | DCMI_CR_JPEG  |
00229                            DCMI_CR_ESS);
00230   hdcmi->Instance->CR |=  (uint32_t)(hdcmi->Init.SynchroMode | hdcmi->Init.CaptureRate | \
00231                                      hdcmi->Init.VSPolarity  | hdcmi->Init.HSPolarity  | \
00232                                      hdcmi->Init.PCKPolarity | hdcmi->Init.ExtendedDataMode | \
00233                                      hdcmi->Init.JPEGMode);
00234 
00235   if(hdcmi->Init.SynchroMode == DCMI_SYNCHRO_EMBEDDED)
00236   {
00237     hdcmi->Instance->ESCR = (((uint32_t)hdcmi->Init.SyncroCode.FrameStartCode)    |
00238                              ((uint32_t)hdcmi->Init.SyncroCode.LineStartCode << DCMI_POSITION_ESCR_LSC)|
00239                              ((uint32_t)hdcmi->Init.SyncroCode.LineEndCode << DCMI_POSITION_ESCR_LEC) |
00240                              ((uint32_t)hdcmi->Init.SyncroCode.FrameEndCode << DCMI_POSITION_ESCR_FEC));
00241   }
00242 
00243   /* Enable the Line, Vsync, Error and Overrun interrupts */
00244   __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_LINE | DCMI_IT_VSYNC | DCMI_IT_ERR | DCMI_IT_OVR);
00245 
00246   /* Update error code */
00247   hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
00248 
00249   /* Initialize the DCMI state*/
00250   hdcmi->State  = HAL_DCMI_STATE_READY;
00251 
00252   return HAL_OK;
00253 }
00254 
00255 /**
00256   * @brief  Deinitializes the DCMI peripheral registers to their default reset
00257   *         values.
00258   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00259   *                the configuration information for DCMI.
00260   * @retval HAL status
00261   */
00262 
00263 HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi)
00264 {
00265 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)  
00266   if(hdcmi->MspDeInitCallback == NULL)  
00267   {
00268     hdcmi->MspDeInitCallback = HAL_DCMI_MspDeInit;
00269   }
00270   /* De-Initialize the low level hardware (MSP) */
00271   hdcmi->MspDeInitCallback(hdcmi);
00272 #else
00273   /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */
00274   HAL_DCMI_MspDeInit(hdcmi);
00275 #endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS) */
00276 
00277   /* Update error code */
00278   hdcmi->ErrorCode = HAL_DCMI_ERROR_NONE;
00279 
00280   /* Initialize the DCMI state*/
00281   hdcmi->State = HAL_DCMI_STATE_RESET;
00282 
00283   /* Release Lock */
00284   __HAL_UNLOCK(hdcmi);
00285 
00286   return HAL_OK;
00287 }
00288 
00289 /**
00290   * @brief  Initializes the DCMI MSP.
00291   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00292   *                the configuration information for DCMI.
00293   * @retval None
00294   */
00295 __weak void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi)
00296 {
00297   /* Prevent unused argument(s) compilation warning */
00298   UNUSED(hdcmi);
00299   /* NOTE : This function Should not be modified, when the callback is needed,
00300             the HAL_DCMI_MspInit could be implemented in the user file
00301    */ 
00302 }
00303 
00304 /**
00305   * @brief  DeInitializes the DCMI MSP.
00306   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00307   *                the configuration information for DCMI.
00308   * @retval None
00309   */
00310 __weak void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi)
00311 {
00312   /* Prevent unused argument(s) compilation warning */
00313   UNUSED(hdcmi);
00314   /* NOTE : This function Should not be modified, when the callback is needed,
00315             the HAL_DCMI_MspDeInit could be implemented in the user file
00316    */
00317 }
00318 
00319 /**
00320   * @}
00321   */
00322 /** @defgroup DCMI_Exported_Functions_Group2 IO operation functions
00323   *  @brief   IO operation functions
00324   *
00325 @verbatim
00326  ===============================================================================
00327                       #####  IO operation functions  #####
00328  ===============================================================================
00329     [..]  This section provides functions allowing to:
00330       (+) Configure destination address and data length and
00331           Enables DCMI DMA request and enables DCMI capture
00332       (+) Stop the DCMI capture.
00333       (+) Handles DCMI interrupt request.
00334 
00335 @endverbatim
00336   * @{
00337   */
00338 
00339 /**
00340   * @brief  Enables DCMI DMA request and enables DCMI capture
00341   * @param  hdcmi     pointer to a DCMI_HandleTypeDef structure that contains
00342   *                    the configuration information for DCMI.
00343   * @param  DCMI_Mode DCMI capture mode snapshot or continuous grab.
00344   * @param  pData     The destination memory Buffer address (LCD Frame buffer).
00345   * @param  Length    The length of capture to be transferred.
00346   * @retval HAL status
00347   */
00348 HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)
00349 {
00350   /* Initialize the second memory address */
00351   uint32_t SecondMemAddress = 0U;
00352 
00353   /* Check function parameters */
00354   assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode));
00355 
00356   /* Process Locked */
00357   __HAL_LOCK(hdcmi);
00358 
00359   /* Lock the DCMI peripheral state */
00360   hdcmi->State = HAL_DCMI_STATE_BUSY;
00361   
00362   /* Enable DCMI by setting DCMIEN bit */
00363   __HAL_DCMI_ENABLE(hdcmi);
00364 
00365   /* Configure the DCMI Mode */
00366   hdcmi->Instance->CR &= ~(DCMI_CR_CM);
00367   hdcmi->Instance->CR |=  (uint32_t)(DCMI_Mode);
00368 
00369   /* Set the DMA memory0 conversion complete callback */
00370   hdcmi->DMA_Handle->XferCpltCallback = DCMI_DMAXferCplt;
00371 
00372   /* Set the DMA error callback */
00373   hdcmi->DMA_Handle->XferErrorCallback = DCMI_DMAError;
00374 
00375   /* Set the dma abort callback */
00376   hdcmi->DMA_Handle->XferAbortCallback = NULL;
00377   
00378   /* Reset transfer counters value */ 
00379   hdcmi->XferCount = 0U;
00380   hdcmi->XferTransferNumber = 0U;
00381 
00382   if(Length <= 0xFFFFU)
00383   {
00384     /* Enable the DMA Stream */
00385     HAL_DMA_Start_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, Length);
00386   }
00387   else /* DCMI_DOUBLE_BUFFER Mode */
00388   {
00389     /* Set the DMA memory1 conversion complete callback */
00390     hdcmi->DMA_Handle->XferM1CpltCallback = DCMI_DMAXferCplt;
00391 
00392     /* Initialize transfer parameters */
00393     hdcmi->XferCount = 1U;
00394     hdcmi->XferSize = Length;
00395     hdcmi->pBuffPtr = pData;
00396 
00397     /* Get the number of buffer */
00398     while(hdcmi->XferSize > 0xFFFFU)
00399     {
00400       hdcmi->XferSize = (hdcmi->XferSize/2U);
00401       hdcmi->XferCount = hdcmi->XferCount*2U;
00402     }
00403 
00404     /* Update DCMI counter  and transfer number*/
00405     hdcmi->XferCount = (hdcmi->XferCount - 2U);
00406     hdcmi->XferTransferNumber = hdcmi->XferCount;
00407 
00408     /* Update second memory address */
00409     SecondMemAddress = (uint32_t)(pData + (4U*hdcmi->XferSize));
00410 
00411     /* Start DMA multi buffer transfer */
00412     HAL_DMAEx_MultiBufferStart_IT(hdcmi->DMA_Handle, (uint32_t)&hdcmi->Instance->DR, (uint32_t)pData, SecondMemAddress, hdcmi->XferSize);
00413   }
00414 
00415   /* Enable Capture */
00416   hdcmi->Instance->CR |= DCMI_CR_CAPTURE;
00417 
00418   /* Release Lock */
00419   __HAL_UNLOCK(hdcmi);
00420 
00421   /* Return function status */
00422   return HAL_OK;
00423 }
00424 
00425 /**
00426   * @brief  Disable DCMI DMA request and Disable DCMI capture
00427   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00428   *                the configuration information for DCMI.
00429   * @retval HAL status
00430   */
00431 HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi)
00432 {
00433   __IO uint32_t count = SystemCoreClock / HAL_TIMEOUT_DCMI_STOP;
00434   HAL_StatusTypeDef status = HAL_OK;
00435 
00436   /* Process locked */
00437   __HAL_LOCK(hdcmi);
00438   
00439   /* Lock the DCMI peripheral state */
00440   hdcmi->State = HAL_DCMI_STATE_BUSY;
00441 
00442   /* Disable Capture */
00443   hdcmi->Instance->CR &= ~(DCMI_CR_CAPTURE);
00444 
00445   /* Check if the DCMI capture effectively disabled */
00446   do
00447   {
00448     if (count-- == 0U)
00449     {
00450       /* Update error code */
00451       hdcmi->ErrorCode |= HAL_DCMI_ERROR_TIMEOUT;
00452 
00453       status = HAL_TIMEOUT;
00454       break;
00455     }
00456   }
00457   while((hdcmi->Instance->CR & DCMI_CR_CAPTURE) != 0U);
00458 
00459   /* Disable the DCMI */
00460   __HAL_DCMI_DISABLE(hdcmi);
00461 
00462   /* Disable the DMA */
00463   HAL_DMA_Abort(hdcmi->DMA_Handle);
00464 
00465   /* Update error code */
00466   hdcmi->ErrorCode |= HAL_DCMI_ERROR_NONE;
00467 
00468   /* Change DCMI state */
00469   hdcmi->State = HAL_DCMI_STATE_READY;
00470 
00471   /* Process Unlocked */
00472   __HAL_UNLOCK(hdcmi);
00473 
00474   /* Return function status */
00475   return status;
00476 }
00477 
00478 /**
00479   * @brief  Suspend DCMI capture  
00480   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00481   *                the configuration information for DCMI. 
00482   * @retval HAL status     
00483   */
00484 HAL_StatusTypeDef HAL_DCMI_Suspend(DCMI_HandleTypeDef* hdcmi)
00485 {
00486   __IO uint32_t count = SystemCoreClock / HAL_TIMEOUT_DCMI_STOP;
00487   HAL_StatusTypeDef status = HAL_OK;
00488 
00489   /* Process locked */
00490   __HAL_LOCK(hdcmi);
00491 
00492   if(hdcmi->State == HAL_DCMI_STATE_BUSY)
00493   {
00494     /* Change DCMI state */
00495     hdcmi->State = HAL_DCMI_STATE_SUSPENDED;
00496 
00497     /* Disable Capture */
00498     hdcmi->Instance->CR &= ~(DCMI_CR_CAPTURE);
00499 
00500     /* Check if the DCMI capture effectively disabled */
00501     do
00502     {
00503       if (count-- == 0U)
00504       {        
00505         /* Update error code */
00506         hdcmi->ErrorCode |= HAL_DCMI_ERROR_TIMEOUT;
00507         
00508         /* Change DCMI state */
00509         hdcmi->State = HAL_DCMI_STATE_READY;
00510         
00511         status = HAL_TIMEOUT;
00512         break;
00513       }
00514     }
00515     while((hdcmi->Instance->CR & DCMI_CR_CAPTURE) != 0);
00516   }    
00517   /* Process Unlocked */
00518   __HAL_UNLOCK(hdcmi);
00519   
00520   /* Return function status */
00521   return status;
00522 }
00523 
00524 /**
00525   * @brief  Resume DCMI capture  
00526   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00527   *                the configuration information for DCMI. 
00528   * @retval HAL status     
00529   */
00530 HAL_StatusTypeDef HAL_DCMI_Resume(DCMI_HandleTypeDef* hdcmi)
00531 {
00532   /* Process locked */
00533   __HAL_LOCK(hdcmi);
00534   
00535   if(hdcmi->State == HAL_DCMI_STATE_SUSPENDED)
00536   {
00537     /* Change DCMI state */
00538     hdcmi->State = HAL_DCMI_STATE_BUSY;
00539     
00540     /* Disable Capture */
00541     hdcmi->Instance->CR |= DCMI_CR_CAPTURE;
00542   } 
00543   /* Process Unlocked */
00544   __HAL_UNLOCK(hdcmi);
00545   
00546   /* Return function status */
00547   return HAL_OK;
00548 }
00549 
00550 /**
00551   * @brief  Handles DCMI interrupt request.
00552   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00553   *                the configuration information for the DCMI.
00554   * @retval None
00555   */
00556 void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi)
00557 {
00558   uint32_t isr_value = READ_REG(hdcmi->Instance->MISR);
00559 
00560   /* Synchronization error interrupt management *******************************/
00561   if((isr_value & DCMI_FLAG_ERRRI) == DCMI_FLAG_ERRRI)
00562   {
00563     /* Clear the Synchronization error flag */
00564     __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_ERRRI);
00565 
00566     /* Update error code */
00567     hdcmi->ErrorCode |= HAL_DCMI_ERROR_SYNC;
00568 
00569     /* Change DCMI state */
00570     hdcmi->State = HAL_DCMI_STATE_ERROR;
00571     
00572     /* Set the synchronization error callback */
00573     hdcmi->DMA_Handle->XferAbortCallback = DCMI_DMAError;
00574 
00575     /* Abort the DMA Transfer */
00576     HAL_DMA_Abort_IT(hdcmi->DMA_Handle);
00577   }
00578   /* Overflow interrupt management ********************************************/
00579   if((isr_value & DCMI_FLAG_OVRRI) == DCMI_FLAG_OVRRI)
00580   {
00581     /* Clear the Overflow flag */
00582     __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_OVRRI);
00583 
00584     /* Update error code */
00585     hdcmi->ErrorCode |= HAL_DCMI_ERROR_OVR;
00586 
00587     /* Change DCMI state */
00588     hdcmi->State = HAL_DCMI_STATE_ERROR;
00589     
00590     /* Set the overflow callback */
00591     hdcmi->DMA_Handle->XferAbortCallback = DCMI_DMAError;
00592 
00593     /* Abort the DMA Transfer */
00594     HAL_DMA_Abort_IT(hdcmi->DMA_Handle);
00595   }
00596   /* Line Interrupt management ************************************************/
00597   if((isr_value & DCMI_FLAG_LINERI) == DCMI_FLAG_LINERI)
00598   {
00599     /* Clear the Line interrupt flag */
00600     __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_LINERI);
00601     
00602     /* Line interrupt Callback */
00603 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00604     /*Call registered DCMI line event callback*/
00605     hdcmi->LineEventCallback(hdcmi);
00606 #else  
00607     HAL_DCMI_LineEventCallback(hdcmi);
00608 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */     
00609   }
00610   /* VSYNC interrupt management ***********************************************/
00611   if((isr_value & DCMI_FLAG_VSYNCRI) == DCMI_FLAG_VSYNCRI)
00612   {
00613     /* Clear the VSYNC flag */
00614     __HAL_DCMI_CLEAR_FLAG(hdcmi, DCMI_FLAG_VSYNCRI);
00615     
00616     /* VSYNC Callback */
00617 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00618     /*Call registered DCMI vsync event callback*/
00619     hdcmi->VsyncEventCallback(hdcmi);
00620 #else  
00621     HAL_DCMI_VsyncEventCallback(hdcmi);
00622 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */ 
00623   }
00624   /* FRAME interrupt management ***********************************************/
00625   if((isr_value & DCMI_FLAG_FRAMERI) == DCMI_FLAG_FRAMERI)
00626   {
00627     /* When snapshot mode, disable Vsync, Error and Overrun interrupts */
00628     if((hdcmi->Instance->CR & DCMI_CR_CM) == DCMI_MODE_SNAPSHOT)
00629     { 
00630       /* Disable the Line, Vsync, Error and Overrun interrupts */
00631       __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_LINE | DCMI_IT_VSYNC | DCMI_IT_ERR | DCMI_IT_OVR);
00632     }
00633 
00634     /* Disable the Frame interrupt */
00635     __HAL_DCMI_DISABLE_IT(hdcmi, DCMI_IT_FRAME);
00636 
00637     /* Frame Callback */
00638 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00639     /*Call registered DCMI frame event callback*/
00640     hdcmi->FrameEventCallback(hdcmi);
00641 #else  
00642     HAL_DCMI_FrameEventCallback(hdcmi);
00643 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */      
00644   }
00645 }
00646 
00647 /**
00648   * @brief  Error DCMI callback.
00649   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00650   *                the configuration information for DCMI.
00651   * @retval None
00652   */
00653 __weak void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)
00654 {
00655   /* Prevent unused argument(s) compilation warning */
00656   UNUSED(hdcmi);
00657   /* NOTE : This function Should not be modified, when the callback is needed,
00658             the HAL_DCMI_ErrorCallback could be implemented in the user file
00659    */
00660 }
00661 
00662 /**
00663   * @brief  Line Event callback.
00664   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00665   *                the configuration information for DCMI.
00666   * @retval None
00667   */
00668 __weak void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi)
00669 {
00670   /* Prevent unused argument(s) compilation warning */
00671   UNUSED(hdcmi);
00672   /* NOTE : This function Should not be modified, when the callback is needed,
00673             the HAL_DCMI_LineEventCallback could be implemented in the user file
00674    */
00675 }
00676 
00677 /**
00678   * @brief  VSYNC Event callback.
00679   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00680   *                the configuration information for DCMI.
00681   * @retval None
00682   */
00683 __weak void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi)
00684 {
00685   /* Prevent unused argument(s) compilation warning */
00686   UNUSED(hdcmi);
00687   /* NOTE : This function Should not be modified, when the callback is needed,
00688             the HAL_DCMI_VsyncEventCallback could be implemented in the user file
00689    */
00690 }
00691 
00692 /**
00693   * @brief  Frame Event callback.
00694   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00695   *                the configuration information for DCMI.
00696   * @retval None
00697   */
00698 __weak void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)
00699 {
00700   /* Prevent unused argument(s) compilation warning */
00701   UNUSED(hdcmi);
00702   /* NOTE : This function Should not be modified, when the callback is needed,
00703             the HAL_DCMI_FrameEventCallback could be implemented in the user file
00704    */
00705 }
00706 
00707 /**
00708   * @}
00709   */
00710 
00711 /** @defgroup DCMI_Exported_Functions_Group3 Peripheral Control functions
00712   *  @brief    Peripheral Control functions
00713   *
00714 @verbatim
00715  ===============================================================================
00716                     ##### Peripheral Control functions #####
00717  ===============================================================================
00718 [..]  This section provides functions allowing to:
00719       (+) Configure the CROP feature.
00720       (+) Enable/Disable the CROP feature.
00721 
00722 @endverbatim
00723   * @{
00724   */
00725 
00726 /**
00727   * @brief  Configure the DCMI CROP coordinate.
00728   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00729   *                the configuration information for DCMI.
00730   * @param  X0    DCMI window X offset
00731   * @param  Y0    DCMI window Y offset
00732   * @param  XSize DCMI Pixel per line
00733   * @param  YSize DCMI Line number
00734   * @retval HAL status
00735   */
00736 HAL_StatusTypeDef HAL_DCMI_ConfigCrop(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize)
00737 {
00738   /* Process Locked */
00739   __HAL_LOCK(hdcmi);
00740 
00741   /* Lock the DCMI peripheral state */
00742   hdcmi->State = HAL_DCMI_STATE_BUSY;
00743 
00744   /* Check the parameters */
00745   assert_param(IS_DCMI_WINDOW_COORDINATE(X0));
00746   assert_param(IS_DCMI_WINDOW_COORDINATE(YSize));
00747   assert_param(IS_DCMI_WINDOW_COORDINATE(XSize));
00748   assert_param(IS_DCMI_WINDOW_HEIGHT(Y0));
00749 
00750   /* Configure CROP */
00751   hdcmi->Instance->CWSIZER = (XSize | (YSize << DCMI_POSITION_CWSIZE_VLINE));
00752   hdcmi->Instance->CWSTRTR = (X0 | (Y0 << DCMI_POSITION_CWSTRT_VST));
00753 
00754   /* Initialize the DCMI state*/
00755   hdcmi->State  = HAL_DCMI_STATE_READY;
00756 
00757   /* Process Unlocked */
00758   __HAL_UNLOCK(hdcmi);
00759 
00760   return HAL_OK;
00761 }
00762 
00763 /**
00764   * @brief  Disable the Crop feature.
00765   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00766   *                the configuration information for DCMI.
00767   * @retval HAL status
00768   */
00769 HAL_StatusTypeDef HAL_DCMI_DisableCrop(DCMI_HandleTypeDef *hdcmi)
00770 {
00771   /* Process Locked */
00772   __HAL_LOCK(hdcmi);
00773 
00774   /* Lock the DCMI peripheral state */
00775   hdcmi->State = HAL_DCMI_STATE_BUSY;
00776 
00777   /* Disable DCMI Crop feature */
00778   hdcmi->Instance->CR &= ~(uint32_t)DCMI_CR_CROP;
00779 
00780   /* Change the DCMI state*/
00781   hdcmi->State = HAL_DCMI_STATE_READY;
00782 
00783   /* Process Unlocked */
00784   __HAL_UNLOCK(hdcmi);
00785 
00786   return HAL_OK;
00787 }
00788 
00789 /**
00790   * @brief  Enable the Crop feature.
00791   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00792   *                the configuration information for DCMI.
00793   * @retval HAL status
00794   */
00795 HAL_StatusTypeDef HAL_DCMI_EnableCrop(DCMI_HandleTypeDef *hdcmi)
00796 {
00797   /* Process Locked */
00798   __HAL_LOCK(hdcmi);
00799 
00800   /* Lock the DCMI peripheral state */
00801   hdcmi->State = HAL_DCMI_STATE_BUSY;
00802 
00803   /* Enable DCMI Crop feature */
00804   hdcmi->Instance->CR |= (uint32_t)DCMI_CR_CROP;
00805 
00806   /* Change the DCMI state*/
00807   hdcmi->State = HAL_DCMI_STATE_READY;
00808 
00809   /* Process Unlocked */
00810   __HAL_UNLOCK(hdcmi);
00811 
00812   return HAL_OK;
00813 }
00814 
00815 /**
00816   * @brief  Set embedded synchronization delimiters unmasks.
00817   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00818   *               the configuration information for DCMI.
00819   * @param  SyncUnmask pointer to a DCMI_SyncUnmaskTypeDef structure that contains
00820   *                    the embedded synchronization delimiters unmasks.
00821   * @retval HAL status
00822   */
00823 HAL_StatusTypeDef  HAL_DCMI_ConfigSyncUnmask(DCMI_HandleTypeDef *hdcmi, DCMI_SyncUnmaskTypeDef *SyncUnmask)
00824 {
00825   /* Process Locked */
00826   __HAL_LOCK(hdcmi);
00827 
00828   /* Lock the DCMI peripheral state */
00829   hdcmi->State = HAL_DCMI_STATE_BUSY;
00830 
00831   /* Write DCMI embedded synchronization unmask register */
00832   hdcmi->Instance->ESUR = (((uint32_t)SyncUnmask->FrameStartUnmask) |\
00833                            ((uint32_t)SyncUnmask->LineStartUnmask << DCMI_ESUR_LSU_Pos)|\
00834                            ((uint32_t)SyncUnmask->LineEndUnmask << DCMI_ESUR_LEU_Pos)|\
00835                            ((uint32_t)SyncUnmask->FrameEndUnmask << DCMI_ESUR_FEU_Pos));
00836 
00837   /* Change the DCMI state*/
00838   hdcmi->State = HAL_DCMI_STATE_READY;
00839 
00840   /* Process Unlocked */
00841   __HAL_UNLOCK(hdcmi);
00842 
00843   return HAL_OK;
00844 }
00845 
00846 /**
00847   * @}
00848   */
00849 
00850 /** @defgroup DCMI_Exported_Functions_Group4 Peripheral State functions
00851   *  @brief    Peripheral State functions
00852   *
00853 @verbatim
00854  ===============================================================================
00855                ##### Peripheral State and Errors functions #####
00856  ===============================================================================
00857     [..]
00858     This subsection provides functions allowing to
00859       (+) Check the DCMI state.
00860       (+) Get the specific DCMI error flag.
00861 
00862 @endverbatim
00863   * @{
00864   */ 
00865 
00866 /**
00867   * @brief  Return the DCMI state
00868   * @param  hdcmi pointer to a DCMI_HandleTypeDef structure that contains
00869   *                the configuration information for DCMI.
00870   * @retval HAL state
00871   */
00872 HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi)
00873 {
00874   return hdcmi->State;
00875 }
00876 
00877 /**
00878   * @brief  Return the DCMI error code
00879   * @param  hdcmi  pointer to a DCMI_HandleTypeDef structure that contains
00880   *               the configuration information for DCMI.
00881   * @retval DCMI Error Code
00882   */
00883 uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi)
00884 {
00885   return hdcmi->ErrorCode;
00886 }
00887 
00888 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00889 /**
00890   * @brief DCMI Callback registering
00891   * @param hdcmi        pointer to a DCMI_HandleTypeDef structure that contains
00892   *                     the configuration information for DCMI.
00893   * @param CallbackID   dcmi Callback ID
00894   * @param pCallback    pointer to DCMI_CallbackTypeDef structure
00895   * @retval status
00896   */
00897 HAL_StatusTypeDef HAL_DCMI_RegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID, pDCMI_CallbackTypeDef pCallback)
00898 {
00899   HAL_StatusTypeDef status = HAL_OK;
00900   
00901   if(pCallback == NULL)
00902   {
00903     /* update the error code */
00904     hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;  
00905     /* update return status */
00906     status = HAL_ERROR;
00907   }
00908   else
00909   {
00910     if(hdcmi->State == HAL_DCMI_STATE_READY)
00911     {
00912       switch (CallbackID)
00913       {
00914       case HAL_DCMI_FRAME_EVENT_CB_ID :
00915         hdcmi->FrameEventCallback = pCallback;
00916         break;
00917         
00918       case HAL_DCMI_VSYNC_EVENT_CB_ID :
00919         hdcmi->VsyncEventCallback = pCallback;
00920         break; 
00921         
00922       case HAL_DCMI_LINE_EVENT_CB_ID :
00923         hdcmi->LineEventCallback = pCallback;
00924         break;
00925         
00926       case HAL_DCMI_ERROR_CB_ID :
00927         hdcmi->ErrorCallback = pCallback;
00928         break;
00929         
00930       case HAL_DCMI_MSPINIT_CB_ID :
00931         hdcmi->MspInitCallback = pCallback;
00932         break;
00933         
00934       case HAL_DCMI_MSPDEINIT_CB_ID :
00935         hdcmi->MspDeInitCallback = pCallback;
00936         break;    
00937         
00938       default : 
00939         /* Return error status */
00940         status =  HAL_ERROR;
00941         break;
00942       }
00943     }
00944     else if(hdcmi->State == HAL_DCMI_STATE_RESET)
00945     {
00946       switch (CallbackID)
00947       {
00948       case HAL_DCMI_MSPINIT_CB_ID :
00949         hdcmi->MspInitCallback = pCallback;
00950         break;
00951 
00952       case HAL_DCMI_MSPDEINIT_CB_ID :
00953         hdcmi->MspDeInitCallback = pCallback;
00954         break;    
00955         
00956       default : 
00957         /* update the error code */
00958         hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
00959         /* update return status */
00960         status = HAL_ERROR;
00961         break;
00962       }         
00963     }  
00964     else
00965     {
00966       /* update the error code */
00967       hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
00968       /* update return status */
00969       status = HAL_ERROR;
00970     }
00971   }
00972   
00973   return status;
00974 }
00975 
00976 /**
00977   * @brief DCMI Callback Unregistering
00978   * @param hdcmi       dcmi handle
00979   * @param CallbackID  dcmi Callback ID
00980   * @retval status
00981   */
00982 HAL_StatusTypeDef HAL_DCMI_UnRegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID)
00983 {
00984   HAL_StatusTypeDef status = HAL_OK;
00985   
00986   if(hdcmi->State == HAL_DCMI_STATE_READY)
00987   {
00988     switch (CallbackID)
00989     {
00990     case HAL_DCMI_FRAME_EVENT_CB_ID :
00991       hdcmi->FrameEventCallback = HAL_DCMI_FrameEventCallback;  /* Legacy weak  FrameEventCallback  */ 
00992       break;
00993       
00994     case HAL_DCMI_VSYNC_EVENT_CB_ID :
00995       hdcmi->VsyncEventCallback = HAL_DCMI_VsyncEventCallback;  /* Legacy weak VsyncEventCallback       */ 
00996       break;
00997       
00998     case HAL_DCMI_LINE_EVENT_CB_ID :
00999       hdcmi->LineEventCallback = HAL_DCMI_LineEventCallback;    /* Legacy weak LineEventCallback   */
01000       break;
01001       
01002     case HAL_DCMI_ERROR_CB_ID :
01003       hdcmi->ErrorCallback = HAL_DCMI_ErrorCallback;           /* Legacy weak ErrorCallback        */ 
01004       break;  
01005       
01006     case HAL_DCMI_MSPINIT_CB_ID :
01007       hdcmi->MspInitCallback = HAL_DCMI_MspInit;
01008       break;
01009       
01010     case HAL_DCMI_MSPDEINIT_CB_ID :
01011       hdcmi->MspDeInitCallback = HAL_DCMI_MspDeInit;
01012       break;      
01013       
01014     default : 
01015       /* update the error code */
01016       hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
01017       /* update return status */
01018       status = HAL_ERROR;
01019       break;
01020     }
01021   }
01022   else if(hdcmi->State == HAL_DCMI_STATE_RESET)
01023   {
01024     switch (CallbackID)
01025     {
01026     case HAL_DCMI_MSPINIT_CB_ID :
01027       hdcmi->MspInitCallback = HAL_DCMI_MspInit;
01028       break;
01029       
01030     case HAL_DCMI_MSPDEINIT_CB_ID :
01031       hdcmi->MspDeInitCallback = HAL_DCMI_MspDeInit;
01032       break;      
01033       
01034     default : 
01035       /* update the error code */
01036       hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
01037       /* update return status */
01038       status = HAL_ERROR;
01039       break;
01040     }           
01041   }   
01042   else
01043   {
01044     /* update the error code */
01045     hdcmi->ErrorCode |= HAL_DCMI_ERROR_INVALID_CALLBACK;
01046     /* update return status */
01047     status = HAL_ERROR;
01048   }
01049   
01050   return status;
01051 }
01052 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
01053 
01054 /**
01055   * @}
01056   */
01057 /* Private functions ---------------------------------------------------------*/
01058 /** @defgroup DCMI_Private_Functions DCMI Private Functions
01059   * @{
01060   */
01061 
01062 /**
01063   * @brief  DMA conversion complete callback.
01064   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
01065   *               the configuration information for the specified DMA module.
01066   * @retval None
01067   */
01068 static void DCMI_DMAXferCplt(DMA_HandleTypeDef *hdma)
01069 {
01070   uint32_t tmp = 0U;
01071  
01072   DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
01073   
01074   if(hdcmi->XferCount != 0U)
01075   {
01076     /* Update memory 0 address location */
01077     tmp = ((hdcmi->DMA_Handle->Instance->CR) & DMA_SxCR_CT);
01078     if(((hdcmi->XferCount % 2U) == 0U) && (tmp != 0U))
01079     {
01080       tmp = hdcmi->DMA_Handle->Instance->M0AR;
01081       HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8U*hdcmi->XferSize)), MEMORY0);
01082       hdcmi->XferCount--;
01083     }
01084     /* Update memory 1 address location */
01085     else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0U)
01086     {
01087       tmp = hdcmi->DMA_Handle->Instance->M1AR;
01088       HAL_DMAEx_ChangeMemory(hdcmi->DMA_Handle, (tmp + (8U*hdcmi->XferSize)), MEMORY1);
01089       hdcmi->XferCount--;
01090     }
01091   }
01092   /* Update memory 0 address location */
01093   else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) != 0U)
01094   {
01095     hdcmi->DMA_Handle->Instance->M0AR = hdcmi->pBuffPtr;
01096   }
01097   /* Update memory 1 address location */
01098   else if((hdcmi->DMA_Handle->Instance->CR & DMA_SxCR_CT) == 0U)
01099   {
01100     tmp = hdcmi->pBuffPtr;
01101     hdcmi->DMA_Handle->Instance->M1AR = (tmp + (4U*hdcmi->XferSize));
01102     hdcmi->XferCount = hdcmi->XferTransferNumber;
01103   }
01104   
01105   /* Check if the frame is transferred */
01106   if(hdcmi->XferCount == hdcmi->XferTransferNumber)
01107   {
01108     /* Enable the Frame interrupt */
01109     __HAL_DCMI_ENABLE_IT(hdcmi, DCMI_IT_FRAME);
01110     
01111     /* When snapshot mode, set dcmi state to ready */
01112     if((hdcmi->Instance->CR & DCMI_CR_CM) == DCMI_MODE_SNAPSHOT)
01113     {  
01114       hdcmi->State= HAL_DCMI_STATE_READY;
01115     }
01116   }
01117 }
01118 
01119 /**
01120   * @brief  DMA error callback 
01121   * @param  hdma pointer to a DMA_HandleTypeDef structure that contains
01122   *                the configuration information for the specified DMA module.
01123   * @retval None
01124   */
01125 static void DCMI_DMAError(DMA_HandleTypeDef *hdma)
01126 {
01127   DCMI_HandleTypeDef* hdcmi = ( DCMI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
01128   
01129   if(hdcmi->DMA_Handle->ErrorCode != HAL_DMA_ERROR_FE)
01130   {
01131     /* Initialize the DCMI state*/
01132     hdcmi->State = HAL_DCMI_STATE_READY;
01133   }
01134 
01135   /* DCMI error Callback */
01136 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
01137     /*Call registered DCMI error callback*/
01138     hdcmi->ErrorCallback(hdcmi);
01139 #else  
01140   HAL_DCMI_ErrorCallback(hdcmi);
01141 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */   
01142 
01143 }
01144 
01145 /**
01146   * @}
01147   */
01148   
01149 /**
01150   * @}
01151   */
01152 #endif /* STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
01153           STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
01154           STM32F479xx */
01155 #endif /* HAL_DCMI_MODULE_ENABLED */
01156 /**
01157   * @}
01158   */
01159 
01160 /**
01161   * @}
01162   */
01163 
01164 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/