1 /**
2   ******************************************************************************
3   * @file    stm32f2xx_hal_dcmi.h
4   * @author  MCD Application Team
5   * @brief   Header file of DCMI HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2016 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32F2xx_HAL_DCMI_H
21 #define STM32F2xx_HAL_DCMI_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32f2xx_hal_def.h"
29 
30 #if defined (DCMI)
31 
32 /** @addtogroup STM32F2xx_HAL_Driver
33   * @{
34   */
35 
36 /** @addtogroup DCMI DCMI
37   * @brief DCMI HAL module driver
38   * @{
39   */
40 
41 /* Exported types ------------------------------------------------------------*/
42 /** @defgroup DCMI_Exported_Types DCMI Exported Types
43   * @{
44   */
45 /**
46   * @brief  HAL DCMI State structures definition
47   */
48 typedef enum
49 {
50   HAL_DCMI_STATE_RESET             = 0x00U,  /*!< DCMI not yet initialized or disabled  */
51   HAL_DCMI_STATE_READY             = 0x01U,  /*!< DCMI initialized and ready for use    */
52   HAL_DCMI_STATE_BUSY              = 0x02U,  /*!< DCMI internal processing is ongoing   */
53   HAL_DCMI_STATE_TIMEOUT           = 0x03U,  /*!< DCMI timeout state                    */
54   HAL_DCMI_STATE_ERROR             = 0x04U,  /*!< DCMI error state                      */
55   HAL_DCMI_STATE_SUSPENDED         = 0x05U   /*!< DCMI suspend state                    */
56 } HAL_DCMI_StateTypeDef;
57 
58 /**
59   * @brief   DCMI Embedded Synchronisation CODE Init structure definition
60   */
61 typedef struct
62 {
63   uint8_t FrameStartCode; /*!< Specifies the code of the frame start delimiter. */
64   uint8_t LineStartCode;  /*!< Specifies the code of the line start delimiter.  */
65   uint8_t LineEndCode;    /*!< Specifies the code of the line end delimiter.    */
66   uint8_t FrameEndCode;   /*!< Specifies the code of the frame end delimiter.   */
67 } DCMI_CodesInitTypeDef;
68 
69 /**
70   * @brief   DCMI Embedded Synchronisation UNMASK Init structure definition
71   */
72 typedef struct
73 {
74   uint8_t FrameStartUnmask; /*!< Specifies the frame start delimiter unmask. */
75   uint8_t LineStartUnmask;  /*!< Specifies the line start delimiter unmask.  */
76   uint8_t LineEndUnmask;    /*!< Specifies the line end delimiter unmask.    */
77   uint8_t FrameEndUnmask;   /*!< Specifies the frame end delimiter unmask.   */
78 } DCMI_SyncUnmaskTypeDef;
79 /**
80   * @brief   DCMI Init structure definition
81   */
82 typedef struct
83 {
84   uint32_t  SynchroMode;                /*!< Specifies the Synchronization Mode: Hardware or Embedded.
85                                              This parameter can be a value of @ref DCMI_Synchronization_Mode */
86 
87   uint32_t  PCKPolarity;                /*!< Specifies the Pixel clock polarity: Falling or Rising.
88                                              This parameter can be a value of @ref DCMI_PIXCK_Polarity       */
89 
90   uint32_t  VSPolarity;                 /*!< Specifies the Vertical synchronization polarity: High or Low.
91                                              This parameter can be a value of @ref DCMI_VSYNC_Polarity       */
92 
93   uint32_t  HSPolarity;                 /*!< Specifies the Horizontal synchronization polarity: High or Low.
94                                              This parameter can be a value of @ref DCMI_HSYNC_Polarity       */
95 
96   uint32_t  CaptureRate;                /*!< Specifies the frequency of frame capture: All, 1/2 or 1/4.
97                                              This parameter can be a value of @ref DCMI_Capture_Rate         */
98 
99   uint32_t  ExtendedDataMode;           /*!< Specifies the data width: 8-bit, 10-bit, 12-bit or 14-bit.
100                                              This parameter can be a value of @ref DCMI_Extended_Data_Mode   */
101 
102   DCMI_CodesInitTypeDef SyncroCode;     /*!< Specifies the code of the line/frame start delimiter and the
103                                              line/frame end delimiter */
104 
105   uint32_t JPEGMode;                    /*!< Enable or Disable the JPEG mode.
106                                              This parameter can be a value of @ref DCMI_MODE_JPEG            */
107 } DCMI_InitTypeDef;
108 
109 /**
110   * @brief  DCMI handle Structure definition
111   */
112 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
113 typedef struct  __DCMI_HandleTypeDef
114 #else
115 typedef struct
116 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
117 {
118   DCMI_TypeDef                  *Instance;           /*!< DCMI Register base address   */
119 
120   DCMI_InitTypeDef              Init;                /*!< DCMI parameters              */
121 
122   HAL_LockTypeDef               Lock;                /*!< DCMI locking object          */
123 
124   __IO HAL_DCMI_StateTypeDef    State;               /*!< DCMI state                   */
125 
126   __IO uint32_t                 XferCount;           /*!< DMA transfer counter         */
127 
128   __IO uint32_t                 XferSize;            /*!< DMA transfer size            */
129 
130   uint32_t                      XferTransferNumber;  /*!< DMA transfer number          */
131 
132   uint32_t                      pBuffPtr;            /*!< Pointer to DMA output buffer */
133 
134   DMA_HandleTypeDef             *DMA_Handle;         /*!< Pointer to the DMA handler   */
135 
136   __IO uint32_t                 ErrorCode;           /*!< DCMI Error code              */
137 
138 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
139   void (* FrameEventCallback)(struct __DCMI_HandleTypeDef *hdcmi);       /*!< DCMI Frame Event Callback */
140   void (* VsyncEventCallback)(struct __DCMI_HandleTypeDef *hdcmi);       /*!< DCMI Vsync Event Callback */
141   void (* LineEventCallback)(struct __DCMI_HandleTypeDef *hdcmi);        /*!< DCMI Line Event Callback  */
142   void (* ErrorCallback)(struct __DCMI_HandleTypeDef *hdcmi);            /*!< DCMI Error Callback       */
143   void (* MspInitCallback)(struct __DCMI_HandleTypeDef *hdcmi);          /*!< DCMI Msp Init callback    */
144   void (* MspDeInitCallback)(struct __DCMI_HandleTypeDef *hdcmi);        /*!< DCMI Msp DeInit callback  */
145 #endif  /* USE_HAL_DCMI_REGISTER_CALLBACKS */
146 } DCMI_HandleTypeDef;
147 
148 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
149 /**
150   * @brief  HAL DCMI Callback ID enumeration definition
151   */
152 typedef enum
153 {
154   HAL_DCMI_FRAME_EVENT_CB_ID    = 0x00U,    /*!< DCMI Frame Event Callback ID */
155   HAL_DCMI_VSYNC_EVENT_CB_ID    = 0x01U,    /*!< DCMI Vsync Event Callback ID */
156   HAL_DCMI_LINE_EVENT_CB_ID     = 0x02U,    /*!< DCMI Line Event Callback ID  */
157   HAL_DCMI_ERROR_CB_ID          = 0x03U,    /*!< DCMI Error Callback ID       */
158   HAL_DCMI_MSPINIT_CB_ID        = 0x04U,    /*!< DCMI MspInit callback ID     */
159   HAL_DCMI_MSPDEINIT_CB_ID      = 0x05U     /*!< DCMI MspDeInit callback ID   */
160 
161 } HAL_DCMI_CallbackIDTypeDef;
162 
163 /**
164   * @brief  HAL DCMI Callback pointer definition
165   */
166 typedef void (*pDCMI_CallbackTypeDef)(DCMI_HandleTypeDef *hdcmi); /*!< pointer to a DCMI callback function */
167 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
168 
169 
170 /**
171   * @}
172   */
173 /* Exported constants --------------------------------------------------------*/
174 
175 /** @defgroup DCMI_Exported_Constants DCMI Exported Constants
176   * @{
177   */
178 
179 /** @defgroup DCMI_Error_Code DCMI Error Code
180   * @{
181   */
182 #define HAL_DCMI_ERROR_NONE             (0x00000000U)  /*!< No error              */
183 #define HAL_DCMI_ERROR_OVR              (0x00000001U)  /*!< Overrun error         */
184 #define HAL_DCMI_ERROR_SYNC             (0x00000002U)  /*!< Synchronization error */
185 #define HAL_DCMI_ERROR_TIMEOUT          (0x00000020U)  /*!< Timeout error         */
186 #define HAL_DCMI_ERROR_DMA              (0x00000040U)  /*!< DMA error             */
187 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
188 #define HAL_DCMI_ERROR_INVALID_CALLBACK (0x00000080U)  /*!< Invalid callback error */
189 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
190 /**
191   * @}
192   */
193 
194 /** @defgroup DCMI_Capture_Mode DCMI Capture Mode
195   * @{
196   */
197 #define DCMI_MODE_CONTINUOUS           (0x00000000U)          /*!< The received data are transferred continuously
198                                                                    into the destination memory through the DMA    */
199 #define DCMI_MODE_SNAPSHOT             ((uint32_t)DCMI_CR_CM) /*!< Once activated, the interface waits for the start of
200                                                                    frame and then transfers a single frame
201                                                                    through the DMA */
202 /**
203   * @}
204   */
205 
206 /** @defgroup DCMI_Synchronization_Mode DCMI Synchronization Mode
207   * @{
208   */
209 #define DCMI_SYNCHRO_HARDWARE        (0x00000000U)   /*!< Hardware synchronization data capture (frame/line start/stop)
210                                                           is synchronized with the HSYNC/VSYNC signals               */
211 #define DCMI_SYNCHRO_EMBEDDED        ((uint32_t)DCMI_CR_ESS)  /*!< Embedded synchronization data capture is synchronized
212                                                                  with synchronization codes embedded in the data flow */
213 
214 /**
215   * @}
216   */
217 
218 /** @defgroup DCMI_PIXCK_Polarity DCMI PIXCK Polarity
219   * @{
220   */
221 #define DCMI_PCKPOLARITY_FALLING    (0x00000000U)      /*!< Pixel clock active on Falling edge */
222 #define DCMI_PCKPOLARITY_RISING     ((uint32_t)DCMI_CR_PCKPOL)  /*!< Pixel clock active on Rising edge  */
223 
224 /**
225   * @}
226   */
227 
228 /** @defgroup DCMI_VSYNC_Polarity DCMI VSYNC Polarity
229   * @{
230   */
231 #define DCMI_VSPOLARITY_LOW     (0x00000000U)     /*!< Vertical synchronization active Low  */
232 #define DCMI_VSPOLARITY_HIGH    ((uint32_t)DCMI_CR_VSPOL)  /*!< Vertical synchronization active High */
233 
234 /**
235   * @}
236   */
237 
238 /** @defgroup DCMI_HSYNC_Polarity DCMI HSYNC Polarity
239   * @{
240   */
241 #define DCMI_HSPOLARITY_LOW     (0x00000000U)     /*!< Horizontal synchronization active Low  */
242 #define DCMI_HSPOLARITY_HIGH    ((uint32_t)DCMI_CR_HSPOL)  /*!< Horizontal synchronization active High */
243 
244 /**
245   * @}
246   */
247 
248 /** @defgroup DCMI_MODE_JPEG DCMI MODE JPEG
249   * @{
250   */
251 #define DCMI_JPEG_DISABLE   (0x00000000U)    /*!< Mode JPEG Disabled  */
252 #define DCMI_JPEG_ENABLE    ((uint32_t)DCMI_CR_JPEG)  /*!< Mode JPEG Enabled   */
253 
254 /**
255   * @}
256   */
257 
258 /** @defgroup DCMI_Capture_Rate DCMI Capture Rate
259   * @{
260   */
261 #define DCMI_CR_ALL_FRAME            (0x00000000U)      /*!< All frames are captured        */
262 #define DCMI_CR_ALTERNATE_2_FRAME    ((uint32_t)DCMI_CR_FCRC_0)  /*!< Every alternate frame captured */
263 #define DCMI_CR_ALTERNATE_4_FRAME    ((uint32_t)DCMI_CR_FCRC_1)  /*!< One frame in 4 frames captured */
264 
265 /**
266   * @}
267   */
268 
269 /** @defgroup DCMI_Extended_Data_Mode DCMI Extended Data Mode
270   * @{
271   */
272 #define DCMI_EXTEND_DATA_8B     (0x00000000U)              /*!< Interface captures 8-bit data on every pixel clock  */
273 #define DCMI_EXTEND_DATA_10B    ((uint32_t)DCMI_CR_EDM_0)  /*!< Interface captures 10-bit data on every pixel clock */
274 #define DCMI_EXTEND_DATA_12B    ((uint32_t)DCMI_CR_EDM_1)  /*!< Interface captures 12-bit data on every pixel clock */
275 #define DCMI_EXTEND_DATA_14B    ((uint32_t)(DCMI_CR_EDM_0 |\
276                                             DCMI_CR_EDM_1))          /*!< Interface captures 14-bit data on every pixel clock */
277 
278 /**
279   * @}
280   */
281 
282 /** @defgroup DCMI_Window_Coordinate DCMI Window Coordinate
283   * @{
284   */
285 #define DCMI_WINDOW_COORDINATE    (0x3FFFU)  /*!< Window coordinate */
286 
287 /**
288   * @}
289   */
290 
291 /** @defgroup DCMI_Window_Height DCMI Window Height
292   * @{
293   */
294 #define DCMI_WINDOW_HEIGHT    (0x1FFFU)  /*!< Window Height */
295 
296 /**
297   * @}
298   */
299 
300 /** @defgroup DCMI_interrupt_sources  DCMI interrupt sources
301   * @{
302   */
303 #define DCMI_IT_FRAME    ((uint32_t)DCMI_IER_FRAME_IE)    /*!< Capture complete interrupt      */
304 #define DCMI_IT_OVR      ((uint32_t)DCMI_IER_OVR_IE)      /*!< Overrun interrupt               */
305 #define DCMI_IT_ERR      ((uint32_t)DCMI_IER_ERR_IE)      /*!< Synchronization error interrupt */
306 #define DCMI_IT_VSYNC    ((uint32_t)DCMI_IER_VSYNC_IE)    /*!< VSYNC interrupt                 */
307 #define DCMI_IT_LINE     ((uint32_t)DCMI_IER_LINE_IE)     /*!< Line interrupt                  */
308 /**
309   * @}
310   */
311 
312 /** @defgroup DCMI_Flags DCMI Flags
313   * @{
314   */
315 
316 /**
317   * @brief   DCMI SR register
318   */
319 #define DCMI_FLAG_HSYNC     ((uint32_t)DCMI_SR_INDEX|DCMI_SR_HSYNC) /*!< HSYNC pin state (active line / synchronization
320                                                                          between lines)   */
321 #define DCMI_FLAG_VSYNC     ((uint32_t)DCMI_SR_INDEX|DCMI_SR_VSYNC) /*!< VSYNC pin state (active frame / synchronization
322                                                                          between frames) */
323 #define DCMI_FLAG_FNE       ((uint32_t)DCMI_SR_INDEX|DCMI_SR_FNE)   /*!< FIFO not empty flag                          */
324 /**
325   * @brief   DCMI RIS register
326   */
327 #define DCMI_FLAG_FRAMERI    ((uint32_t)DCMI_RIS_FRAME_RIS)  /*!< Frame capture complete interrupt flag */
328 #define DCMI_FLAG_OVRRI      ((uint32_t)DCMI_RIS_OVR_RIS)    /*!< Overrun interrupt flag                */
329 #define DCMI_FLAG_ERRRI      ((uint32_t)DCMI_RIS_ERR_RIS)    /*!< Synchronization error interrupt flag  */
330 #define DCMI_FLAG_VSYNCRI    ((uint32_t)DCMI_RIS_VSYNC_RIS)  /*!< VSYNC interrupt flag                  */
331 #define DCMI_FLAG_LINERI     ((uint32_t)DCMI_RIS_LINE_RIS)   /*!< Line interrupt flag                   */
332 /**
333   * @brief   DCMI MIS register
334   */
335 #define DCMI_FLAG_FRAMEMI    ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_FRAME_MIS)  /*!< DCMI Frame capture complete masked
336                                    interrupt status */
337 #define DCMI_FLAG_OVRMI      ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_OVR_MIS  )  /*!< DCMI Overrun masked interrupt status                */
338 #define DCMI_FLAG_ERRMI      ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_ERR_MIS  )  /*!< DCMI Synchronization error masked interrupt status  */
339 #define DCMI_FLAG_VSYNCMI    ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_VSYNC_MIS)  /*!< DCMI VSYNC masked interrupt status                  */
340 #define DCMI_FLAG_LINEMI     ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_LINE_MIS )  /*!< DCMI Line masked interrupt status                   */
341 /**
342   * @}
343   */
344 
345 /**
346   * @}
347   */
348 
349 /* Exported macro ------------------------------------------------------------*/
350 /** @defgroup DCMI_Exported_Macros DCMI Exported Macros
351   * @{
352   */
353 
354 /** @brief Reset DCMI handle state
355   * @param  __HANDLE__ specifies the DCMI handle.
356   * @retval None
357   */
358 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
359 #define __HAL_DCMI_RESET_HANDLE_STATE(__HANDLE__)  do{                                             \
360                                                        (__HANDLE__)->State = HAL_DCMI_STATE_RESET; \
361                                                        (__HANDLE__)->MspInitCallback = NULL;       \
362                                                        (__HANDLE__)->MspDeInitCallback = NULL;     \
363                                                      } while(0)
364 #else
365 #define __HAL_DCMI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DCMI_STATE_RESET)
366 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
367 
368 /**
369   * @brief  Enable the DCMI.
370   * @param  __HANDLE__ DCMI handle
371   * @retval None
372   */
373 #define __HAL_DCMI_ENABLE(__HANDLE__)    ((__HANDLE__)->Instance->CR |= DCMI_CR_ENABLE)
374 
375 /**
376   * @brief  Disable the DCMI.
377   * @param  __HANDLE__ DCMI handle
378   * @retval None
379   */
380 #define __HAL_DCMI_DISABLE(__HANDLE__)   ((__HANDLE__)->Instance->CR &= ~(DCMI_CR_ENABLE))
381 
382 /* Interrupt & Flag management */
383 /**
384   * @brief  Get the DCMI pending flag.
385   * @param  __HANDLE__ DCMI handle
386   * @param  __FLAG__ Get the specified flag.
387   *         This parameter can be one of the following values (no combination allowed)
388   *            @arg DCMI_FLAG_HSYNC: HSYNC pin state (active line / synchronization between lines)
389   *            @arg DCMI_FLAG_VSYNC: VSYNC pin state (active frame / synchronization between frames)
390   *            @arg DCMI_FLAG_FNE: FIFO empty flag
391   *            @arg DCMI_FLAG_FRAMERI: Frame capture complete flag mask
392   *            @arg DCMI_FLAG_OVRRI: Overrun flag mask
393   *            @arg DCMI_FLAG_ERRRI: Synchronization error flag mask
394   *            @arg DCMI_FLAG_VSYNCRI: VSYNC flag mask
395   *            @arg DCMI_FLAG_LINERI: Line flag mask
396   *            @arg DCMI_FLAG_FRAMEMI: DCMI Capture complete masked interrupt status
397   *            @arg DCMI_FLAG_OVRMI: DCMI Overrun masked interrupt status
398   *            @arg DCMI_FLAG_ERRMI: DCMI Synchronization error masked interrupt status
399   *            @arg DCMI_FLAG_VSYNCMI: DCMI VSYNC masked interrupt status
400   *            @arg DCMI_FLAG_LINEMI: DCMI Line masked interrupt status
401   * @retval The state of FLAG.
402   */
403 #define __HAL_DCMI_GET_FLAG(__HANDLE__, __FLAG__)\
404   ((((__FLAG__) & (DCMI_SR_INDEX|DCMI_MIS_INDEX)) == 0x0)? ((__HANDLE__)->Instance->RIS & (__FLAG__)) :\
405    (((__FLAG__) & DCMI_SR_INDEX) == 0x0)? ((__HANDLE__)->Instance->MIS & (__FLAG__)) :\
406    ((__HANDLE__)->Instance->SR & (__FLAG__)))
407 
408 /**
409   * @brief  Clear the DCMI pending flags.
410   * @param  __HANDLE__ DCMI handle
411   * @param  __FLAG__ specifies the flag to clear.
412   *         This parameter can be any combination of the following values:
413   *            @arg DCMI_FLAG_FRAMERI: Frame capture complete flag mask
414   *            @arg DCMI_FLAG_OVFRI: Overflow flag mask
415   *            @arg DCMI_FLAG_ERRRI: Synchronization error flag mask
416   *            @arg DCMI_FLAG_VSYNCRI: VSYNC flag mask
417   *            @arg DCMI_FLAG_LINERI: Line flag mask
418   * @retval None
419   */
420 #define __HAL_DCMI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
421 
422 /**
423   * @brief  Enable the specified DCMI interrupts.
424   * @param  __HANDLE__    DCMI handle
425   * @param  __INTERRUPT__ specifies the DCMI interrupt sources to be enabled.
426   *         This parameter can be any combination of the following values:
427   *            @arg DCMI_IT_FRAME: Frame capture complete interrupt mask
428   *            @arg DCMI_IT_OVF: Overflow interrupt mask
429   *            @arg DCMI_IT_ERR: Synchronization error interrupt mask
430   *            @arg DCMI_IT_VSYNC: VSYNC interrupt mask
431   *            @arg DCMI_IT_LINE: Line interrupt mask
432   * @retval None
433   */
434 #define __HAL_DCMI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
435 
436 /**
437   * @brief  Disable the specified DCMI interrupts.
438   * @param  __HANDLE__ DCMI handle
439   * @param  __INTERRUPT__ specifies the DCMI interrupt sources to be enabled.
440   *         This parameter can be any combination of the following values:
441   *            @arg DCMI_IT_FRAME: Frame capture complete interrupt mask
442   *            @arg DCMI_IT_OVF: Overflow interrupt mask
443   *            @arg DCMI_IT_ERR: Synchronization error interrupt mask
444   *            @arg DCMI_IT_VSYNC: VSYNC interrupt mask
445   *            @arg DCMI_IT_LINE: Line interrupt mask
446   * @retval None
447   */
448 #define __HAL_DCMI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= ~(__INTERRUPT__))
449 
450 /**
451   * @brief  Check whether the specified DCMI interrupt has occurred or not.
452   * @param  __HANDLE__ DCMI handle
453   * @param  __INTERRUPT__ specifies the DCMI interrupt source to check.
454   *         This parameter can be one of the following values:
455   *            @arg DCMI_IT_FRAME: Frame capture complete interrupt mask
456   *            @arg DCMI_IT_OVF: Overflow interrupt mask
457   *            @arg DCMI_IT_ERR: Synchronization error interrupt mask
458   *            @arg DCMI_IT_VSYNC: VSYNC interrupt mask
459   *            @arg DCMI_IT_LINE: Line interrupt mask
460   * @retval The state of INTERRUPT.
461   */
462 #define __HAL_DCMI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MISR & (__INTERRUPT__))
463 
464 /**
465   * @}
466   */
467 
468 /* Exported functions --------------------------------------------------------*/
469 /** @addtogroup DCMI_Exported_Functions DCMI Exported Functions
470   * @{
471   */
472 
473 /** @addtogroup DCMI_Exported_Functions_Group1 Initialization and Configuration functions
474   * @{
475   */
476 /* Initialization and de-initialization functions *****************************/
477 HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi);
478 HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi);
479 void       HAL_DCMI_MspInit(DCMI_HandleTypeDef *hdcmi);
480 void       HAL_DCMI_MspDeInit(DCMI_HandleTypeDef *hdcmi);
481 
482 /* Callbacks Register/UnRegister functions  ***********************************/
483 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
484 HAL_StatusTypeDef HAL_DCMI_RegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID,
485                                             pDCMI_CallbackTypeDef pCallback);
486 HAL_StatusTypeDef HAL_DCMI_UnRegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID);
487 #endif /* USE_HAL_DCMI_REGISTER_CALLBACKS */
488 /**
489   * @}
490   */
491 
492 /** @addtogroup DCMI_Exported_Functions_Group2 IO operation functions
493   * @{
494   */
495 /* IO operation functions *****************************************************/
496 HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef *hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length);
497 HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef *hdcmi);
498 HAL_StatusTypeDef HAL_DCMI_Suspend(DCMI_HandleTypeDef *hdcmi);
499 HAL_StatusTypeDef HAL_DCMI_Resume(DCMI_HandleTypeDef *hdcmi);
500 void       HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi);
501 void       HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi);
502 void       HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi);
503 void       HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi);
504 void       HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi);
505 /**
506   * @}
507   */
508 
509 /** @addtogroup DCMI_Exported_Functions_Group3 Peripheral Control functions
510   * @{
511   */
512 /* Peripheral Control functions ***********************************************/
513 HAL_StatusTypeDef     HAL_DCMI_ConfigCrop(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize,
514                                           uint32_t YSize);
515 HAL_StatusTypeDef     HAL_DCMI_EnableCrop(DCMI_HandleTypeDef *hdcmi);
516 HAL_StatusTypeDef     HAL_DCMI_DisableCrop(DCMI_HandleTypeDef *hdcmi);
517 HAL_StatusTypeDef     HAL_DCMI_ConfigSyncUnmask(DCMI_HandleTypeDef *hdcmi, const DCMI_SyncUnmaskTypeDef *SyncUnmask);
518 
519 /**
520   * @}
521   */
522 
523 /** @addtogroup DCMI_Exported_Functions_Group4 Peripheral State functions
524   * @{
525   */
526 /* Peripheral State functions *************************************************/
527 HAL_DCMI_StateTypeDef HAL_DCMI_GetState(const DCMI_HandleTypeDef *hdcmi);
528 uint32_t              HAL_DCMI_GetError(const DCMI_HandleTypeDef *hdcmi);
529 /**
530   * @}
531   */
532 
533 /**
534   * @}
535   */
536 
537 /* Private types -------------------------------------------------------------*/
538 /* Private variables ---------------------------------------------------------*/
539 /* Private constants ---------------------------------------------------------*/
540 /** @defgroup DCMI_Private_Constants DCMI Private Constants
541   * @{
542   */
543 /** @defgroup DCMI_MIS_INDEX DCMI Mis Index
544   * @{
545   */
546 #define DCMI_MIS_INDEX        ((uint32_t)0x1000) /*!< DCMI MIS register index */
547 
548 /**
549   * @}
550   */
551 
552 /** @defgroup DCMI_SR_INDEX  DCMI SR Index
553   * @{
554   */
555 #define DCMI_SR_INDEX         ((uint32_t)0x2000) /*!< DCMI SR register index  */
556 
557 /**
558   * @}
559   */
560 
561 /**
562   * @}
563   */
564 /* Private macro -------------------------------------------------------------*/
565 /** @defgroup DCMI_Private_Macros DCMI Private Macros
566   * @{
567   */
568 #define IS_DCMI_CAPTURE_MODE(MODE)(((MODE) == DCMI_MODE_CONTINUOUS) || \
569                                    ((MODE) == DCMI_MODE_SNAPSHOT))
570 
571 #define IS_DCMI_SYNCHRO(MODE)(((MODE) == DCMI_SYNCHRO_HARDWARE) || \
572                               ((MODE) == DCMI_SYNCHRO_EMBEDDED))
573 
574 #define IS_DCMI_PCKPOLARITY(POLARITY)(((POLARITY) == DCMI_PCKPOLARITY_FALLING) || \
575                                       ((POLARITY) == DCMI_PCKPOLARITY_RISING))
576 
577 #define IS_DCMI_VSPOLARITY(POLARITY)(((POLARITY) == DCMI_VSPOLARITY_LOW) || \
578                                      ((POLARITY) == DCMI_VSPOLARITY_HIGH))
579 
580 #define IS_DCMI_HSPOLARITY(POLARITY)(((POLARITY) == DCMI_HSPOLARITY_LOW) || \
581                                      ((POLARITY) == DCMI_HSPOLARITY_HIGH))
582 
583 #define IS_DCMI_MODE_JPEG(JPEG_MODE)(((JPEG_MODE) == DCMI_JPEG_DISABLE) || \
584                                      ((JPEG_MODE) == DCMI_JPEG_ENABLE))
585 
586 #define IS_DCMI_CAPTURE_RATE(RATE) (((RATE) == DCMI_CR_ALL_FRAME)         || \
587                                     ((RATE) == DCMI_CR_ALTERNATE_2_FRAME) || \
588                                     ((RATE) == DCMI_CR_ALTERNATE_4_FRAME))
589 
590 #define IS_DCMI_EXTENDED_DATA(DATA)(((DATA) == DCMI_EXTEND_DATA_8B)  || \
591                                     ((DATA) == DCMI_EXTEND_DATA_10B) || \
592                                     ((DATA) == DCMI_EXTEND_DATA_12B) || \
593                                     ((DATA) == DCMI_EXTEND_DATA_14B))
594 
595 #define IS_DCMI_WINDOW_COORDINATE(COORDINATE) ((COORDINATE) <= DCMI_WINDOW_COORDINATE)
596 
597 #define IS_DCMI_WINDOW_HEIGHT(HEIGHT) ((HEIGHT) <= DCMI_WINDOW_HEIGHT)
598 
599 /**
600   * @}
601   */
602 
603 /* Private functions ---------------------------------------------------------*/
604 /** @addtogroup DCMI_Private_Functions DCMI Private Functions
605   * @{
606   */
607 
608 /**
609   * @}
610   */
611 
612 /**
613   * @}
614   */
615 /**
616   * @}
617   */
618 #endif /* DCMI */
619 
620 #ifdef __cplusplus
621 }
622 #endif
623 
624 #endif /* STM32F2xx_HAL_DCMI_H */
625