STM32L4xx_HAL_Driver  1.14.0
stm32l4xx_hal_dcmi.c File Reference

DCMI HAL module driver This file provides firmware functions to manage the following functionalities of the Digital Camera Interface (DCMI) peripheral: More...

Go to the source code of this file.

Functions

static void DCMI_DMAXferCplt (DMA_HandleTypeDef *hdma)
 DMA conversion complete callback. More...
 
static void DCMI_DMAHalfXferCplt (DMA_HandleTypeDef *hdma)
 DMA Half Transfer complete callback. More...
 
static void DCMI_DMAError (DMA_HandleTypeDef *hdma)
 DMA error callback. More...
 
static uint32_t DCMI_TransferSize (uint32_t InputSize)
 Sub-buffers transfer size computation. More...
 
HAL_StatusTypeDef HAL_DCMI_Init (DCMI_HandleTypeDef *hdcmi)
 Initialize the DCMI according to the specified parameters in the DCMI_InitTypeDef and create the associated handle. More...
 
HAL_StatusTypeDef HAL_DCMI_DeInit (DCMI_HandleTypeDef *hdcmi)
 De-initialize the DCMI peripheral, reset control registers to their default values. More...
 
void HAL_DCMI_MspInit (DCMI_HandleTypeDef *hdcmi)
 Initialize the DCMI MSP. More...
 
void HAL_DCMI_MspDeInit (DCMI_HandleTypeDef *hdcmi)
 De-initialize the DCMI MSP. More...
 
HAL_StatusTypeDef HAL_DCMI_Start_DMA (DCMI_HandleTypeDef *hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)
 Enable DCMI capture in DMA mode. More...
 
HAL_StatusTypeDef HAL_DCMI_Stop (DCMI_HandleTypeDef *hdcmi)
 Disable DCMI capture in DMA mode. More...
 
HAL_StatusTypeDef HAL_DCMI_Suspend (DCMI_HandleTypeDef *hdcmi)
 Suspend DCMI capture. More...
 
HAL_StatusTypeDef HAL_DCMI_Resume (DCMI_HandleTypeDef *hdcmi)
 Resume DCMI capture. More...
 
void HAL_DCMI_IRQHandler (DCMI_HandleTypeDef *hdcmi)
 Handle DCMI interrupt request. More...
 
void HAL_DCMI_ErrorCallback (DCMI_HandleTypeDef *hdcmi)
 Error DCMI callback. More...
 
void HAL_DCMI_LineEventCallback (DCMI_HandleTypeDef *hdcmi)
 Line Event callback. More...
 
void HAL_DCMI_VsyncEventCallback (DCMI_HandleTypeDef *hdcmi)
 VSYNC Event callback. More...
 
void HAL_DCMI_FrameEventCallback (DCMI_HandleTypeDef *hdcmi)
 Frame Event callback. More...
 
HAL_StatusTypeDef HAL_DCMI_ConfigCrop (DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize)
 Configure the DCMI crop window coordinates. More...
 
HAL_StatusTypeDef HAL_DCMI_DisableCrop (DCMI_HandleTypeDef *hdcmi)
 Disable the crop feature. More...
 
HAL_StatusTypeDef HAL_DCMI_EnableCrop (DCMI_HandleTypeDef *hdcmi)
 Enable the crop feature. More...
 
HAL_StatusTypeDef HAL_DCMI_ConfigSyncUnmask (DCMI_HandleTypeDef *hdcmi, DCMI_SyncUnmaskTypeDef *SyncUnmask)
 Set embedded synchronization delimiters unmasks. More...
 
HAL_DCMI_StateTypeDef HAL_DCMI_GetState (DCMI_HandleTypeDef *hdcmi)
 Return the DCMI state. More...
 
uint32_t HAL_DCMI_GetError (DCMI_HandleTypeDef *hdcmi)
 Return the DCMI error code. More...
 
HAL_StatusTypeDef HAL_DCMI_RegisterCallback (DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID, pDCMI_CallbackTypeDef pCallback)
 DCMI Callback registering. More...
 
HAL_StatusTypeDef HAL_DCMI_UnRegisterCallback (DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID)
 DCMI Callback Unregistering. More...
 

Detailed Description

DCMI HAL module driver This file provides firmware functions to manage the following functionalities of the Digital Camera Interface (DCMI) peripheral:

Author
MCD Application Team
  • Initialization and de-initialization functions
  • IO operation functions
  • Peripheral Control functions
  • Peripheral State and Error functions
==============================================================================
                      ##### How to use this driver #####
