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