STM32L443xx HAL User Manual
stm32l4xx_hal_dcmi.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_hal_dcmi.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of DCMI HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32L4xx_HAL_DCMI_H
00021 #define STM32L4xx_HAL_DCMI_H
00022 
00023 #ifdef __cplusplus
00024  extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32l4xx_hal_def.h"
00029 
00030 #if defined (DCMI)
00031 
00032 /** @addtogroup STM32L4xx_HAL_Driver
00033   * @{
00034   */
00035 
00036 /** @addtogroup DCMI DCMI
00037   * @brief DCMI HAL module driver
00038   * @{
00039   */
00040 
00041 /* Exported types ------------------------------------------------------------*/
00042 /** @defgroup DCMI_Exported_Types DCMI Exported Types
00043   * @{
00044   */
00045 
00046 /**
00047   * @brief   DCMI Embedded Synchronisation CODE Init structure definition
00048   */
00049 typedef struct
00050 {
00051   uint8_t FrameStartCode; /*!< Specifies the code of the frame start delimiter. */
00052   uint8_t LineStartCode;  /*!< Specifies the code of the line start delimiter.  */
00053   uint8_t LineEndCode;    /*!< Specifies the code of the line end delimiter.    */
00054   uint8_t FrameEndCode;   /*!< Specifies the code of the frame end delimiter.   */
00055 }DCMI_CodesInitTypeDef;
00056 
00057 
00058 /**
00059   * @brief   DCMI Embedded Synchronisation CODE Init structure definition
00060   */
00061 typedef struct
00062 {
00063   uint8_t FrameStartUnmask; /*!< Specifies the frame start delimiter unmask. */
00064   uint8_t LineStartUnmask;  /*!< Specifies the line start delimiter unmask.  */
00065   uint8_t LineEndUnmask;    /*!< Specifies the line end delimiter unmask.    */
00066   uint8_t FrameEndUnmask;   /*!< Specifies the frame end delimiter unmask.   */
00067 }DCMI_SyncUnmaskTypeDef;
00068 
00069 
00070 /**
00071   * @brief   DCMI Init structure definition
00072   */
00073 typedef struct
00074 {
00075   uint32_t  SynchroMode;                /*!< Specifies the Synchronization Mode: Hardware or Embedded.
00076                                              This parameter can be a value of @ref DCMI_Synchronization_Mode */
00077 
00078   uint32_t  PCKPolarity;                /*!< Specifies the Pixel clock polarity: Falling or Rising.
00079                                              This parameter can be a value of @ref DCMI_PIXCK_Polarity       */
00080 
00081   uint32_t  VSPolarity;                 /*!< Specifies the Vertical synchronization polarity: High or Low.
00082                                              This parameter can be a value of @ref DCMI_VSYNC_Polarity       */
00083 
00084   uint32_t  HSPolarity;                 /*!< Specifies the Horizontal synchronization polarity: High or Low.
00085                                              This parameter can be a value of @ref DCMI_HSYNC_Polarity       */
00086 
00087   uint32_t  CaptureRate;                /*!< Specifies the frequency of frame capture: All, 1/2 or 1/4.
00088                                              This parameter can be a value of @ref DCMI_Capture_Rate         */
00089 
00090   uint32_t  ExtendedDataMode;           /*!< Specifies the data width: 8-bit, 10-bit, 12-bit or 14-bit.
00091                                              This parameter can be a value of @ref DCMI_Extended_Data_Mode   */
00092 
00093   DCMI_CodesInitTypeDef SynchroCode;    /*!< Specifies the frame start delimiter codes.                       */
00094 
00095   uint32_t JPEGMode;                    /*!< Enable or Disable the JPEG mode.
00096                                              This parameter can be a value of @ref DCMI_MODE_JPEG            */
00097 
00098   uint32_t ByteSelectMode;              /*!< Specifies the data to be captured by the interface
00099                                             This parameter can be a value of @ref DCMI_Byte_Select_Mode      */
00100 
00101   uint32_t ByteSelectStart;             /*!< Specifies if the data to be captured by the interface is even or odd
00102                                             This parameter can be a value of @ref DCMI_Byte_Select_Start     */
00103 
00104   uint32_t LineSelectMode;              /*!< Specifies the line of data to be captured by the interface
00105                                             This parameter can be a value of @ref DCMI_Line_Select_Mode      */
00106 
00107   uint32_t LineSelectStart;             /*!< Specifies if the line of data to be captured by the interface is even or odd
00108                                             This parameter can be a value of @ref DCMI_Line_Select_Start     */
00109 }DCMI_InitTypeDef;
00110 
00111 
00112 /**
00113   * @brief  HAL DCMI State structures definition
00114   */
00115 typedef enum
00116 {
00117   HAL_DCMI_STATE_RESET             = 0x00U,  /*!< DCMI not yet initialized or disabled  */
00118   HAL_DCMI_STATE_READY             = 0x01U,  /*!< DCMI initialized and ready for use    */
00119   HAL_DCMI_STATE_BUSY              = 0x02U,  /*!< DCMI internal processing is ongoing   */
00120   HAL_DCMI_STATE_TIMEOUT           = 0x03U,  /*!< DCMI timeout state                    */
00121   HAL_DCMI_STATE_ERROR             = 0x04U,  /*!< DCMI error state                      */
00122   HAL_DCMI_STATE_SUSPENDED         = 0x05U   /*!< DCMI suspend state                    */
00123 }HAL_DCMI_StateTypeDef;
00124 
00125 
00126 /**
00127   * @brief  DCMI handle Structure definition
00128   */
00129 typedef struct __DCMI_HandleTypeDef
00130 {
00131   DCMI_TypeDef                  *Instance;           /*!< DCMI Register base address   */
00132 
00133   DCMI_InitTypeDef              Init;                /*!< DCMI init parameters         */
00134 
00135   HAL_LockTypeDef               Lock;                /*!< DCMI locking object          */
00136 
00137   __IO HAL_DCMI_StateTypeDef    State;               /*!< DCMI state                   */
00138 
00139   __IO uint32_t                 XferCount;           /*!< DMA transfers counter        */
00140 
00141   __IO uint32_t                 XferSize;            /*!< DMA transfer size            */
00142 
00143   uint32_t                      pBuffPtr;            /*!< Pointer to DMA output buffer */
00144 
00145   uint32_t                      XferCount_0;         /*!< Initial DMA transfers counter */
00146 
00147   uint32_t                      XferSize_0;          /*!< Initial DMA transfers size   */
00148 
00149   uint32_t                      pBuffPtr_0;          /*!< Saveguard of pointer to DMA output buffer */
00150 
00151   DMA_HandleTypeDef             *DMA_Handle;         /*!< Pointer to DMA handler       */
00152 
00153   DMA_HandleTypeDef             *DMAM2M_Handle;      /*!< Pointer to DMA handler for memory to memory copy
00154                                                         (case picture size >  maximum DMA transfer length) */
00155 
00156   __IO uint32_t                 ErrorCode;           /*!< DCMI Error code              */
00157 
00158   uint32_t                      pCircularBuffer;     /*!< Pointer to intermediate copy buffer
00159                                                         (case picture size >  maximum DMA transfer length) */
00160 
00161   uint32_t                      HalfCopyLength;      /*!< Intermediate copies length
00162                                                         (case picture size >  maximum DMA transfer length) */
00163 
00164 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00165   void    (* FrameEventCallback) ( struct __DCMI_HandleTypeDef *hdcmi);  /*!< DCMI Frame Event Callback */
00166   void    (* VsyncEventCallback) ( struct __DCMI_HandleTypeDef *hdcmi);  /*!< DCMI Vsync Event Callback */
00167   void    (* LineEventCallback ) ( struct __DCMI_HandleTypeDef *hdcmi);  /*!< DCMI Line Event Callback  */
00168   void    (* ErrorCallback)      ( struct __DCMI_HandleTypeDef *hdcmi);  /*!< DCMI Error Callback       */
00169   void    (* MspInitCallback)    ( struct __DCMI_HandleTypeDef *hdcmi);  /*!< DCMI Msp Init callback    */
00170   void    (* MspDeInitCallback)  ( struct __DCMI_HandleTypeDef *hdcmi);  /*!< DCMI Msp DeInit callback  */
00171 #endif  /* USE_HAL_DCMI_REGISTER_CALLBACKS */
00172 
00173 }DCMI_HandleTypeDef;
00174 
00175 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00176 typedef enum
00177 {
00178   HAL_DCMI_FRAME_EVENT_CB_ID    = 0x00U,    /*!< DCMI Frame Event Callback ID */
00179   HAL_DCMI_VSYNC_EVENT_CB_ID    = 0x01U,    /*!< DCMI Vsync Event Callback ID */
00180   HAL_DCMI_LINE_EVENT_CB_ID     = 0x02U,    /*!< DCMI Line Event Callback ID  */
00181   HAL_DCMI_ERROR_CB_ID          = 0x03U,    /*!< DCMI Error Callback ID       */
00182   HAL_DCMI_MSPINIT_CB_ID        = 0x04U,    /*!< DCMI MspInit callback ID     */
00183   HAL_DCMI_MSPDEINIT_CB_ID      = 0x05U     /*!< DCMI MspDeInit callback ID   */
00184 
00185 }HAL_DCMI_CallbackIDTypeDef;
00186 
00187 typedef void (*pDCMI_CallbackTypeDef)(DCMI_HandleTypeDef *hdcmi);
00188 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
00189 
00190 /**
00191   * @}
00192   */
00193 
00194 /* Exported constants --------------------------------------------------------*/
00195 /** @defgroup DCMI_Exported_Constants DCMI Exported Constants
00196   * @{
00197   */
00198 
00199 /** @defgroup DCMI_Error_Code DCMI Error Code
00200   * @{
00201   */
00202 #define HAL_DCMI_ERROR_NONE             ((uint32_t)0x00000000U)  /*!< No error              */
00203 #define HAL_DCMI_ERROR_OVR              ((uint32_t)0x00000001U)  /*!< Overrun error         */
00204 #define HAL_DCMI_ERROR_SYNC             ((uint32_t)0x00000002U)  /*!< Synchronization error */
00205 #define HAL_DCMI_ERROR_TIMEOUT          ((uint32_t)0x00000020U)  /*!< Timeout error         */
00206 #define HAL_DCMI_ERROR_DMA              ((uint32_t)0x00000040U)  /*!< DMA error             */
00207 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00208 #define HAL_DCMI_ERROR_INVALID_CALLBACK ((uint32_t)0x00000080U)  /*!< Invalid callback error */
00209 #endif
00210 /**
00211   * @}
00212   */
00213 
00214 /** @defgroup DCMI_Capture_Mode DCMI Capture Mode
00215   * @{
00216   */
00217 #define DCMI_MODE_CONTINUOUS           ((uint32_t)0x00000000U) /*!< The received data are transferred continuously
00218                                                                     into the destination memory through the DMA             */
00219 #define DCMI_MODE_SNAPSHOT             ((uint32_t)DCMI_CR_CM)  /*!< Once activated, the interface waits for the start of
00220                                                                     frame and then transfers a single frame through the DMA */
00221 /**
00222   * @}
00223   */
00224 
00225 /** @defgroup DCMI_Synchronization_Mode DCMI Synchronization Mode
00226   * @{
00227   */
00228 #define DCMI_SYNCHRO_HARDWARE        ((uint32_t)0x00000000U)  /*!< Hardware synchronization data capture (frame/line start/stop)
00229                                                                    is synchronized with the HSYNC/VSYNC signals                  */
00230 #define DCMI_SYNCHRO_EMBEDDED        ((uint32_t)DCMI_CR_ESS)  /*!< Embedded synchronization data capture is synchronized with
00231                                                                    synchronization codes embedded in the data flow               */
00232 
00233 /**
00234   * @}
00235   */
00236 
00237 /** @defgroup DCMI_PIXCK_Polarity DCMI Pixel Clock Polarity
00238   * @{
00239   */
00240 #define DCMI_PCKPOLARITY_FALLING    ((uint32_t)0x00000000U)     /*!< Pixel clock active on Falling edge */
00241 #define DCMI_PCKPOLARITY_RISING     ((uint32_t)DCMI_CR_PCKPOL)  /*!< Pixel clock active on Rising edge  */
00242 
00243 /**
00244   * @}
00245   */
00246 
00247 /** @defgroup DCMI_VSYNC_Polarity DCMI VSYNC Polarity
00248   * @{
00249   */
00250 #define DCMI_VSPOLARITY_LOW     ((uint32_t)0x00000000U)    /*!< Vertical synchronization active Low  */
00251 #define DCMI_VSPOLARITY_HIGH    ((uint32_t)DCMI_CR_VSPOL)  /*!< Vertical synchronization active High */
00252 
00253 /**
00254   * @}
00255   */
00256 
00257 /** @defgroup DCMI_HSYNC_Polarity DCMI HSYNC Polarity
00258   * @{
00259   */
00260 #define DCMI_HSPOLARITY_LOW     ((uint32_t)0x00000000U)    /*!< Horizontal synchronization active Low  */
00261 #define DCMI_HSPOLARITY_HIGH    ((uint32_t)DCMI_CR_HSPOL)  /*!< Horizontal synchronization active High */
00262 
00263 /**
00264   * @}
00265   */
00266 
00267 /** @defgroup DCMI_JPEG_Mode DCMI JPEG Mode
00268   * @{
00269   */
00270 #define DCMI_JPEG_DISABLE   ((uint32_t)0x00000000U)   /*!< JPEG mode disabled  */
00271 #define DCMI_JPEG_ENABLE    ((uint32_t)DCMI_CR_JPEG)  /*!< JPEG mode enabled   */
00272 
00273 /**
00274   * @}
00275   */
00276 
00277 /** @defgroup DCMI_Capture_Rate DCMI Capture Rate
00278   * @{
00279   */
00280 #define DCMI_CR_ALL_FRAME            ((uint32_t)0x00000000U)     /*!< All frames are captured        */
00281 #define DCMI_CR_ALTERNATE_2_FRAME    ((uint32_t)DCMI_CR_FCRC_0)  /*!< Every alternate frame captured */
00282 #define DCMI_CR_ALTERNATE_4_FRAME    ((uint32_t)DCMI_CR_FCRC_1)  /*!< One frame in 4 frames captured */
00283 
00284 /**
00285   * @}
00286   */
00287 
00288 /** @defgroup DCMI_Extended_Data_Mode DCMI Extended Data Mode
00289   * @{
00290   */
00291 #define DCMI_EXTEND_DATA_8B     ((uint32_t)0x00000000U)                      /*!< Interface captures 8-bit data on every pixel clock  */
00292 #define DCMI_EXTEND_DATA_10B    ((uint32_t)DCMI_CR_EDM_0)                    /*!< Interface captures 10-bit data on every pixel clock */
00293 #define DCMI_EXTEND_DATA_12B    ((uint32_t)DCMI_CR_EDM_1)                    /*!< Interface captures 12-bit data on every pixel clock */
00294 #define DCMI_EXTEND_DATA_14B    ((uint32_t)(DCMI_CR_EDM_0 | DCMI_CR_EDM_1))  /*!< Interface captures 14-bit data on every pixel clock */
00295 
00296 /**
00297   * @}
00298   */
00299 
00300 /** @defgroup DCMI_Byte_Select_Mode DCMI Byte Select Mode
00301   * @{
00302   */
00303 #define DCMI_BSM_ALL                 ((uint32_t)0x00000000U) /*!< Interface captures all received data */
00304 #define DCMI_BSM_OTHER               ((uint32_t)DCMI_CR_BSM_0) /*!< Interface captures every other byte from the received data */
00305 #define DCMI_BSM_ALTERNATE_4         ((uint32_t)DCMI_CR_BSM_1) /*!< Interface captures one byte out of four */
00306 #define DCMI_BSM_ALTERNATE_2         ((uint32_t)(DCMI_CR_BSM_0 | DCMI_CR_BSM_1)) /*!< Interface captures two bytes out of four */
00307 
00308 /**
00309   * @}
00310   */
00311 
00312 /** @defgroup DCMI_Byte_Select_Start DCMI Byte Select Start
00313   * @{
00314   */
00315 #define DCMI_OEBS_ODD               ((uint32_t)0x00000000U)  /*!< Interface captures first data from the frame/line start, second one being dropped */
00316 #define DCMI_OEBS_EVEN              ((uint32_t)DCMI_CR_OEBS) /*!< Interface captures second data from the frame/line start, first one being dropped */
00317 
00318 /**
00319   * @}
00320   */
00321 
00322 /** @defgroup DCMI_Line_Select_Mode DCMI Line Select Mode
00323   * @{
00324   */
00325 #define DCMI_LSM_ALL                 ((uint32_t)0x00000000U) /*!< Interface captures all received lines */
00326 #define DCMI_LSM_ALTERNATE_2         ((uint32_t)DCMI_CR_LSM) /*!< Interface captures one line out of two */
00327 
00328 /**
00329   * @}
00330   */
00331 
00332 /** @defgroup DCMI_Line_Select_Start DCMI Line Select Start
00333   * @{
00334   */
00335 #define DCMI_OELS_ODD               ((uint32_t)0x00000000U) /*!< Interface captures first line from the frame start, second one being dropped */
00336 #define DCMI_OELS_EVEN              ((uint32_t)DCMI_CR_OELS) /*!< Interface captures second line from the frame start, first one being dropped */
00337 
00338 /**
00339   * @}
00340   */
00341 
00342 
00343 /** @defgroup DCMI_interrupt_sources  DCMI Interrupt Sources
00344   * @{
00345   */
00346 #define DCMI_IT_FRAME    ((uint32_t)DCMI_IER_FRAME_IE)    /*!< Capture complete interrupt      */
00347 #define DCMI_IT_OVR      ((uint32_t)DCMI_IER_OVR_IE)      /*!< Overrun interrupt               */
00348 #define DCMI_IT_ERR      ((uint32_t)DCMI_IER_ERR_IE)      /*!< Synchronization error interrupt */
00349 #define DCMI_IT_VSYNC    ((uint32_t)DCMI_IER_VSYNC_IE)    /*!< VSYNC interrupt                 */
00350 #define DCMI_IT_LINE     ((uint32_t)DCMI_IER_LINE_IE)     /*!< Line interrupt                  */
00351 /**
00352   * @}
00353   */
00354 
00355 /** @defgroup DCMI_Flags DCMI Flags
00356   * @{
00357   */
00358 
00359 /**
00360   * @brief   DCMI SR register
00361   */
00362 #define DCMI_FLAG_HSYNC     ((uint32_t)DCMI_SR_INDEX|DCMI_SR_HSYNC) /*!< HSYNC pin state (active line / synchronization between lines)   */
00363 #define DCMI_FLAG_VSYNC     ((uint32_t)DCMI_SR_INDEX|DCMI_SR_VSYNC) /*!< VSYNC pin state (active frame / synchronization between frames) */
00364 #define DCMI_FLAG_FNE       ((uint32_t)DCMI_SR_INDEX|DCMI_SR_FNE)   /*!< FIFO not empty flag                                                 */
00365 /**
00366   * @brief   DCMI RIS register
00367   */
00368 #define DCMI_FLAG_FRAMERI    ((uint32_t)DCMI_RIS_FRAME_RIS)  /*!< Capture complete interrupt flag      */
00369 #define DCMI_FLAG_OVRRI      ((uint32_t)DCMI_RIS_OVR_RIS)    /*!< Overrun interrupt flag               */
00370 #define DCMI_FLAG_ERRRI      ((uint32_t)DCMI_RIS_ERR_RIS)    /*!< Synchronization error interrupt flag */
00371 #define DCMI_FLAG_VSYNCRI    ((uint32_t)DCMI_RIS_VSYNC_RIS)  /*!< VSYNC interrupt flag                 */
00372 #define DCMI_FLAG_LINERI     ((uint32_t)DCMI_RIS_LINE_RIS)   /*!< Line interrupt flag                  */
00373 /**
00374   * @brief   DCMI MIS register
00375   */
00376 #define DCMI_FLAG_FRAMEMI    ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_FRAME_MIS)  /*!< DCMI Capture complete masked interrupt status      */
00377 #define DCMI_FLAG_OVRMI      ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_OVR_MIS  )  /*!< DCMI Overrun masked interrupt status               */
00378 #define DCMI_FLAG_ERRMI      ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_ERR_MIS  )  /*!< DCMI Synchronization error masked interrupt status */
00379 #define DCMI_FLAG_VSYNCMI    ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_VSYNC_MIS)  /*!< DCMI VSYNC masked interrupt status                 */
00380 #define DCMI_FLAG_LINEMI     ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_LINE_MIS )  /*!< DCMI Line masked interrupt status                  */
00381 /**
00382   * @}
00383   */
00384 
00385 /**
00386   * @}
00387   */
00388 
00389 /* Exported macro ------------------------------------------------------------*/
00390 /** @defgroup DCMI_Exported_Macros DCMI Exported Macros
00391   * @{
00392   */
00393 
00394 /** @brief Reset DCMI handle state
00395   * @param  __HANDLE__ specifies the DCMI handle.
00396   * @retval None
00397   */
00398 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00399 #define __HAL_DCMI_RESET_HANDLE_STATE(__HANDLE__) do{                                            \
00400                                                      (__HANDLE__)->State = HAL_DCMI_STATE_RESET; \
00401                                                      (__HANDLE__)->MspInitCallback = NULL;      \
00402                                                      (__HANDLE__)->MspDeInitCallback = NULL;    \
00403                                                    } while(0)
00404 #else
00405 #define __HAL_DCMI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DCMI_STATE_RESET)
00406 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
00407 
00408 /**
00409   * @brief  Enable the DCMI.
00410   * @param  __HANDLE__ DCMI handle
00411   * @retval None
00412   */
00413 #define __HAL_DCMI_ENABLE(__HANDLE__)    ((__HANDLE__)->Instance->CR |= DCMI_CR_ENABLE)
00414 
00415 /**
00416   * @brief  Disable the DCMI.
00417   * @param  __HANDLE__ DCMI handle
00418   * @retval None
00419   */
00420 #define __HAL_DCMI_DISABLE(__HANDLE__)   ((__HANDLE__)->Instance->CR &= ~(DCMI_CR_ENABLE))
00421 
00422 /* Interrupt & Flag management */
00423 /**
00424   * @brief  Get the DCMI pending flag.
00425   * @param  __HANDLE__ DCMI handle
00426   * @param  __FLAG__ Get the specified flag.
00427   *         This parameter can be one of the following values (no combination allowed)
00428   *            @arg DCMI_FLAG_HSYNC: HSYNC pin state (active line / synchronization between lines)
00429   *            @arg DCMI_FLAG_VSYNC: VSYNC pin state (active frame / synchronization between frames)
00430   *            @arg DCMI_FLAG_FNE: FIFO empty flag
00431   *            @arg DCMI_FLAG_FRAMERI: Frame capture complete flag
00432   *            @arg DCMI_FLAG_OVRRI: Overrun flag
00433   *            @arg DCMI_FLAG_ERRRI: Synchronization error flag
00434   *            @arg DCMI_FLAG_VSYNCRI: VSYNC flag
00435   *            @arg DCMI_FLAG_LINERI: Line flag
00436   *            @arg DCMI_FLAG_FRAMEMI: DCMI Capture complete masked interrupt status
00437   *            @arg DCMI_FLAG_OVRMI: DCMI Overrun masked interrupt status
00438   *            @arg DCMI_FLAG_ERRMI: DCMI Synchronization error masked interrupt status
00439   *            @arg DCMI_FLAG_VSYNCMI: DCMI VSYNC masked interrupt status
00440   *            @arg DCMI_FLAG_LINEMI: DCMI Line masked interrupt status
00441   * @retval The state of FLAG.
00442   */
00443 #define __HAL_DCMI_GET_FLAG(__HANDLE__, __FLAG__)\
00444  ((((__FLAG__) & (DCMI_SR_INDEX|DCMI_MIS_INDEX)) == 0x0U)? ((__HANDLE__)->Instance->RISR & (__FLAG__)) :\
00445  (((__FLAG__) & DCMI_SR_INDEX) == 0x0U)? ((__HANDLE__)->Instance->MISR & (__FLAG__)) : ((__HANDLE__)->Instance->SR & (__FLAG__)))
00446 
00447 /**
00448   * @brief  Clear the DCMI pending flag.
00449   * @param  __HANDLE__ DCMI handle
00450   * @param  __FLAG__ specifies the flag to clear.
00451   *         This parameter can be any combination of the following values:
00452   *            @arg DCMI_FLAG_FRAMERI: Frame capture complete flag
00453   *            @arg DCMI_FLAG_OVRRI: Overrun flag
00454   *            @arg DCMI_FLAG_ERRRI: Synchronization error flag
00455   *            @arg DCMI_FLAG_VSYNCRI: VSYNC flag
00456   *            @arg DCMI_FLAG_LINERI: Line flag
00457   * @retval None
00458   */
00459 #define __HAL_DCMI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
00460 
00461 /**
00462   * @brief  Enable the specified DCMI interrupts.
00463   * @param  __HANDLE__ DCMI handle
00464   * @param  __INTERRUPT__ specifies the DCMI interrupt sources to be enabled.
00465   *         This parameter can be any combination of the following values:
00466   *            @arg DCMI_IT_FRAME: Frame capture complete interrupt
00467   *            @arg DCMI_IT_OVR: Overrun interrupt
00468   *            @arg DCMI_IT_ERR: Synchronization error interrupt
00469   *            @arg DCMI_IT_VSYNC: VSYNC interrupt
00470   *            @arg DCMI_IT_LINE: Line interrupt
00471   * @retval None
00472   */
00473 #define __HAL_DCMI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
00474 
00475 /**
00476   * @brief  Disable the specified DCMI interrupts.
00477   * @param  __HANDLE__ DCMI handle
00478   * @param  __INTERRUPT__ specifies the DCMI interrupt sources to be enabled.
00479   *         This parameter can be any combination of the following values:
00480   *            @arg DCMI_IT_FRAME: Frame capture complete interrupt
00481   *            @arg DCMI_IT_OVR: Overrun interrupt
00482   *            @arg DCMI_IT_ERR: Synchronization error interrupt
00483   *            @arg DCMI_IT_VSYNC: VSYNC interrupt
00484   *            @arg DCMI_IT_LINE: Line interrupt
00485   * @retval None
00486   */
00487 #define __HAL_DCMI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= ~(__INTERRUPT__))
00488 
00489 /**
00490   * @brief  Check whether the specified DCMI interrupt has occurred or not.
00491   * @note   A bit in MIS register is set if the corresponding enable bit in
00492   *         DCMI_IER is set and the corresponding bit in DCMI_RIS is set.
00493   * @param  __HANDLE__ DCMI handle
00494   * @param  __INTERRUPT__ specifies the DCMI interrupt flag and source to check.
00495   *         This parameter can be one of the following values:
00496   *            @arg DCMI_IT_FRAME: Frame capture complete interrupt mask
00497   *            @arg DCMI_IT_OVR: Overrun interrupt mask
00498   *            @arg DCMI_IT_ERR: Synchronization error interrupt mask
00499   *            @arg DCMI_IT_VSYNC: VSYNC interrupt mask
00500   *            @arg DCMI_IT_LINE: Line interrupt mask
00501   * @retval The state of INTERRUPT.
00502   */
00503 #define __HAL_DCMI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MIS & (__INTERRUPT__))
00504 
00505 /**
00506   * @}
00507   */
00508 
00509 /* Exported functions --------------------------------------------------------*/
00510 /** @addtogroup DCMI_Exported_Functions
00511   * @{
00512   */
00513 
00514 /** @addtogroup DCMI_Exported_Functions_Group1 Initialization and Configuration functions
00515  * @{
00516  */
00517 
00518 /* Initialization and de-initialization functions *****************************/
00519 HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi);
00520 HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi);
00521 void       HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi);
00522 void       HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi);
00523 
00524 /* Callbacks Register/UnRegister functions  ***********************************/
00525 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
00526 HAL_StatusTypeDef HAL_DCMI_RegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID, pDCMI_CallbackTypeDef pCallback);
00527 HAL_StatusTypeDef HAL_DCMI_UnRegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID);
00528 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
00529 /**
00530   * @}
00531   */
00532 
00533 /** @addtogroup DCMI_Exported_Functions_Group2 IO operation functions
00534  * @{
00535  */
00536 
00537 /* IO operation functions *****************************************************/
00538 HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length);
00539 HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi);
00540 HAL_StatusTypeDef HAL_DCMI_Suspend(DCMI_HandleTypeDef* hdcmi);
00541 HAL_StatusTypeDef HAL_DCMI_Resume(DCMI_HandleTypeDef* hdcmi);
00542 void              HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi);
00543 void              HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi);
00544 void              HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi);
00545 void              HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi);
00546 void              HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi);
00547 /**
00548   * @}
00549   */
00550 
00551 /** @addtogroup DCMI_Exported_Functions_Group3 Peripheral Control functions
00552  * @{
00553  */
00554 /* Peripheral Control functions ***********************************************/
00555 HAL_StatusTypeDef     HAL_DCMI_ConfigCrop(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize);
00556 HAL_StatusTypeDef     HAL_DCMI_EnableCrop(DCMI_HandleTypeDef *hdcmi);
00557 HAL_StatusTypeDef     HAL_DCMI_DisableCrop(DCMI_HandleTypeDef *hdcmi);
00558 HAL_StatusTypeDef     HAL_DCMI_ConfigSyncUnmask(DCMI_HandleTypeDef *hdcmi, DCMI_SyncUnmaskTypeDef *SyncUnmask);
00559 /**
00560   * @}
00561   */
00562 
00563 /** @addtogroup DCMI_Exported_Functions_Group4 Peripheral State functions
00564  * @{
00565  */
00566 /* Peripheral State functions *************************************************/
00567 HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi);
00568 uint32_t              HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi);
00569 /**
00570   * @}
00571   */
00572 
00573 /**
00574   * @}
00575   */
00576 
00577 /* Private types -------------------------------------------------------------*/
00578 /* Private variables ---------------------------------------------------------*/
00579 /* Private constants ---------------------------------------------------------*/
00580 /** @addtogroup DCMI_Private_Constants DCMI Private Constants
00581   * @{
00582   */
00583 
00584 /** @defgroup DCMI_Registers_Indices DCMI Registers Indices
00585   * @{
00586   */
00587 #define DCMI_MIS_INDEX        (0x1000U)         /*!< DCMI MIS register index */
00588 #define DCMI_SR_INDEX         (0x2000U)         /*!< DCMI SR register index */
00589 /**
00590   * @}
00591   */
00592 
00593 /** @defgroup DCMI_Window_Coordinate DCMI Window Coordinate
00594   * @{
00595   */
00596 #define DCMI_WINDOW_COORDINATE    ((uint32_t)0x3FFFU)  /*!< Window coordinate */
00597 /**
00598   * @}
00599   */
00600 
00601 /** @defgroup DCMI_Window_Height DCMI Window Height
00602   * @{
00603   */
00604 #define DCMI_WINDOW_HEIGHT    ((uint32_t)0x1FFFU)  /*!< Window Height */
00605 /**
00606   * @}
00607   */
00608 
00609 /**
00610   * @}
00611   */
00612 
00613 /* Private macro -------------------------------------------------------------*/
00614 /** @defgroup DCMI_Private_Macros DCMI Private Macros
00615   * @{
00616   */
00617 #define IS_DCMI_CAPTURE_MODE(MODE)(((MODE) == DCMI_MODE_CONTINUOUS) || \
00618                                    ((MODE) == DCMI_MODE_SNAPSHOT))
00619 
00620 #define IS_DCMI_SYNCHRO(MODE)(((MODE) == DCMI_SYNCHRO_HARDWARE) || \
00621                               ((MODE) == DCMI_SYNCHRO_EMBEDDED))
00622 
00623 #define IS_DCMI_PCKPOLARITY(POLARITY)(((POLARITY) == DCMI_PCKPOLARITY_FALLING) || \
00624                                       ((POLARITY) == DCMI_PCKPOLARITY_RISING))
00625 
00626 #define IS_DCMI_VSPOLARITY(POLARITY)(((POLARITY) == DCMI_VSPOLARITY_LOW) || \
00627                                      ((POLARITY) == DCMI_VSPOLARITY_HIGH))
00628 
00629 #define IS_DCMI_HSPOLARITY(POLARITY)(((POLARITY) == DCMI_HSPOLARITY_LOW) || \
00630                                      ((POLARITY) == DCMI_HSPOLARITY_HIGH))
00631 
00632 #define IS_DCMI_MODE_JPEG(JPEG_MODE)(((JPEG_MODE) == DCMI_JPEG_DISABLE) || \
00633                                      ((JPEG_MODE) == DCMI_JPEG_ENABLE))
00634 
00635 #define IS_DCMI_CAPTURE_RATE(RATE) (((RATE) == DCMI_CR_ALL_FRAME)         || \
00636                                     ((RATE) == DCMI_CR_ALTERNATE_2_FRAME) || \
00637                                     ((RATE) == DCMI_CR_ALTERNATE_4_FRAME))
00638 
00639 #define IS_DCMI_EXTENDED_DATA(DATA)(((DATA) == DCMI_EXTEND_DATA_8B)  || \
00640                                     ((DATA) == DCMI_EXTEND_DATA_10B) || \
00641                                     ((DATA) == DCMI_EXTEND_DATA_12B) || \
00642                                     ((DATA) == DCMI_EXTEND_DATA_14B))
00643 
00644 #define IS_DCMI_WINDOW_COORDINATE(COORDINATE) ((COORDINATE) <= DCMI_WINDOW_COORDINATE)
00645 
00646 #define IS_DCMI_WINDOW_HEIGHT(HEIGHT) ((HEIGHT) <= DCMI_WINDOW_HEIGHT)
00647 
00648 #define IS_DCMI_BYTE_SELECT_MODE(MODE)(((MODE) == DCMI_BSM_ALL) || \
00649                                        ((MODE) == DCMI_BSM_OTHER) || \
00650                                        ((MODE) == DCMI_BSM_ALTERNATE_4) || \
00651                                        ((MODE) == DCMI_BSM_ALTERNATE_2))
00652 
00653 #define IS_DCMI_BYTE_SELECT_START(POLARITY)(((POLARITY) == DCMI_OEBS_ODD) || \
00654                                             ((POLARITY) == DCMI_OEBS_EVEN))
00655 
00656 #define IS_DCMI_LINE_SELECT_MODE(MODE)(((MODE) == DCMI_LSM_ALL) || \
00657                                        ((MODE) == DCMI_LSM_ALTERNATE_2))
00658 
00659 #define IS_DCMI_LINE_SELECT_START(POLARITY)(((POLARITY) == DCMI_OELS_ODD) || \
00660                                             ((POLARITY) == DCMI_OELS_EVEN))
00661 
00662 /**
00663   * @}
00664   */
00665 
00666 /**
00667   * @}
00668   */
00669 
00670 /**
00671   * @}
00672   */
00673 
00674 #endif /* DCMI */
00675 
00676 #ifdef __cplusplus
00677 }
00678 #endif
00679 
00680 #endif /* STM32L4xx_HAL_DCMI_H */