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