You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

672 lines
28 KiB

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