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