source: asp3_wo_tecs/trunk/arch/arm_m_gcc/stm32f4xx_stm32cube/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dcmi.h@ 303

Last change on this file since 303 was 303, checked in by ertl-honda, 7 years ago

nucleo_f401re依存部の追加

File size: 18.9 KB
Line 
1/**
2 ******************************************************************************
3 * @file stm32f4xx_hal_dcmi.h
4 * @author MCD Application Team
5 * @version V1.4.1
6 * @date 09-October-2015
7 * @brief Header file of DCMI HAL module.
8 ******************************************************************************
9 * @attention
10 *
11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
12 *
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 ******************************************************************************
36 */
37
38/* Define to prevent recursive inclusion -------------------------------------*/
39#ifndef __STM32F4xx_HAL_DCMI_H
40#define __STM32F4xx_HAL_DCMI_H
41
42#ifdef __cplusplus
43 extern "C" {
44#endif
45
46#if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) ||\
47 defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) ||\
48 defined(STM32F479xx)
49/* Includes ------------------------------------------------------------------*/
50#include "stm32f4xx_hal_def.h"
51
52/* Include DCMI HAL Extended module */
53/* (include on top of file since DCMI structures are defined in extended file) */
54#include "stm32f4xx_hal_dcmi_ex.h"
55
56/** @addtogroup STM32F4xx_HAL_Driver
57 * @{
58 */
59
60/** @addtogroup DCMI DCMI
61 * @brief DCMI HAL module driver
62 * @{
63 */
64
65/* Exported types ------------------------------------------------------------*/
66/** @defgroup DCMI_Exported_Types DCMI Exported Types
67 * @{
68 */
69/**
70 * @brief DCMI Error source
71 */
72typedef enum
73{
74 DCMI_ERROR_SYNC = 1, /*!< Synchronisation error */
75 DCMI_OVERRUN = 2, /*!< DCMI Overrun */
76}DCMI_ErrorTypeDef;
77
78
79/**
80 * @brief HAL DCMI State structures definition
81 */
82typedef enum
83{
84 HAL_DCMI_STATE_RESET = 0x00, /*!< DCMI not yet initialized or disabled */
85 HAL_DCMI_STATE_READY = 0x01, /*!< DCMI initialized and ready for use */
86 HAL_DCMI_STATE_BUSY = 0x02, /*!< DCMI internal processing is ongoing */
87 HAL_DCMI_STATE_TIMEOUT = 0x03, /*!< DCMI timeout state */
88 HAL_DCMI_STATE_ERROR = 0x04 /*!< DCMI error state */
89}HAL_DCMI_StateTypeDef;
90
91/**
92 * @brief DCMI handle Structure definition
93 */
94typedef struct
95{
96 DCMI_TypeDef *Instance; /*!< DCMI Register base address */
97
98 DCMI_InitTypeDef Init; /*!< DCMI parameters */
99
100 HAL_LockTypeDef Lock; /*!< DCMI locking object */
101
102 __IO HAL_DCMI_StateTypeDef State; /*!< DCMI state */
103
104 __IO uint32_t XferCount; /*!< DMA transfer counter */
105
106 __IO uint32_t XferSize; /*!< DMA transfer size */
107
108 uint32_t XferTransferNumber; /*!< DMA transfer number */
109
110 uint32_t pBuffPtr; /*!< Pointer to DMA output buffer */
111
112 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer to the DMA handler */
113
114 __IO uint32_t ErrorCode; /*!< DCMI Error code */
115
116}DCMI_HandleTypeDef;
117/**
118 * @}
119 */
120
121/* Exported constants --------------------------------------------------------*/
122/** @defgroup DCMI_Exported_Constants DCMI Exported Constants
123 * @{
124 */
125
126/** @defgroup DCMI_Error_Code DCMI Error Code
127 * @{
128 */
129#define HAL_DCMI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
130#define HAL_DCMI_ERROR_OVF ((uint32_t)0x00000001) /*!< Overflow error */
131#define HAL_DCMI_ERROR_SYNC ((uint32_t)0x00000002) /*!< Synchronization error */
132#define HAL_DCMI_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */
133/**
134 * @}
135 */
136
137/** @defgroup DCMI_Capture_Mode DCMI Capture Mode
138 * @{
139 */
140#define DCMI_MODE_CONTINUOUS ((uint32_t)0x00000000) /*!< The received data are transferred continuously
141 into the destination memory through the DMA */
142#define DCMI_MODE_SNAPSHOT ((uint32_t)DCMI_CR_CM) /*!< Once activated, the interface waits for the start of
143 frame and then transfers a single frame through the DMA */
144/**
145 * @}
146 */
147
148/** @defgroup DCMI_Synchronization_Mode DCMI Synchronization Mode
149 * @{
150 */
151#define DCMI_SYNCHRO_HARDWARE ((uint32_t)0x00000000) /*!< Hardware synchronization data capture (frame/line start/stop)
152 is synchronized with the HSYNC/VSYNC signals */
153#define DCMI_SYNCHRO_EMBEDDED ((uint32_t)DCMI_CR_ESS) /*!< Embedded synchronization data capture is synchronized with
154 synchronization codes embedded in the data flow */
155
156/**
157 * @}
158 */
159
160/** @defgroup DCMI_PIXCK_Polarity DCMI PIXCK Polarity
161 * @{
162 */
163#define DCMI_PCKPOLARITY_FALLING ((uint32_t)0x00000000) /*!< Pixel clock active on Falling edge */
164#define DCMI_PCKPOLARITY_RISING ((uint32_t)DCMI_CR_PCKPOL) /*!< Pixel clock active on Rising edge */
165
166/**
167 * @}
168 */
169
170/** @defgroup DCMI_VSYNC_Polarity DCMI VSYNC Polarity
171 * @{
172 */
173#define DCMI_VSPOLARITY_LOW ((uint32_t)0x00000000) /*!< Vertical synchronization active Low */
174#define DCMI_VSPOLARITY_HIGH ((uint32_t)DCMI_CR_VSPOL) /*!< Vertical synchronization active High */
175
176/**
177 * @}
178 */
179
180/** @defgroup DCMI_HSYNC_Polarity DCMI HSYNC Polarity
181 * @{
182 */
183#define DCMI_HSPOLARITY_LOW ((uint32_t)0x00000000) /*!< Horizontal synchronization active Low */
184#define DCMI_HSPOLARITY_HIGH ((uint32_t)DCMI_CR_HSPOL) /*!< Horizontal synchronization active High */
185
186/**
187 * @}
188 */
189
190/** @defgroup DCMI_MODE_JPEG DCMI MODE JPEG
191 * @{
192 */
193#define DCMI_JPEG_DISABLE ((uint32_t)0x00000000) /*!< Mode JPEG Disabled */
194#define DCMI_JPEG_ENABLE ((uint32_t)DCMI_CR_JPEG) /*!< Mode JPEG Enabled */
195
196/**
197 * @}
198 */
199
200/** @defgroup DCMI_Capture_Rate DCMI Capture Rate
201 * @{
202 */
203#define DCMI_CR_ALL_FRAME ((uint32_t)0x00000000) /*!< All frames are captured */
204#define DCMI_CR_ALTERNATE_2_FRAME ((uint32_t)DCMI_CR_FCRC_0) /*!< Every alternate frame captured */
205#define DCMI_CR_ALTERNATE_4_FRAME ((uint32_t)DCMI_CR_FCRC_1) /*!< One frame in 4 frames captured */
206
207/**
208 * @}
209 */
210
211/** @defgroup DCMI_Extended_Data_Mode DCMI Extended Data Mode
212 * @{
213 */
214#define DCMI_EXTEND_DATA_8B ((uint32_t)0x00000000) /*!< Interface captures 8-bit data on every pixel clock */
215#define DCMI_EXTEND_DATA_10B ((uint32_t)DCMI_CR_EDM_0) /*!< Interface captures 10-bit data on every pixel clock */
216#define DCMI_EXTEND_DATA_12B ((uint32_t)DCMI_CR_EDM_1) /*!< Interface captures 12-bit data on every pixel clock */
217#define DCMI_EXTEND_DATA_14B ((uint32_t)(DCMI_CR_EDM_0 | DCMI_CR_EDM_1)) /*!< Interface captures 14-bit data on every pixel clock */
218
219/**
220 * @}
221 */
222
223/** @defgroup DCMI_Window_Coordinate DCMI Window Coordinate
224 * @{
225 */
226#define DCMI_WINDOW_COORDINATE ((uint32_t)0x3FFF) /*!< Window coordinate */
227
228/**
229 * @}
230 */
231
232/** @defgroup DCMI_Window_Height DCMI Window Height
233 * @{
234 */
235#define DCMI_WINDOW_HEIGHT ((uint32_t)0x1FFF) /*!< Window Height */
236
237/**
238 * @}
239 */
240
241/** @defgroup DCMI_interrupt_sources DCMI interrupt sources
242 * @{
243 */
244#define DCMI_IT_FRAME ((uint32_t)DCMI_IER_FRAME_IE)
245#define DCMI_IT_OVF ((uint32_t)DCMI_IER_OVF_IE)
246#define DCMI_IT_ERR ((uint32_t)DCMI_IER_ERR_IE)
247#define DCMI_IT_VSYNC ((uint32_t)DCMI_IER_VSYNC_IE)
248#define DCMI_IT_LINE ((uint32_t)DCMI_IER_LINE_IE)
249/**
250 * @}
251 */
252
253/** @defgroup DCMI_Flags DCMI Flags
254 * @{
255 */
256
257/**
258 * @brief DCMI SR register
259 */
260#define DCMI_FLAG_HSYNC ((uint32_t)0x2001)
261#define DCMI_FLAG_VSYNC ((uint32_t)0x2002)
262#define DCMI_FLAG_FNE ((uint32_t)0x2004)
263/**
264 * @brief DCMI RISR register
265 */
266#define DCMI_FLAG_FRAMERI ((uint32_t)DCMI_RISR_FRAME_RIS)
267#define DCMI_FLAG_OVFRI ((uint32_t)DCMI_RISR_OVF_RIS)
268#define DCMI_FLAG_ERRRI ((uint32_t)DCMI_RISR_ERR_RIS)
269#define DCMI_FLAG_VSYNCRI ((uint32_t)DCMI_RISR_VSYNC_RIS)
270#define DCMI_FLAG_LINERI ((uint32_t)DCMI_RISR_LINE_RIS)
271/**
272 * @brief DCMI MISR register
273 */
274#define DCMI_FLAG_FRAMEMI ((uint32_t)0x1001)
275#define DCMI_FLAG_OVFMI ((uint32_t)0x1002)
276#define DCMI_FLAG_ERRMI ((uint32_t)0x1004)
277#define DCMI_FLAG_VSYNCMI ((uint32_t)0x1008)
278#define DCMI_FLAG_LINEMI ((uint32_t)0x1010)
279/**
280 * @}
281 */
282
283/**
284 * @}
285 */
286
287/* Exported macro ------------------------------------------------------------*/
288/** @defgroup DCMI_Exported_Macros DCMI Exported Macros
289 * @{
290 */
291
292/** @brief Reset DCMI handle state
293 * @param __HANDLE__: specifies the DCMI handle.
294 * @retval None
295 */
296#define __HAL_DCMI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DCMI_STATE_RESET)
297
298/**
299 * @brief Enable the DCMI.
300 * @param __HANDLE__: DCMI handle
301 * @retval None
302 */
303#define __HAL_DCMI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DCMI_CR_ENABLE)
304
305/**
306 * @brief Disable the DCMI.
307 * @param __HANDLE__: DCMI handle
308 * @retval None
309 */
310#define __HAL_DCMI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(DCMI_CR_ENABLE))
311
312/* Interrupt & Flag management */
313/**
314 * @brief Get the DCMI pending flags.
315 * @param __HANDLE__: DCMI handle
316 * @param __FLAG__: Get the specified flag.
317 * This parameter can be any combination of the following values:
318 * @arg DCMI_FLAG_FRAMERI: Frame capture complete flag mask
319 * @arg DCMI_FLAG_OVFRI: Overflow flag mask
320 * @arg DCMI_FLAG_ERRRI: Synchronization error flag mask
321 * @arg DCMI_FLAG_VSYNCRI: VSYNC flag mask
322 * @arg DCMI_FLAG_LINERI: Line flag mask
323 * @retval The state of FLAG.
324 */
325#define __HAL_DCMI_GET_FLAG(__HANDLE__, __FLAG__)\
326((((__FLAG__) & 0x3000) == 0x0)? ((__HANDLE__)->Instance->RISR & (__FLAG__)) :\
327 (((__FLAG__) & 0x2000) == 0x0)? ((__HANDLE__)->Instance->MISR & (__FLAG__)) : ((__HANDLE__)->Instance->SR & (__FLAG__)))
328
329/**
330 * @brief Clear the DCMI pending flags.
331 * @param __HANDLE__: DCMI handle
332 * @param __FLAG__: specifies the flag to clear.
333 * This parameter can be any combination of the following values:
334 * @arg DCMI_FLAG_FRAMERI: Frame capture complete flag mask
335 * @arg DCMI_FLAG_OVFRI: Overflow flag mask
336 * @arg DCMI_FLAG_ERRRI: Synchronization error flag mask
337 * @arg DCMI_FLAG_VSYNCRI: VSYNC flag mask
338 * @arg DCMI_FLAG_LINERI: Line flag mask
339 * @retval None
340 */
341#define __HAL_DCMI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
342
343/**
344 * @brief Enable the specified DCMI interrupts.
345 * @param __HANDLE__: DCMI handle
346 * @param __INTERRUPT__: specifies the DCMI interrupt sources to be enabled.
347 * This parameter can be any combination of the following values:
348 * @arg DCMI_IT_FRAME: Frame capture complete interrupt mask
349 * @arg DCMI_IT_OVF: Overflow interrupt mask
350 * @arg DCMI_IT_ERR: Synchronization error interrupt mask
351 * @arg DCMI_IT_VSYNC: VSYNC interrupt mask
352 * @arg DCMI_IT_LINE: Line interrupt mask
353 * @retval None
354 */
355#define __HAL_DCMI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
356
357/**
358 * @brief Disable the specified DCMI interrupts.
359 * @param __HANDLE__: DCMI handle
360 * @param __INTERRUPT__: specifies the DCMI interrupt sources to be enabled.
361 * This parameter can be any combination of the following values:
362 * @arg DCMI_IT_FRAME: Frame capture complete interrupt mask
363 * @arg DCMI_IT_OVF: Overflow interrupt mask
364 * @arg DCMI_IT_ERR: Synchronization error interrupt mask
365 * @arg DCMI_IT_VSYNC: VSYNC interrupt mask
366 * @arg DCMI_IT_LINE: Line interrupt mask
367 * @retval None
368 */
369#define __HAL_DCMI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= ~(__INTERRUPT__))
370
371/**
372 * @brief Check whether the specified DCMI interrupt has occurred or not.
373 * @param __HANDLE__: DCMI handle
374 * @param __INTERRUPT__: specifies the DCMI interrupt source to check.
375 * This parameter can be one of the following values:
376 * @arg DCMI_IT_FRAME: Frame capture complete interrupt mask
377 * @arg DCMI_IT_OVF: Overflow interrupt mask
378 * @arg DCMI_IT_ERR: Synchronization error interrupt mask
379 * @arg DCMI_IT_VSYNC: VSYNC interrupt mask
380 * @arg DCMI_IT_LINE: Line interrupt mask
381 * @retval The state of INTERRUPT.
382 */
383#define __HAL_DCMI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MISR & (__INTERRUPT__))
384
385/**
386 * @}
387 */
388
389/* Exported functions --------------------------------------------------------*/
390/** @addtogroup DCMI_Exported_Functions
391 * @{
392 */
393
394/** @addtogroup DCMI_Exported_Functions_Group1
395 * @{
396 */
397
398/* Initialization and de-initialization functions *****************************/
399HAL_StatusTypeDef HAL_DCMI_Init(DCMI_HandleTypeDef *hdcmi);
400HAL_StatusTypeDef HAL_DCMI_DeInit(DCMI_HandleTypeDef *hdcmi);
401void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi);
402void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi);
403/**
404 * @}
405 */
406
407/** @addtogroup DCMI_Exported_Functions_Group2
408 * @{
409 */
410
411/* IO operation functions *****************************************************/
412HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length);
413HAL_StatusTypeDef HAL_DCMI_Stop(DCMI_HandleTypeDef* hdcmi);
414void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi);
415void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi);
416void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi);
417void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi);
418void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi);
419/**
420 * @}
421 */
422
423/** @addtogroup DCMI_Exported_Functions_Group3
424 * @{
425 */
426/* Peripheral Control functions ***********************************************/
427HAL_StatusTypeDef HAL_DCMI_ConfigCROP(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize);
428HAL_StatusTypeDef HAL_DCMI_EnableCROP(DCMI_HandleTypeDef *hdcmi);
429HAL_StatusTypeDef HAL_DCMI_DisableCROP(DCMI_HandleTypeDef *hdcmi);
430/**
431 * @}
432 */
433
434/** @addtogroup DCMI_Exported_Functions_Group4
435 * @{
436 */
437/* Peripheral State functions *************************************************/
438HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi);
439uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi);
440/**
441 * @}
442 */
443
444/**
445 * @}
446 */
447
448/* Private types -------------------------------------------------------------*/
449/* Private variables ---------------------------------------------------------*/
450/* Private constants ---------------------------------------------------------*/
451/* Private macro -------------------------------------------------------------*/
452/** @defgroup DCMI_Private_Macros DCMI Private Macros
453 * @{
454 */
455#define IS_DCMI_CAPTURE_MODE(MODE)(((MODE) == DCMI_MODE_CONTINUOUS) || \
456 ((MODE) == DCMI_MODE_SNAPSHOT))
457
458#define IS_DCMI_SYNCHRO(MODE)(((MODE) == DCMI_SYNCHRO_HARDWARE) || \
459 ((MODE) == DCMI_SYNCHRO_EMBEDDED))
460
461#define IS_DCMI_PCKPOLARITY(POLARITY)(((POLARITY) == DCMI_PCKPOLARITY_FALLING) || \
462 ((POLARITY) == DCMI_PCKPOLARITY_RISING))
463
464#define IS_DCMI_VSPOLARITY(POLARITY)(((POLARITY) == DCMI_VSPOLARITY_LOW) || \
465 ((POLARITY) == DCMI_VSPOLARITY_HIGH))
466
467#define IS_DCMI_HSPOLARITY(POLARITY)(((POLARITY) == DCMI_HSPOLARITY_LOW) || \
468 ((POLARITY) == DCMI_HSPOLARITY_HIGH))
469
470#define IS_DCMI_MODE_JPEG(JPEG_MODE)(((JPEG_MODE) == DCMI_JPEG_DISABLE) || \
471 ((JPEG_MODE) == DCMI_JPEG_ENABLE))
472
473#define IS_DCMI_CAPTURE_RATE(RATE) (((RATE) == DCMI_CR_ALL_FRAME) || \
474 ((RATE) == DCMI_CR_ALTERNATE_2_FRAME) || \
475 ((RATE) == DCMI_CR_ALTERNATE_4_FRAME))
476
477#define IS_DCMI_EXTENDED_DATA(DATA)(((DATA) == DCMI_EXTEND_DATA_8B) || \
478 ((DATA) == DCMI_EXTEND_DATA_10B) || \
479 ((DATA) == DCMI_EXTEND_DATA_12B) || \
480 ((DATA) == DCMI_EXTEND_DATA_14B))
481
482#define IS_DCMI_WINDOW_COORDINATE(COORDINATE) ((COORDINATE) <= DCMI_WINDOW_COORDINATE)
483
484#define IS_DCMI_WINDOW_HEIGHT(HEIGHT) ((HEIGHT) <= DCMI_WINDOW_HEIGHT)
485
486/**
487 * @}
488 */
489
490/* Private functions ---------------------------------------------------------*/
491/** @addtogroup DCMI_Private_Functions DCMI Private Functions
492 * @{
493 */
494
495/**
496 * @}
497 */
498
499#endif /* STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx ||\
500 STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx ||\
501 STM32F479xx */
502
503/**
504 * @}
505 */
506
507/**
508 * @}
509 */
510
511#ifdef __cplusplus
512}
513#endif
514
515#endif /* __STM32F4xx_HAL_DCMI_H */
516
517/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Note: See TracBrowser for help on using the repository browser.