==============================================================================
[..]
    The sequence below describes how to use this driver to capture images
    from a camera module connected to the DCMI Interface.
    This sequence does not take into account the configuration of the
    camera module, which should be made before configuring and enabling
    the DCMI to capture images.

  (#) Program the required configuration through the following parameters:
      horizontal and vertical polarity, pixel clock polarity, capture rate,
      synchronization mode, frame delimiter codes, data width, byte and line
      selection using HAL_DCMI_Init() function.

  (#) Optionally select JPEG mode; in that case, only the polarity
      and the capture mode parameters need to be set.

  (#) Capture mode can be either snapshot or continuous mode.

  (#) Configure the DMA_Handle to transfer data from DCMI DR
      register to the destination memory buffer.

  -@- In snapshot mode, the interface transfers a single frame through DMA. In
     continuous mode, the DMA must be set in circular mode to ensure a continuous
     flow of images data samples.

  (#) Program the transfer configuration through the following parameters:
      DCMI mode, destination memory buffer address and data length then
      enable capture using HAL_DCMI_Start_DMA() function.

  (#) Whether in continuous or snapshot mode, data length parameter must be
      equal to the frame size.

  (#) When the frame size is unknown beforehand (e.g. JPEG case), data length must
      be large enough to ensure the capture of a frame.

  (#) If the frame size is larger than the maximum DMA transfer length (i.e. 65535),
      (++) the DMA must be configured in circular mode, either for snapshot or continuous
           capture mode,
      (++) during capture, the driver copies the image data samples from DCMI DR register
           at the end of the final destination buffer used as a work buffer,
      (++) at each DMA half (respectively complete) transfer interrupt, the first
           (resp. second) half of the work buffer is copied to the final destination thru
           a second DMA channel.
      (++) Parameters of this second DMA channel are contained in the memory to memory DMA
           handle "DMAM2M_Handle", itself field of the DCMI handle structure.
      (++) This memory to memory transfer has length half that of the work buffer and is
           carried out in normal mode (not in circular mode).

  (#) Optionally, configure and enable the CROP feature to select a
      rectangular window from the received image using HAL_DCMI_ConfigCrop()
      and HAL_DCMI_EnableCrop() functions. Use HAL_DCMI_DisableCrop() to
      disable this feature.

  (#) The capture can be stopped with HAL_DCMI_Stop() function.

  (#) To control the DCMI state, use the function HAL_DCMI_GetState().

  (#) To read the DCMI error code, use the function HAL_DCMI_GetError().

  [..]
  (@) When the frame size is less than the maximum DMA transfer length (i.e. 65535)
      and when in snapshot mode, user must make sure the FRAME interrupt is disabled.
      This allows to avoid corner cases where the FRAME interrupt might be triggered
      before the DMA transfer completion interrupt. In this specific configuration,
      the driver checks the FRAME capture flag after the DMA transfer end and calls
      HAL_DCMI_FrameEventCallback() if the flag is set.

   *** DCMI HAL driver macros list ***
   =============================================
   [..]
     Below the list of most used macros in DCMI HAL driver.

    (+) __HAL_DCMI_ENABLE: Enable the DCMI peripheral.
    (+) __HAL_DCMI_DISABLE: Disable the DCMI peripheral.
    (+) __HAL_DCMI_GET_FLAG: Get the DCMI pending flags.
    (+) __HAL_DCMI_CLEAR_FLAG: Clear the DCMI pending flags.
    (+) __HAL_DCMI_ENABLE_IT: Enable the specified DCMI interrupts.
    (+) __HAL_DCMI_DISABLE_IT: Disable the specified DCMI interrupts.
    (+) __HAL_DCMI_GET_IT_SOURCE: Check whether the specified DCMI interrupt has occurred or not.

  *** Callback registration ***
  =============================

  The compilation define USE_HAL_DCMI_REGISTER_CALLBACKS when set to 1
  allows the user to configure dynamically the driver callbacks.
  Use functions @ref HAL_DCMI_RegisterCallback() to register a user callback.

  Function @ref HAL_DCMI_RegisterCallback() allows to register following callbacks:
    (+) FrameEventCallback : DCMI Frame Event.
    (+) VsyncEventCallback : DCMI Vsync Event.
    (+) LineEventCallback  : DCMI Line Event.
    (+) ErrorCallback      : DCMI error.
    (+) MspInitCallback    : DCMI MspInit.
    (+) MspDeInitCallback  : DCMI MspDeInit.
  This function takes as parameters the HAL peripheral handle, the callback ID
  and a pointer to the user callback function.

  Use function @ref HAL_DCMI_UnRegisterCallback() to reset a callback to the default
  weak (surcharged) function.
  @ref HAL_DCMI_UnRegisterCallback() takes as parameters the HAL peripheral handle,
  and the callback ID.
  This function allows to reset following callbacks:
    (+) FrameEventCallback : DCMI Frame Event.
    (+) VsyncEventCallback : DCMI Vsync Event.
    (+) LineEventCallback  : DCMI Line Event.
    (+) ErrorCallback      : DCMI error.
    (+) MspInitCallback    : DCMI MspInit.
    (+) MspDeInitCallback  : DCMI MspDeInit.

  By default, after the @ref HAL_DCMI_Init and if the state is HAL_DCMI_STATE_RESET
  all callbacks are reset to the corresponding legacy weak (surcharged) functions:
  examples @ref FrameEventCallback(), @ref HAL_DCMI_ErrorCallback().
  Exception done for MspInit and MspDeInit callbacks that are respectively
  reset to the legacy weak (surcharged) functions in the @ref HAL_DCMI_Init
  and @ref  HAL_DCMI_DeInit only when these callbacks are null (not registered beforehand).
  If not, MspInit or MspDeInit are not null, the @ref HAL_DCMI_Init and @ref HAL_DCMI_DeInit
  keep and use the user MspInit/MspDeInit callbacks (registered beforehand).

  Callbacks can be registered/unregistered in READY state only.
  Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered
  in READY or RESET state, thus registered (user) MspInit/DeInit callbacks can be used
  during the Init/DeInit.
  In that case first register the MspInit/MspDeInit user callbacks
  using @ref HAL_DCMI_RegisterCallback before calling @ref HAL_DCMI_DeInit
  or @ref HAL_DCMI_Init function.

  When the compilation define USE_HAL_DCMI_REGISTER_CALLBACKS is set to 0 or
  not defined, the callback registering feature is not available
  and weak (surcharged) callbacks are used.
Attention

© Copyright (c) 2017 STMicroelectronics. All rights reserved.

This software component is licensed by ST under BSD 3-Clause license, the "License"; You may not use this file except in compliance with the License. You may obtain a copy of the License at: opensource.org/licenses/BSD-3-Clause

Definition in file stm32l4xx_hal_dcmi.c.