ARMEBS4  revision-26.06.2015
stm32f4xx_dcmi.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file stm32f4xx_dcmi.h
4  * @author MCD Application Team
5  * @version V1.0.0
6  * @date 30-September-2011
7  * @brief This file contains all the functions prototypes for the DCMI firmware library.
8  ******************************************************************************
9  * @attention
10  *
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.
17  *
18  * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19  ******************************************************************************
20  */
21 
22 /* Define to prevent recursive inclusion -------------------------------------*/
23 #ifndef __STM32F4xx_DCMI_H
24 #define __STM32F4xx_DCMI_H
25 
26 #ifdef __cplusplus
27  extern "C" {
28 #endif
29 
30 /* Includes ------------------------------------------------------------------*/
31 #include "stm32/stm32f4xx.h"
32 
33 /** @addtogroup STM32F4xx_StdPeriph_Driver
34  * @{
35  */
36 
37 /** @addtogroup DCMI
38  * @{
39  */
40 
41 /* Exported types ------------------------------------------------------------*/
42 /**
43  * @brief DCMI Init structure definition
44  */
45 typedef struct
46 {
47  uint16_t DCMI_CaptureMode; /*!< Specifies the Capture Mode: Continuous or Snapshot.
48  This parameter can be a value of @ref DCMI_Capture_Mode */
49 
50  uint16_t DCMI_SynchroMode; /*!< Specifies the Synchronization Mode: Hardware or Embedded.
51  This parameter can be a value of @ref DCMI_Synchronization_Mode */
52 
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 */
55 
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 */
58 
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 */
61 
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 */
64 
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 */
68 
69 /**
70  * @brief DCMI CROP Init structure definition
71  */
72 typedef struct
73 {
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 */
76 
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 */
79 
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 */
82 
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 */
87 
88 /**
89  * @brief DCMI Embedded Synchronisation CODE Init structure definition
90  */
91 typedef struct
92 {
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. */
98 
99 /* Exported constants --------------------------------------------------------*/
100 
101 /** @defgroup DCMI_Exported_Constants
102  * @{
103  */
104 
105 /** @defgroup DCMI_Capture_Mode
106  * @{
107  */
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))
114 /**
115  * @}
116  */
117 
118 
119 /** @defgroup DCMI_Synchronization_Mode
120  * @{
121  */
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))
128 /**
129  * @}
130  */
131 
132 
133 /** @defgroup DCMI_PIXCK_Polarity
134  * @{
135  */
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))
140 /**
141  * @}
142  */
143 
144 
145 /** @defgroup DCMI_VSYNC_Polarity
146  * @{
147  */
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))
152 /**
153  * @}
154  */
155 
156 
157 /** @defgroup DCMI_HSYNC_Polarity
158  * @{
159  */
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))
164 /**
165  * @}
166  */
167 
168 
169 /** @defgroup DCMI_Capture_Rate
170  * @{
171  */
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))
178 /**
179  * @}
180  */
181 
182 
183 /** @defgroup DCMI_Extended_Data_Mode
184  * @{
185  */
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))
194 /**
195  * @}
196  */
197 
198 
199 /** @defgroup DCMI_interrupt_sources
200  * @{
201  */
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))
213 /**
214  * @}
215  */
216 
217 
218 /** @defgroup DCMI_Flags
219  * @{
220  */
221 /**
222  * @brief DCMI SR register
223  */
224 #define DCMI_FLAG_HSYNC ((uint16_t)0x2001)
225 #define DCMI_FLAG_VSYNC ((uint16_t)0x2002)
226 #define DCMI_FLAG_FNE ((uint16_t)0x2004)
227 /**
228  * @brief DCMI RISR register
229  */
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)
235 /**
236  * @brief DCMI MISR register
237  */
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))
256 
257 #define IS_DCMI_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFE0) == 0x0000) && ((FLAG) != 0x0000))
258 /**
259  * @}
260  */
261 
262 /**
263  * @}
264  */
265 
266 /* Exported macro ------------------------------------------------------------*/
267 /* Exported functions --------------------------------------------------------*/
268 
269 /* Function used to set the DCMI configuration to the default reset state ****/
270 void DCMI_DeInit(void);
271 
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);
279 
280 /* Image capture functions ****************************************************/
281 void DCMI_Cmd(FunctionalState NewState);
282 void DCMI_CaptureCmd(FunctionalState NewState);
283 uint32_t DCMI_ReadData(void);
284 
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);
291 
292 #ifdef __cplusplus
293 }
294 #endif
295 
296 #endif /*__STM32F4xx_DCMI_H */
297 
298 /**
299  * @}
300  */
301 
302 /**
303  * @}
304  */
305 
306 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
DCMI Init structure definition.
uint16_t DCMI_PCKPolarity
uint16_t DCMI_HSPolarity
DCMI CROP Init structure definition.
uint16_t DCMI_SynchroMode
uint16_t DCMI_CaptureRate
uint16_t DCMI_ExtendedDataMode
CMSIS Cortex-M4 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
uint16_t DCMI_HorizontalOffsetCount
DCMI Embedded Synchronisation CODE Init structure definition.
uint16_t DCMI_VerticalStartLine
uint16_t DCMI_VerticalLineCount
uint16_t DCMI_VSPolarity
uint16_t DCMI_CaptureMode