2 ******************************************************************************
3 * @file stm32f4xx_dcmi.h
4 * @author MCD Application Team
7 * @brief This file contains all the functions prototypes for the DCMI firmware library.
8 ******************************************************************************
11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
18 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
22 /* Define to prevent recursive inclusion -------------------------------------*/
23 #ifndef __STM32F4xx_DCMI_H
24 #define __STM32F4xx_DCMI_H
30 /* Includes ------------------------------------------------------------------*/
31 #include "stm32f4xx.h"
33 /** @addtogroup STM32F4xx_StdPeriph_Driver
41 /* Exported types ------------------------------------------------------------*/
43 * @brief DCMI Init structure definition
47 uint16_t DCMI_CaptureMode; /*!< Specifies the Capture Mode: Continuous or Snapshot.
48 This parameter can be a value of @ref DCMI_Capture_Mode */
50 uint16_t DCMI_SynchroMode; /*!< Specifies the Synchronization Mode: Hardware or Embedded.
51 This parameter can be a value of @ref DCMI_Synchronization_Mode */
53 uint16_t DCMI_PCKPolarity; /*!< Specifies the Pixel clock polarity: Falling or Rising.
54 This parameter can be a value of @ref DCMI_PIXCK_Polarity */
56 uint16_t DCMI_VSPolarity; /*!< Specifies the Vertical synchronization polarity: High or Low.
57 This parameter can be a value of @ref DCMI_VSYNC_Polarity */
59 uint16_t DCMI_HSPolarity; /*!< Specifies the Horizontal synchronization polarity: High or Low.
60 This parameter can be a value of @ref DCMI_HSYNC_Polarity */
62 uint16_t DCMI_CaptureRate; /*!< Specifies the frequency of frame capture: All, 1/2 or 1/4.
63 This parameter can be a value of @ref DCMI_Capture_Rate */
65 uint16_t DCMI_ExtendedDataMode; /*!< Specifies the data width: 8-bit, 10-bit, 12-bit or 14-bit.
66 This parameter can be a value of @ref DCMI_Extended_Data_Mode */
70 * @brief DCMI CROP Init structure definition
74 uint16_t DCMI_VerticalStartLine; /*!< Specifies the Vertical start line count from which the image capture
75 will start. This parameter can be a value between 0x00 and 0x1FFF */
77 uint16_t DCMI_HorizontalOffsetCount; /*!< Specifies the number of pixel clocks to count before starting a capture.
78 This parameter can be a value between 0x00 and 0x3FFF */
80 uint16_t DCMI_VerticalLineCount; /*!< Specifies the number of lines to be captured from the starting point.
81 This parameter can be a value between 0x00 and 0x3FFF */
83 uint16_t DCMI_CaptureCount; /*!< Specifies the number of pixel clocks to be captured from the starting
84 point on the same line.
85 This parameter can be a value between 0x00 and 0x3FFF */
86 } DCMI_CROPInitTypeDef;
89 * @brief DCMI Embedded Synchronisation CODE Init structure definition
93 uint8_t DCMI_FrameStartCode; /*!< Specifies the code of the frame start delimiter. */
94 uint8_t DCMI_LineStartCode; /*!< Specifies the code of the line start delimiter. */
95 uint8_t DCMI_LineEndCode; /*!< Specifies the code of the line end delimiter. */
96 uint8_t DCMI_FrameEndCode; /*!< Specifies the code of the frame end delimiter. */
97 } DCMI_CodesInitTypeDef;
99 /* Exported constants --------------------------------------------------------*/
101 /** @defgroup DCMI_Exported_Constants
105 /** @defgroup DCMI_Capture_Mode
108 #define DCMI_CaptureMode_Continuous ((uint16_t)0x0000) /*!< The received data are transferred continuously
109 into the destination memory through the DMA */
110 #define DCMI_CaptureMode_SnapShot ((uint16_t)0x0002) /*!< Once activated, the interface waits for the start of
111 frame and then transfers a single frame through the DMA */
112 #define IS_DCMI_CAPTURE_MODE(MODE)(((MODE) == DCMI_CaptureMode_Continuous) || \
113 ((MODE) == DCMI_CaptureMode_SnapShot))
119 /** @defgroup DCMI_Synchronization_Mode
122 #define DCMI_SynchroMode_Hardware ((uint16_t)0x0000) /*!< Hardware synchronization data capture (frame/line start/stop)
123 is synchronized with the HSYNC/VSYNC signals */
124 #define DCMI_SynchroMode_Embedded ((uint16_t)0x0010) /*!< Embedded synchronization data capture is synchronized with
125 synchronization codes embedded in the data flow */
126 #define IS_DCMI_SYNCHRO(MODE)(((MODE) == DCMI_SynchroMode_Hardware) || \
127 ((MODE) == DCMI_SynchroMode_Embedded))
133 /** @defgroup DCMI_PIXCK_Polarity
136 #define DCMI_PCKPolarity_Falling ((uint16_t)0x0000) /*!< Pixel clock active on Falling edge */
137 #define DCMI_PCKPolarity_Rising ((uint16_t)0x0020) /*!< Pixel clock active on Rising edge */
138 #define IS_DCMI_PCKPOLARITY(POLARITY)(((POLARITY) == DCMI_PCKPolarity_Falling) || \
139 ((POLARITY) == DCMI_PCKPolarity_Rising))
145 /** @defgroup DCMI_VSYNC_Polarity
148 #define DCMI_VSPolarity_Low ((uint16_t)0x0000) /*!< Vertical synchronization active Low */
149 #define DCMI_VSPolarity_High ((uint16_t)0x0080) /*!< Vertical synchronization active High */
150 #define IS_DCMI_VSPOLARITY(POLARITY)(((POLARITY) == DCMI_VSPolarity_Low) || \
151 ((POLARITY) == DCMI_VSPolarity_High))
157 /** @defgroup DCMI_HSYNC_Polarity
160 #define DCMI_HSPolarity_Low ((uint16_t)0x0000) /*!< Horizontal synchronization active Low */
161 #define DCMI_HSPolarity_High ((uint16_t)0x0040) /*!< Horizontal synchronization active High */
162 #define IS_DCMI_HSPOLARITY(POLARITY)(((POLARITY) == DCMI_HSPolarity_Low) || \
163 ((POLARITY) == DCMI_HSPolarity_High))
169 /** @defgroup DCMI_Capture_Rate
172 #define DCMI_CaptureRate_All_Frame ((uint16_t)0x0000) /*!< All frames are captured */
173 #define DCMI_CaptureRate_1of2_Frame ((uint16_t)0x0100) /*!< Every alternate frame captured */
174 #define DCMI_CaptureRate_1of4_Frame ((uint16_t)0x0200) /*!< One frame in 4 frames captured */
175 #define IS_DCMI_CAPTURE_RATE(RATE) (((RATE) == DCMI_CaptureRate_All_Frame) || \
176 ((RATE) == DCMI_CaptureRate_1of2_Frame) ||\
177 ((RATE) == DCMI_CaptureRate_1of4_Frame))
183 /** @defgroup DCMI_Extended_Data_Mode
186 #define DCMI_ExtendedDataMode_8b ((uint16_t)0x0000) /*!< Interface captures 8-bit data on every pixel clock */
187 #define DCMI_ExtendedDataMode_10b ((uint16_t)0x0400) /*!< Interface captures 10-bit data on every pixel clock */
188 #define DCMI_ExtendedDataMode_12b ((uint16_t)0x0800) /*!< Interface captures 12-bit data on every pixel clock */
189 #define DCMI_ExtendedDataMode_14b ((uint16_t)0x0C00) /*!< Interface captures 14-bit data on every pixel clock */
190 #define IS_DCMI_EXTENDED_DATA(DATA)(((DATA) == DCMI_ExtendedDataMode_8b) || \
191 ((DATA) == DCMI_ExtendedDataMode_10b) ||\
192 ((DATA) == DCMI_ExtendedDataMode_12b) ||\
193 ((DATA) == DCMI_ExtendedDataMode_14b))
199 /** @defgroup DCMI_interrupt_sources
202 #define DCMI_IT_FRAME ((uint16_t)0x0001)
203 #define DCMI_IT_OVF ((uint16_t)0x0002)
204 #define DCMI_IT_ERR ((uint16_t)0x0004)
205 #define DCMI_IT_VSYNC ((uint16_t)0x0008)
206 #define DCMI_IT_LINE ((uint16_t)0x0010)
207 #define IS_DCMI_CONFIG_IT(IT) ((((IT) & (uint16_t)0xFFE0) == 0x0000) && ((IT) != 0x0000))
208 #define IS_DCMI_GET_IT(IT) (((IT) == DCMI_IT_FRAME) || \
209 ((IT) == DCMI_IT_OVF) || \
210 ((IT) == DCMI_IT_ERR) || \
211 ((IT) == DCMI_IT_VSYNC) || \
212 ((IT) == DCMI_IT_LINE))
218 /** @defgroup DCMI_Flags
222 * @brief DCMI SR register
224 #define DCMI_FLAG_HSYNC ((uint16_t)0x2001)
225 #define DCMI_FLAG_VSYNC ((uint16_t)0x2002)
226 #define DCMI_FLAG_FNE ((uint16_t)0x2004)
228 * @brief DCMI RISR register
230 #define DCMI_FLAG_FRAMERI ((uint16_t)0x0001)
231 #define DCMI_FLAG_OVFRI ((uint16_t)0x0002)
232 #define DCMI_FLAG_ERRRI ((uint16_t)0x0004)
233 #define DCMI_FLAG_VSYNCRI ((uint16_t)0x0008)
234 #define DCMI_FLAG_LINERI ((uint16_t)0x0010)
236 * @brief DCMI MISR register
238 #define DCMI_FLAG_FRAMEMI ((uint16_t)0x1001)
239 #define DCMI_FLAG_OVFMI ((uint16_t)0x1002)
240 #define DCMI_FLAG_ERRMI ((uint16_t)0x1004)
241 #define DCMI_FLAG_VSYNCMI ((uint16_t)0x1008)
242 #define DCMI_FLAG_LINEMI ((uint16_t)0x1010)
243 #define IS_DCMI_GET_FLAG(FLAG) (((FLAG) == DCMI_FLAG_HSYNC) || \
244 ((FLAG) == DCMI_FLAG_VSYNC) || \
245 ((FLAG) == DCMI_FLAG_FNE) || \
246 ((FLAG) == DCMI_FLAG_FRAMERI) || \
247 ((FLAG) == DCMI_FLAG_OVFRI) || \
248 ((FLAG) == DCMI_FLAG_ERRRI) || \
249 ((FLAG) == DCMI_FLAG_VSYNCRI) || \
250 ((FLAG) == DCMI_FLAG_LINERI) || \
251 ((FLAG) == DCMI_FLAG_FRAMEMI) || \
252 ((FLAG) == DCMI_FLAG_OVFMI) || \
253 ((FLAG) == DCMI_FLAG_ERRMI) || \
254 ((FLAG) == DCMI_FLAG_VSYNCMI) || \
255 ((FLAG) == DCMI_FLAG_LINEMI))
257 #define IS_DCMI_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFE0) == 0x0000) && ((FLAG) != 0x0000))
266 /* Exported macro ------------------------------------------------------------*/
267 /* Exported functions --------------------------------------------------------*/
269 /* Function used to set the DCMI configuration to the default reset state ****/
270 void DCMI_DeInit(void);
272 /* Initialization and Configuration functions *********************************/
273 void DCMI_Init(DCMI_InitTypeDef* DCMI_InitStruct);
274 void DCMI_StructInit(DCMI_InitTypeDef* DCMI_InitStruct);
275 void DCMI_CROPConfig(DCMI_CROPInitTypeDef* DCMI_CROPInitStruct);
276 void DCMI_CROPCmd(FunctionalState NewState);
277 void DCMI_SetEmbeddedSynchroCodes(DCMI_CodesInitTypeDef* DCMI_CodesInitStruct);
278 void DCMI_JPEGCmd(FunctionalState NewState);
280 /* Image capture functions ****************************************************/
281 void DCMI_Cmd(FunctionalState NewState);
282 void DCMI_CaptureCmd(FunctionalState NewState);
283 uint32_t DCMI_ReadData(void);
285 /* Interrupts and flags management functions **********************************/
286 void DCMI_ITConfig(uint16_t DCMI_IT, FunctionalState NewState);
287 FlagStatus DCMI_GetFlagStatus(uint16_t DCMI_FLAG);
288 void DCMI_ClearFlag(uint16_t DCMI_FLAG);
289 ITStatus DCMI_GetITStatus(uint16_t DCMI_IT);
290 void DCMI_ClearITPendingBit(uint16_t DCMI_IT);
296 #endif /*__STM32F4xx_DCMI_H */
306 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/