stm32l4xx_hal_dcmi.h 28 KB

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