n32g45x_dvp.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /*****************************************************************************
  2. * Copyright (c) 2019, Nations Technologies Inc.
  3. *
  4. * All rights reserved.
  5. * ****************************************************************************
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * - Redistributions of source code must retain the above copyright notice,
  11. * this list of conditions and the disclaimer below.
  12. *
  13. * Nations' name may not be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. *
  16. * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY NATIONS "AS IS" AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  19. * DISCLAIMED. IN NO EVENT SHALL NATIONS BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
  22. * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  23. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  24. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  25. * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. * ****************************************************************************/
  27. /**
  28. * @file n32g45x_dvp.h
  29. * @author Nations
  30. * @version v1.0.4
  31. *
  32. * @copyright Copyright (c) 2019, Nations Technologies Inc. All rights reserved.
  33. */
  34. #ifndef __N32G45X_DVP_H__
  35. #define __N32G45X_DVP_H__
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. #include "n32g45x.h"
  40. /** @addtogroup N32G45X_StdPeriph_Driver
  41. * @{
  42. */
  43. /** @addtogroup DVP
  44. * @brief DVP driver modules
  45. * @{
  46. */
  47. /** @addtogroup DVP_Exported_Types
  48. * @{
  49. */
  50. /**
  51. * @brief DVP Init Structure definition
  52. */
  53. typedef struct
  54. {
  55. uint32_t FifoWatermark; /*!< Specifies the max number of fifo data which will request INT or DMA
  56. This parameter can be a value of @ref DVP_FifoWatermark */
  57. uint16_t LineCapture; /*!< Specifies the number of data line captuered in x lines.
  58. This parameter can be a value of @ref DVP_LineSelect_Mode */
  59. uint16_t ByteCapture; /*!< Specifies the number of stop byte captuered in x bytes.
  60. This parameter can be a value of @ref DVP_ByteSelect_Mode */
  61. uint16_t DataInvert; /*!< Specifies the data invert.
  62. This parameter can be a value of @ref DVP_DATA_INVERT */
  63. uint16_t PixelClkPolarity; /*!< Specifies the pixel clock polarity
  64. This parameter can be a value of @ref DVP_Pixel_Polarity */
  65. uint16_t VsyncPolarity; /*!< Specifies the vertical synchronization polarity
  66. This parameter can be a value of @ref DVP_Vsync_Polarity */
  67. uint16_t HsyncPolarity; /*!< Specifies the Horizontal synchronization polarity
  68. This parameter can be a value of @ref DVP_Hsync_Polarity */
  69. uint16_t CaptureMode; /*!< Specifies the capture mode.
  70. This parameter can be a value of @ref DVP_Capture_Mode */
  71. uint16_t RowStart; /*!< Specifies the startint row of the pixel array in a frame */
  72. uint16_t ColumnStart; /*!< Specifies the starting column of the pixel array row in a frame */
  73. uint16_t ImageHeight; /*!< Specifies the image's height in a frame */
  74. uint16_t ImageWidth; /*!< Specifies the image's width in a frame */
  75. } DVP_InitType;
  76. /**
  77. * @}
  78. */
  79. /** @addtogroup DVP_Exported_Constants
  80. * @{
  81. */
  82. /** @addtogroup DVP_FIFO_SOFT_RESET
  83. * @{
  84. */
  85. #define DVP_FIFO_SOFT_RESET (DVP_CTRL_FFSWRST)
  86. /**
  87. * @}
  88. */
  89. /** @addtogroup DVP_LineSelect_Mode
  90. * @{
  91. */
  92. #define DVP_LINE_CAPTURE_ALL (0x00000000)
  93. #define DVP_LINE_CAPTURE_1_2 (0x1UL << DVP_CTRL_LSM_SHIFT)
  94. #define DVP_LINE_CAPTURE_1_3 (0x2UL << DVP_CTRL_LSM_SHIFT)
  95. #define DVP_LINE_CAPTURE_1_4 (0x3UL << DVP_CTRL_LSM_SHIFT)
  96. #define DVP_LINE_CAPTURE_1_5 (0x4UL << DVP_CTRL_LSM_SHIFT)
  97. #define DVP_LINE_CAPTURE_1_6 (0x5UL << DVP_CTRL_LSM_SHIFT)
  98. #define DVP_LINE_CAPTURE_1_7 (0x6UL << DVP_CTRL_LSM_SHIFT)
  99. #define DVP_LINE_CAPTURE_1_8 (0x7UL << DVP_CTRL_LSM_SHIFT)
  100. #define IS_DVP_LINE_CAPTURE(_LSM_) (((_LSM_) & (~DVP_CTRL_LSM_MASK) )==0)
  101. /**
  102. * @}
  103. */
  104. /** @addtogroup DVP_ByteSelect_Mode
  105. * @{
  106. */
  107. #define DVP_BYTE_CAPTURE_ALL (0x00000000)
  108. #define DVP_BYTE_CAPTURE_1_2 (0x1UL << DVP_CTRL_BSM_SHIFT)
  109. #define DVP_BYTE_CAPTURE_1_3 (0x2UL << DVP_CTRL_BSM_SHIFT)
  110. #define DVP_BYTE_CAPTURE_1_4 (0x3UL << DVP_CTRL_BSM_SHIFT)
  111. #define DVP_BYTE_CAPTURE_1_5 (0x4UL << DVP_CTRL_BSM_SHIFT)
  112. #define DVP_BYTE_CAPTURE_1_6 (0x5UL << DVP_CTRL_BSM_SHIFT)
  113. #define DVP_BYTE_CAPTURE_1_7 (0x6UL << DVP_CTRL_BSM_SHIFT)
  114. #define DVP_BYTE_CAPTURE_1_8 (0x7UL << DVP_CTRL_BSM_SHIFT)
  115. #define IS_DVP_BYTE_CAPTURE(_BSM_) (((_BSM_) & (~DVP_CTRL_BSM_MASK) )==0)
  116. /**
  117. * @}
  118. */
  119. /** @addtogroup DVP_DATA_INVERT
  120. * @{
  121. */
  122. #define DVP_DATA_INVERT (DVP_CTRL_DATINV)
  123. #define DVP_DATA_NOTINVERT (0x00000000)
  124. #define IS_DVP_DATA_INVERT(_INV_) (((_INV_) & (~DVP_CTRL_DATINV_MASK) )==0)
  125. /**
  126. * @}
  127. */
  128. /** @addtogroup DVP_Pixel_Polarity
  129. * @{
  130. */
  131. #define DVP_PIXEL_POLARITY_FALLING (0x00000000)
  132. #define DVP_PIXEL_POLARITY_RISING (DVP_CTRL_PCKPOL)
  133. #define IS_DVP_PIXEL_POLARITY(_POL_) (((_POL_) & (~DVP_CTRL_PCKPOL_MASK) )==0)
  134. /**
  135. * @}
  136. */
  137. /** @addtogroup DVP_FifoWatermark
  138. * @{
  139. */
  140. #define DVP_WATER_MARK_0 (0x00000000)
  141. #define DVP_WATER_MARK_1 (0x1UL << DVP_CTRL_FWM_SHIFT)
  142. #define DVP_WATER_MARK_2 (0x2UL << DVP_CTRL_FWM_SHIFT)
  143. #define DVP_WATER_MARK_3 (0x3UL << DVP_CTRL_FWM_SHIFT)
  144. #define DVP_WATER_MARK_4 (0x4UL << DVP_CTRL_FWM_SHIFT)
  145. #define DVP_WATER_MARK_5 (0x5UL << DVP_CTRL_FWM_SHIFT)
  146. #define DVP_WATER_MARK_6 (0x6UL << DVP_CTRL_FWM_SHIFT)
  147. #define DVP_WATER_MARK_7 (0x7UL << DVP_CTRL_FWM_SHIFT)
  148. #define IS_DVP_FIFOWATERMARK(_WATER_) (((_WATER_) >= DVP_WATER_MARK_1) && ((_WATER_) <= DVP_WATER_MARK_7))
  149. /** @addtogroup DVP_Vsync_Polarity
  150. * @{
  151. */
  152. #define DVP_VSYNC_POLARITY_HIGH (DVP_CTRL_VSPOL)
  153. #define DVP_VSYNC_POLARITY_LOW (0x00000000)
  154. #define IS_DVP_VSYNC_POLARITY(_POL_) (((_POL_) == DVP_VSYNC_POLARITY_HIGH) || ((_POL_) == DVP_VSYNC_POLARITY_LOW))
  155. /**
  156. * @}
  157. */
  158. /** @addtogroup DVP_Hsync_Polarity
  159. * @{
  160. */
  161. #define DVP_HSYNC_POLARITY_HIGH (DVP_CTRL_HSPOL)
  162. #define DVP_HSYNC_POLARITY_LOW (0x00000000)
  163. #define IS_DVP_HSYNC_POLARITY(_POL_) (((_POL_) == DVP_HSYNC_POLARITY_HIGH) || ((_POL_) == DVP_HSYNC_POLARITY_LOW))
  164. /**
  165. * @}
  166. */
  167. /** @addtogroup DVP_Capture_Mode
  168. * @{
  169. */
  170. #define DVP_CAPTURE_MODE_SINGLE (0x00000000)
  171. #define DVP_CAPTURE_MODE_CONTINUE (DVP_CTRL_CM)
  172. #define IS_DVP_CAPTURE_MODE(_MODE_) (((_MODE_) == DVP_CAPTURE_MODE_SINGLE) || ((_MODE_) == DVP_CAPTURE_MODE_CONTINUE))
  173. /**
  174. * @}
  175. */
  176. /** @addtogroup DVP_CAPTURE_ENABLE
  177. * @{
  178. */
  179. #define DVP_CAPTURE_DISABLE (0x00000000)
  180. #define DVP_CAPTURE_ENABLE (DVP_CTRL_CAPTURE)
  181. #define IS_DVP_CAPTURE(_CAPTURE_) (((_CAPTURE_) == DVP_CAPTURE_DISABLE) || ((_CAPTURE_) == DVP_CAPTURE_ENABLE))
  182. /**
  183. * @}
  184. */
  185. /** @addtogroup DVP_DMA
  186. * @{
  187. */
  188. #define DVP_DMA_DISABLE (0x00000000)
  189. #define DVP_DMA_ENABLE (DVP_INTEN_DMAEN)
  190. /**
  191. * @}
  192. */
  193. /** @addtogroup DVP_StatusFlag
  194. * @{
  195. */
  196. #define DVP_FLAG_HERR (DVP_INTSTS_HERRIS)
  197. #define DVP_FLAG_VERR (DVP_INTSTS_VERRIS)
  198. #define DVP_FLAG_FO (DVP_INTSTS_FOIS)
  199. #define DVP_FLAG_FW (DVP_INTSTS_FWIS)
  200. #define DVP_FLAG_FF (DVP_INTSTS_FFIS)
  201. #define DVP_FLAG_FE (DVP_INTSTS_FEIS)
  202. #define DVP_FLAG_LE (DVP_INTSTS_LEIS)
  203. #define DVP_FLAG_LS (DVP_INTSTS_LSIS)
  204. #define DVP_FLAG_FME (DVP_INTSTS_FMEIS)
  205. #define DVP_FLAG_FMS (DVP_INTSTS_FMSIS)
  206. #define DVP_FLAG_MASK (DVP_FLAG_HERR |DVP_FLAG_VERR |DVP_FLAG_FO \
  207. |DVP_FLAG_FW |DVP_FLAG_FF |DVP_FLAG_FE \
  208. |DVP_FLAG_LE |DVP_FLAG_LS |DVP_FLAG_FME \
  209. |DVP_FLAG_FMS)
  210. #define IS_DVP_FLAG(_FLAG_) (((_FLAG_) & (~DVP_FLAG_MASK))==0)
  211. /** @addtogroup DVP_ClearFlag
  212. * @{
  213. */
  214. #define DVP_CLEAR_FLAG_HERR (DVP_INTSTS_HERRIS)
  215. #define DVP_CLEAR_FLAG_VERR (DVP_INTSTS_VERRIS)
  216. #define DVP_CLEAR_FLAG_FO (DVP_INTSTS_FOIS)
  217. #define DVP_CLEAR_FLAG_FE (DVP_INTSTS_FEIS)
  218. #define DVP_CLEAR_FLAG_LE (DVP_INTSTS_LEIS)
  219. #define DVP_CLEAR_FLAG_LS (DVP_INTSTS_LSIS)
  220. #define DVP_CLEAR_FLAG_FME (DVP_INTSTS_FMEIS)
  221. #define DVP_CLEAR_FLAG_FMS (DVP_INTSTS_FMSIS)
  222. #define DVP_CLEAR_FLAG_MASK (DVP_CLEAR_FLAG_HERR |DVP_CLEAR_FLAG_VERR \
  223. |DVP_CLEAR_FLAG_FO |DVP_CLEAR_FLAG_FE \
  224. |DVP_CLEAR_FLAG_LE |DVP_CLEAR_FLAG_LS \
  225. |DVP_CLEAR_FLAG_FME |DVP_CLEAR_FLAG_FMS)
  226. #define IS_DVP_CLEAR_FLAG(_FLAG_) (((_FLAG_) & (~DVP_CLEAR_FLAG_MASK))==0)
  227. /**
  228. * @}
  229. */
  230. /** @addtogroup DVP_IntEnable
  231. * @{
  232. */
  233. #define DVP_INTEN_HERR (DVP_INTEN_HERRIE)
  234. #define DVP_INTEN_VERR (DVP_INTEN_VERRIE)
  235. #define DVP_INTEN_FO (DVP_INTEN_FOIE)
  236. #define DVP_INTEN_FW (DVP_INTEN_FWIE)
  237. #define DVP_INTEN_FF (DVP_INTEN_FFIE)
  238. #define DVP_INTEN_FE (DVP_INTEN_FEIE)
  239. #define DVP_INTEN_LE (DVP_INTEN_LEIE)
  240. #define DVP_INTEN_LS (DVP_INTEN_LSIE)
  241. #define DVP_INTEN_FME (DVP_INTEN_FMEIE)
  242. #define DVP_INTEN_FMS (DVP_INTEN_FMSIE)
  243. #define DVP_INTEN_MASK (DVP_INTEN_HERR |DVP_INTEN_VERR |DVP_INTEN_FO |DVP_INTEN_FW \
  244. |DVP_INTEN_FF |DVP_INTEN_FE |DVP_INTEN_LE |DVP_INTEN_LS \
  245. |DVP_INTEN_FME |DVP_INTEN_FMS)
  246. #define IS_DVP_INTEN(_INT_) (((_INT_) & (~DVP_INTEN_MASK))==0)
  247. /**
  248. * @}
  249. */
  250. /** @addtogroup DVP_IntMark
  251. * @{
  252. */
  253. #define DVP_MINT_HERR (DVP_MINTSTS_HERRMIS)
  254. #define DVP_MINT_VERR (DVP_MINTSTS_VERRMIS)
  255. #define DVP_MINT_FO (DVP_MINTSTS_FOMIS)
  256. #define DVP_MINT_FW (DVP_MINTSTS_FWMIS)
  257. #define DVP_MINT_FF (DVP_MINTSTS_FFMIS)
  258. #define DVP_MINT_FE (DVP_MINTSTS_FEMIS)
  259. #define DVP_MINT_LE (DVP_MINTSTS_LEMIS)
  260. #define DVP_MINT_LS (DVP_MINTSTS_LSMIS)
  261. #define DVP_MINT_FME (DVP_MINTSTS_FMEMIS)
  262. #define DVP_MINT_FMS (DVP_MINTSTS_FMSMIS)
  263. #define DVP_MINT_MASK (DVP_MINT_HERR |DVP_MINT_VERR |DVP_MINT_FO |DVP_MINT_FW \
  264. |DVP_MINT_FF |DVP_MINT_FE |DVP_MINT_LE |DVP_MINT_LS \
  265. |DVP_MINT_FME |DVP_MINT_FMS)
  266. #define IS_DVP_MINT(_MINT_) (((_MINT_) & (~DVP_MINT_MASK))==0)
  267. /**
  268. * @}
  269. */
  270. /* Exported macros -----------------------------------------------------------*/
  271. /** @addtogroup DVP_Exported_Macros
  272. * @{
  273. */
  274. /**
  275. * @brief Config the water mark of FIFO.
  276. * @param _Watermark_ Select the new water mark of FIFO.
  277. * This parameter can be one of the following values:
  278. * @arg DVP_WATER_MARK_1
  279. * @arg DVP_WATER_MARK_2
  280. * @arg DVP_WATER_MARK_3
  281. * @arg DVP_WATER_MARK_4
  282. * @retval None
  283. */
  284. #define __DVP_SetFifoWatermark(_Watermark_) (MODIFY_REG(DVP->CTRL, DVP_CTRL_FWM_MASK, _Watermark_))
  285. /**
  286. * @brief Config the line capture mode.
  287. * @param _LSM_ Specifies the new mode of line capture.
  288. * This parameter can be one of the following values:
  289. * @arg DVP_LINE_CAPTURE_ALL Capture all lines
  290. * @arg DVP_LINE_CAPTURE_1_2 Capture 1 line of each 2 lines
  291. * @arg DVP_LINE_CAPTURE_1_3 Capture 1 line of each 3 lines
  292. * @arg DVP_LINE_CAPTURE_1_4 Capture 1 line of each 4 lines
  293. * @arg DVP_LINE_CAPTURE_1_5 Capture 1 line of each 5 lines
  294. * @arg DVP_LINE_CAPTURE_1_6 Capture 1 line of each 6 lines
  295. * @arg DVP_LINE_CAPTURE_1_7 Capture 1 line of each 7 lines
  296. * @arg DVP_LINE_CAPTURE_1_8 Capture 1 line of each 8 lines
  297. * @retval None
  298. */
  299. #define __DVP_SetLineCaptureMode(_LSM_) (MODIFY_REG(DVP->CTRL, DVP_CTRL_LSM_MASK, _LSM_))
  300. /**
  301. * @brief Config the byte capture mode.
  302. * @param _BSM_ Specifies the new mode of byte capture.
  303. * This parameter can be one of the following values:
  304. * @arg DVP_BYTE_CAPTURE_ALL Capture all pixels
  305. * @arg DVP_BYTE_CAPTURE_1_2 Capture 1 pixel of each 2 pixels
  306. * @arg DVP_BYTE_CAPTURE_1_3 Capture 1 pixel of each 3 pixels
  307. * @arg DVP_BYTE_CAPTURE_1_4 Capture 1 pixel of each 4 pixels
  308. * @arg DVP_BYTE_CAPTURE_1_5 Capture 1 pixel of each 5 pixels
  309. * @arg DVP_BYTE_CAPTURE_1_6 Capture 1 pixel of each 6 pixels
  310. * @arg DVP_BYTE_CAPTURE_1_7 Capture 1 pixel of each 7 pixels
  311. * @arg DVP_BYTE_CAPTURE_1_8 Capture 1 pixel of each 8 pixels
  312. * @retval None
  313. */
  314. #define __DVP_SetByteCaptureMode(_BSM_) (MODIFY_REG(DVP->CTRL, DVP_CTRL_BSM_MASK, _BSM_))
  315. /**
  316. * @brief Config the data invert function.
  317. * @param _INV_ Specifies the data invert or not.
  318. * This parameter can be one of the following values:
  319. * @arg DVP_DATA_INVERT Invert capture data
  320. * @arg DVP_DATA_NOTINVERT Capture data not invert
  321. * @retval None
  322. */
  323. #define __DVP_SetDataInvert(_INV_) (MODIFY_REG(DVP->CTRL, DVP_CTRL_DATINV_MASK, _INV_))
  324. /**
  325. * @brief Config the pixel clock polarity.
  326. * @param _POL_ Specifies the clock edge of pixel clock.
  327. * This parameter can be one of the following values:
  328. * @arg DVP_PIXEL_POLARITY_FALLING Get data at falling edge
  329. * @arg DVP_PIXEL_POLARITY_RISING Get data at rising edge
  330. * @retval None
  331. */
  332. #define __DVP_SetPclkPol(_POL_) (MODIFY_REG(DVP->CTRL, DVP_CTRL_PCKPOL_MASK, _POL_))
  333. /**
  334. * @brief Config the VSYNC polarity.
  335. * @param _POL_ Specifies the active polarity of VSYNC pin.
  336. * This parameter can be one of the following values:
  337. * @arg DVP_VSYNC_POLARITY_HIGH VSYNC active high
  338. * @arg DVP_VSYNC_POLARITY_LOW VSYNC active low
  339. * @retval None
  340. */
  341. #define __DVP_SetVsyncPol(_POL_) (MODIFY_REG(DVP->CTRL, DVP_CTRL_VSPOL_MASK, _POL_))
  342. /**
  343. * @brief Config the HSYNC polarity.
  344. * @param _POL_ Specifies the active polarity of HSYNC pin.
  345. * This parameter can be one of the following values:
  346. * @arg DVP_HSYNC_POLARITY_HIGH VSYNC active high
  347. * @arg DVP_HSYNC_POLARITY_LOW VSYNC active low
  348. * @retval None
  349. */
  350. #define __DVP_SetHsyncPol(_POL_) (MODIFY_REG(DVP->CTRL, DVP_CTRL_HSPOL_MASK, _POL_))
  351. /**
  352. * @brief Config the capture mode.
  353. * @param _POL_ Specifies the new capture mode.
  354. * This parameter can be one of the following values:
  355. * @arg DVP_CAPTURE_MODE_SINGLE Capture one frame
  356. * @arg DVP_CAPTURE_MODE_CONTINUE Capture many frames
  357. * @retval None
  358. */
  359. #define __DVP_SetCaptureMode(_MODE_) (MODIFY_REG(DVP->CTRL, DVP_CTRL_CM_MASK, _MODE_))
  360. /**
  361. * @brief Enable DVP interface.
  362. * @param None
  363. * @retval None
  364. */
  365. #define __DVP_StartCapture() (SET_BIT(DVP->CTRL, DVP_CAPTURE_ENABLE))
  366. /**
  367. * @brief Disable DVP interface.
  368. * @param None
  369. * @retval None
  370. */
  371. #define __DVP_StopCapture() (CLEAR_BIT(DVP->CTRL, DVP_CAPTURE_ENABLE))
  372. /**
  373. * @brief Disable DVP interface.
  374. * @param None
  375. * @retval None
  376. */
  377. #define __FIFOIsNotEmpty() (READ_BIT(DVP->STS, DVP_STS_FNE))
  378. /**
  379. * @brief Checks whether the specified DVP flag is set.
  380. * @param _FLAG_ specifies the flag to check.
  381. * This parameter can be any combination of the following values:
  382. * @arg DVP_FLAG_HERR Hsync error interrupt flag
  383. * @arg DVP_FLAG_VERR Vsync error interrupt flag
  384. * @arg DVP_FLAG_FO FIFO overflow intterrupt flag
  385. * @arg DVP_FLAG_FW FIFO watermark interrupt flag
  386. * @arg DVP_FLAG_FF FIFO full interrupt flag
  387. * @arg DVP_FLAG_FE FIFO empty interrupt flag
  388. * @arg DVP_FLAG_LE Line end interrupt flag
  389. * @arg DVP_FLAG_LS Line start interrupt flag
  390. * @arg DVP_FLAG_FME Frame end interrupt flag
  391. * @arg DVP_FLAG_FMS Frame start interrupt flag
  392. * @retval true or false.
  393. */
  394. #define __DVP_FlagIsSet(_FLAG_) (((DVP->INTSTS) & (_FLAG_))==(_FLAG_))
  395. /**
  396. * @brief Checks whether the specified DVP flag is not set.
  397. * @param _FLAG_ specifies the flag to check.
  398. * This parameter can be any combination of the following values:
  399. * @arg DVP_FLAG_HERR Hsync error interrupt flag
  400. * @arg DVP_FLAG_VERR Vsync error interrupt flag
  401. * @arg DVP_FLAG_FO FIFO overflow intterrupt flag
  402. * @arg DVP_FLAG_FW FIFO watermark interrupt flag
  403. * @arg DVP_FLAG_FF FIFO full interrupt flag
  404. * @arg DVP_FLAG_FE FIFO empty interrupt flag
  405. * @arg DVP_FLAG_LE Line end interrupt flag
  406. * @arg DVP_FLAG_LS Line start interrupt flag
  407. * @arg DVP_FLAG_FME Frame end interrupt flag
  408. * @arg DVP_FLAG_FMS Frame start interrupt flag
  409. * @retval true or false.
  410. */
  411. #define __DVP_FlagIsNotSet(_FLAG_) (((DVP->INTSTS) & (_FLAG_))!=(_FLAG_))
  412. /**
  413. * @brief Clears the DVP flags.
  414. * @param _FLAG_ specifies the flag to clear.
  415. * This parameter can be any combination of the following values:
  416. * @arg DVP_CLEAR_FLAG_HERR Hsync error interrupt flag clear
  417. * @arg DVP_CLEAR_FLAG_VERR Vsync error interrupt flag clear
  418. * @arg DVP_CLEAR_FLAG_FO FIFO overflow intterrupt flag clear
  419. * @arg DVP_CLEAR_FLAG_FE FIFO empty interrupt flag clear
  420. * @arg DVP_CLEAR_FLAG_LE Line end interrupt flag clear
  421. * @arg DVP_CLEAR_FLAG_LS Line start interrupt flag clear
  422. * @arg DVP_CLEAR_FLAG_FME Frame end interrupt flag clear
  423. * @arg DVP_CLEAR_FLAG_FMS Frame start interrupt flag clear
  424. * @retval None.
  425. */
  426. #define __DVP_ClrFlag(_FLAG_) (DVP->INTSTS = (~(_FLAG_)) & DVP_CLEAR_FLAG_MASK)
  427. /**
  428. * @brief Enable DVP interrupts.
  429. * @param _INT_ specifies the interrupt to be enable.
  430. * This parameter can be any combination of the following values:
  431. * @arg DVP_INTEN_HERR Hsync error interrupt enable
  432. * @arg DVP_INTEN_VERR Vsync error interrupt enable
  433. * @arg DVP_INTEN_FO FIFO overflow intterrupt enable
  434. * @arg DVP_INTEN_FE FIFO empty interrupt enable
  435. * @arg DVP_INTEN_LE Line end interrupt enable
  436. * @arg DVP_INTEN_LS Line start interrupt enable
  437. * @arg DVP_INTEN_FME Frame end interrupt enable
  438. * @arg DVP_INTEN_FMS Frame start interrupt enable
  439. * @retval None.
  440. */
  441. #define __DVP_EnableInt(_INT_) (SET_BIT(DVP->INTEN, _INT_))
  442. /**
  443. * @brief Disable DVP interrupts.
  444. * @param _INT_ specifies the interrupt to be disable.
  445. * This parameter can be any combination of the following values:
  446. * @arg DVP_INTEN_HERR Hsync error interrupt disable
  447. * @arg DVP_INTEN_VERR Vsync error interrupt disable
  448. * @arg DVP_INTEN_FO FIFO overflow intterrupt disable
  449. * @arg DVP_INTEN_FE FIFO empty interrupt disable
  450. * @arg DVP_INTEN_LE Line end interrupt disable
  451. * @arg DVP_INTEN_LS Line start interrupt disable
  452. * @arg DVP_INTEN_FME Frame end interrupt disable
  453. * @arg DVP_INTEN_FMS Frame start interrupt disable
  454. * @retval None.
  455. */
  456. #define __DVP_DisableInt(_INT_) (CLEAR_BIT(DVP->INTEN, _INT_))
  457. /**
  458. * @brief Enable DVP DMA.
  459. * @param None.
  460. * @retval None.
  461. */
  462. #define __DVP_EnableDMA() (SET_BIT(DVP->INTEN, DVP_INTEN_DMAEN))
  463. /**
  464. * @brief Enable DVP DMA.
  465. * @param None.
  466. * @retval None.
  467. */
  468. #define __DVP_DisableDMA() (CLEAR_BIT(DVP->INTEN, DVP_INTEN_DMAEN))
  469. /**
  470. * @brief Checks whether the specified DVP interrupt has occurred or not.
  471. * @param _INT_ specifies the DVP interrupt source to check.
  472. * This parameter can be one of the following values:
  473. * @arg DVP_MINT_HERR Hsync error interrupt
  474. * @arg DVP_MINT_VERR Vsync error interrupt
  475. * @arg DVP_MINT_FO FIFO overflow intterrupt
  476. * @arg DVP_MINT_FW FIFO watermark interrupt
  477. * @arg DVP_MINT_FF FIFO full interrupt
  478. * @arg DVP_MINT_FE FIFO empty interrupt
  479. * @arg DVP_MINT_LE Line end interrupt
  480. * @arg DVP_MINT_LS Line start interrupt
  481. * @arg DVP_MINT_FME Frame end interrupt
  482. * @arg DVP_MINT_FMS Frame start interrupt
  483. * @retval The state of _INT_ (SET or RESET).
  484. */
  485. #define __DVP_GetIntMark(_INT_) (((DVP->MINTSTS) & (_INT_))==(_INT_))
  486. /**
  487. * @brief Config the positon of first capture pixel .
  488. * @param _VST_ specifies the line positon.
  489. * This parameter must be less than 2048.
  490. * @param _HST_ specifies the pixel positon.
  491. * This parameter must be less than 2048.
  492. * @retval None.
  493. */
  494. #define __DVP_SetStartSHIFT(_VST_,_HST_) (DVP->WST=((_VST_)<<DVP_WST_VST_SHIFT)|(_HST_))
  495. /**
  496. * @brief Config the size of capture picture (frame) .
  497. * @param _VLINE_ specifies the total lines of a frame.
  498. * This parameter must be less than 2048.
  499. * @param _HCNT_ specifies the pixels of a line.
  500. * This parameter must be less than 2048.
  501. * @retval None.
  502. */
  503. #define __DVP_SetPicSize(_VLINE_,_HCNT_) (DVP->WSIZE=((_VLINE_)<<DVP_WSIZE_VLINE_SHIFT)|(_HCNT_))
  504. /**
  505. * @brief Read data from FIFO.
  506. * @param None.
  507. * @retval Data in FIFO
  508. */
  509. #define __DVP_ReadFIFO() (READ_REG(DVP->FIFO))
  510. /**
  511. * @}
  512. */
  513. /** @addtogroup DVP_Exported_Functions
  514. * @{
  515. */
  516. void DVP_ResetReg(void);
  517. void DVP_Init(DVP_InitType* DVP_InitStruct);
  518. void DVP_DafaultInitParam(DVP_InitType* DVP_InitStruct);
  519. uint32_t DVP_GetFifoCount(void);
  520. void DVP_ResetFifo(void);
  521. void DVP_ConfigDma( FunctionalState Cmd);
  522. /**
  523. * @}
  524. */
  525. /**
  526. * @}
  527. */
  528. /**
  529. * @}
  530. */
  531. #ifdef __cplusplus
  532. }
  533. #endif
  534. #endif