21 #ifndef __STM32F4xx_HAL_DCMI_H
22 #define __STM32F4xx_HAL_DCMI_H
28 #if defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) ||\
29 defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) ||\
32 #include "stm32f4xx_hal_def.h"
56 uint8_t FrameStartUnmask;
57 uint8_t LineStartUnmask;
58 uint8_t LineEndUnmask;
59 uint8_t FrameEndUnmask;
60 }DCMI_SyncUnmaskTypeDef;
66 HAL_DCMI_STATE_RESET = 0x00U,
67 HAL_DCMI_STATE_READY = 0x01U,
68 HAL_DCMI_STATE_BUSY = 0x02U,
69 HAL_DCMI_STATE_TIMEOUT = 0x03U,
70 HAL_DCMI_STATE_ERROR = 0x04U,
71 HAL_DCMI_STATE_SUSPENDED = 0x05U
72 }HAL_DCMI_StateTypeDef;
77 typedef struct __DCMI_HandleTypeDef
81 DCMI_InitTypeDef
Init;
85 __IO HAL_DCMI_StateTypeDef State;
87 __IO uint32_t XferCount;
89 __IO uint32_t XferSize;
91 uint32_t XferTransferNumber;
97 __IO uint32_t ErrorCode;
98 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
99 void (* FrameEventCallback) (
struct __DCMI_HandleTypeDef *hdcmi);
100 void (* VsyncEventCallback) (
struct __DCMI_HandleTypeDef *hdcmi);
101 void (* LineEventCallback ) (
struct __DCMI_HandleTypeDef *hdcmi);
102 void (* ErrorCallback) (
struct __DCMI_HandleTypeDef *hdcmi);
103 void (* MspInitCallback) (
struct __DCMI_HandleTypeDef *hdcmi);
104 void (* MspDeInitCallback) (
struct __DCMI_HandleTypeDef *hdcmi);
108 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
111 HAL_DCMI_FRAME_EVENT_CB_ID = 0x00U,
112 HAL_DCMI_VSYNC_EVENT_CB_ID = 0x01U,
113 HAL_DCMI_LINE_EVENT_CB_ID = 0x02U,
114 HAL_DCMI_ERROR_CB_ID = 0x03U,
115 HAL_DCMI_MSPINIT_CB_ID = 0x04U,
116 HAL_DCMI_MSPDEINIT_CB_ID = 0x05U
118 }HAL_DCMI_CallbackIDTypeDef;
120 typedef void (*pDCMI_CallbackTypeDef)(DCMI_HandleTypeDef *hdcmi);
136 #define HAL_DCMI_ERROR_NONE 0x00000000U
137 #define HAL_DCMI_ERROR_OVR 0x00000001U
138 #define HAL_DCMI_ERROR_SYNC 0x00000002U
139 #define HAL_DCMI_ERROR_TIMEOUT 0x00000020U
140 #define HAL_DCMI_ERROR_DMA 0x00000040U
141 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
142 #define HAL_DCMI_ERROR_INVALID_CALLBACK ((uint32_t)0x00000080U)
151 #define DCMI_MODE_CONTINUOUS 0x00000000U
153 #define DCMI_MODE_SNAPSHOT ((uint32_t)DCMI_CR_CM)
162 #define DCMI_SYNCHRO_HARDWARE 0x00000000U
164 #define DCMI_SYNCHRO_EMBEDDED ((uint32_t)DCMI_CR_ESS)
174 #define DCMI_PCKPOLARITY_FALLING 0x00000000U
175 #define DCMI_PCKPOLARITY_RISING ((uint32_t)DCMI_CR_PCKPOL)
184 #define DCMI_VSPOLARITY_LOW 0x00000000U
185 #define DCMI_VSPOLARITY_HIGH ((uint32_t)DCMI_CR_VSPOL)
194 #define DCMI_HSPOLARITY_LOW 0x00000000U
195 #define DCMI_HSPOLARITY_HIGH ((uint32_t)DCMI_CR_HSPOL)
204 #define DCMI_JPEG_DISABLE 0x00000000U
205 #define DCMI_JPEG_ENABLE ((uint32_t)DCMI_CR_JPEG)
214 #define DCMI_CR_ALL_FRAME 0x00000000U
215 #define DCMI_CR_ALTERNATE_2_FRAME ((uint32_t)DCMI_CR_FCRC_0)
216 #define DCMI_CR_ALTERNATE_4_FRAME ((uint32_t)DCMI_CR_FCRC_1)
225 #define DCMI_EXTEND_DATA_8B 0x00000000U
226 #define DCMI_EXTEND_DATA_10B ((uint32_t)DCMI_CR_EDM_0)
227 #define DCMI_EXTEND_DATA_12B ((uint32_t)DCMI_CR_EDM_1)
228 #define DCMI_EXTEND_DATA_14B ((uint32_t)(DCMI_CR_EDM_0 | DCMI_CR_EDM_1))
237 #define DCMI_WINDOW_COORDINATE 0x3FFFU
246 #define DCMI_WINDOW_HEIGHT 0x1FFFU
255 #define DCMI_POSITION_CWSIZE_VLINE (uint32_t)DCMI_CWSIZE_VLINE_Pos
256 #define DCMI_POSITION_CWSTRT_VST (uint32_t)DCMI_CWSTRT_VST_Pos
265 #define DCMI_IT_FRAME ((uint32_t)DCMI_IER_FRAME_IE)
266 #define DCMI_IT_OVR ((uint32_t)DCMI_IER_OVR_IE)
267 #define DCMI_IT_ERR ((uint32_t)DCMI_IER_ERR_IE)
268 #define DCMI_IT_VSYNC ((uint32_t)DCMI_IER_VSYNC_IE)
269 #define DCMI_IT_LINE ((uint32_t)DCMI_IER_LINE_IE)
281 #define DCMI_FLAG_HSYNC ((uint32_t)DCMI_SR_INDEX|DCMI_SR_HSYNC)
282 #define DCMI_FLAG_VSYNC ((uint32_t)DCMI_SR_INDEX|DCMI_SR_VSYNC)
283 #define DCMI_FLAG_FNE ((uint32_t)DCMI_SR_INDEX|DCMI_SR_FNE)
287 #define DCMI_FLAG_FRAMERI ((uint32_t)DCMI_RISR_FRAME_RIS)
288 #define DCMI_FLAG_OVRRI ((uint32_t)DCMI_RISR_OVR_RIS)
289 #define DCMI_FLAG_ERRRI ((uint32_t)DCMI_RISR_ERR_RIS)
290 #define DCMI_FLAG_VSYNCRI ((uint32_t)DCMI_RISR_VSYNC_RIS)
291 #define DCMI_FLAG_LINERI ((uint32_t)DCMI_RISR_LINE_RIS)
295 #define DCMI_FLAG_FRAMEMI ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_FRAME_MIS)
296 #define DCMI_FLAG_OVRMI ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_OVR_MIS )
297 #define DCMI_FLAG_ERRMI ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_ERR_MIS )
298 #define DCMI_FLAG_VSYNCMI ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_VSYNC_MIS)
299 #define DCMI_FLAG_LINEMI ((uint32_t)DCMI_MIS_INDEX|DCMI_MIS_LINE_MIS )
317 #define __HAL_DCMI_RESET_HANDLE_STATE(__HANDLE__) do{ \
318 (__HANDLE__)->State = HAL_DCMI_STATE_RESET; \
319 (__HANDLE__)->MspInitCallback = NULL; \
320 (__HANDLE__)->MspDeInitCallback = NULL; \
328 #define __HAL_DCMI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= DCMI_CR_ENABLE)
335 #define __HAL_DCMI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(DCMI_CR_ENABLE))
358 #define __HAL_DCMI_GET_FLAG(__HANDLE__, __FLAG__)\
359 ((((__FLAG__) & (DCMI_SR_INDEX|DCMI_MIS_INDEX)) == 0x0U)? ((__HANDLE__)->Instance->RISR & (__FLAG__)) :\
360 (((__FLAG__) & DCMI_SR_INDEX) == 0x0U)? ((__HANDLE__)->Instance->MISR & (__FLAG__)) : ((__HANDLE__)->Instance->SR & (__FLAG__)))
374 #define __HAL_DCMI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
388 #define __HAL_DCMI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
402 #define __HAL_DCMI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= ~(__INTERRUPT__))
416 #define __HAL_DCMI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->MISR & (__INTERRUPT__))
433 void HAL_DCMI_MspInit(DCMI_HandleTypeDef* hdcmi);
434 void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* hdcmi);
437 #if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
438 HAL_StatusTypeDef HAL_DCMI_RegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID, pDCMI_CallbackTypeDef pCallback);
439 HAL_StatusTypeDef HAL_DCMI_UnRegisterCallback(DCMI_HandleTypeDef *hdcmi, HAL_DCMI_CallbackIDTypeDef CallbackID);
449 HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length);
453 void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi);
454 void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi);
455 void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi);
456 void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi);
457 void HAL_DCMI_VsyncCallback(DCMI_HandleTypeDef *hdcmi);
458 void HAL_DCMI_HsyncCallback(DCMI_HandleTypeDef *hdcmi);
459 void HAL_DCMI_IRQHandler(DCMI_HandleTypeDef *hdcmi);
468 HAL_StatusTypeDef HAL_DCMI_ConfigCrop(DCMI_HandleTypeDef *hdcmi, uint32_t X0, uint32_t Y0, uint32_t XSize, uint32_t YSize);
471 HAL_StatusTypeDef HAL_DCMI_ConfigSyncUnmask(DCMI_HandleTypeDef *hdcmi, DCMI_SyncUnmaskTypeDef *SyncUnmask);
480 HAL_DCMI_StateTypeDef HAL_DCMI_GetState(DCMI_HandleTypeDef *hdcmi);
481 uint32_t HAL_DCMI_GetError(DCMI_HandleTypeDef *hdcmi);
496 #define DCMI_MIS_INDEX 0x1000U
497 #define DCMI_SR_INDEX 0x2000U
505 #define IS_DCMI_CAPTURE_MODE(MODE)(((MODE) == DCMI_MODE_CONTINUOUS) || \
506 ((MODE) == DCMI_MODE_SNAPSHOT))
508 #define IS_DCMI_SYNCHRO(MODE)(((MODE) == DCMI_SYNCHRO_HARDWARE) || \
509 ((MODE) == DCMI_SYNCHRO_EMBEDDED))
511 #define IS_DCMI_PCKPOLARITY(POLARITY)(((POLARITY) == DCMI_PCKPOLARITY_FALLING) || \
512 ((POLARITY) == DCMI_PCKPOLARITY_RISING))
514 #define IS_DCMI_VSPOLARITY(POLARITY)(((POLARITY) == DCMI_VSPOLARITY_LOW) || \
515 ((POLARITY) == DCMI_VSPOLARITY_HIGH))
517 #define IS_DCMI_HSPOLARITY(POLARITY)(((POLARITY) == DCMI_HSPOLARITY_LOW) || \
518 ((POLARITY) == DCMI_HSPOLARITY_HIGH))
520 #define IS_DCMI_MODE_JPEG(JPEG_MODE)(((JPEG_MODE) == DCMI_JPEG_DISABLE) || \
521 ((JPEG_MODE) == DCMI_JPEG_ENABLE))
523 #define IS_DCMI_CAPTURE_RATE(RATE) (((RATE) == DCMI_CR_ALL_FRAME) || \
524 ((RATE) == DCMI_CR_ALTERNATE_2_FRAME) || \
525 ((RATE) == DCMI_CR_ALTERNATE_4_FRAME))
527 #define IS_DCMI_EXTENDED_DATA(DATA)(((DATA) == DCMI_EXTEND_DATA_8B) || \
528 ((DATA) == DCMI_EXTEND_DATA_10B) || \
529 ((DATA) == DCMI_EXTEND_DATA_12B) || \
530 ((DATA) == DCMI_EXTEND_DATA_14B))
532 #define IS_DCMI_WINDOW_COORDINATE(COORDINATE) ((COORDINATE) <= DCMI_WINDOW_COORDINATE)
534 #define IS_DCMI_WINDOW_HEIGHT(HEIGHT) ((HEIGHT) <= DCMI_WINDOW_HEIGHT)