hc32f4a0_dvp.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /**
  2. *******************************************************************************
  3. * @file hc32f4a0_dvp.h
  4. * @brief This file contains all the functions prototypes of the DVP(Digital
  5. * Video Processor) driver library.
  6. @verbatim
  7. Change Logs:
  8. Date Author Notes
  9. 2020-08-20 Hongjh First version
  10. @endverbatim
  11. *******************************************************************************
  12. * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
  13. *
  14. * This software component is licensed by HDSC under BSD 3-Clause license
  15. * (the "License"); You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. *******************************************************************************
  20. */
  21. #ifndef __HC32F4A0_DVP_H__
  22. #define __HC32F4A0_DVP_H__
  23. /* C binding of definitions if building with C++ compiler */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*******************************************************************************
  29. * Include files
  30. ******************************************************************************/
  31. #include "hc32_common.h"
  32. #include "ddl_config.h"
  33. /**
  34. * @addtogroup HC32F4A0_DDL_Driver
  35. * @{
  36. */
  37. /**
  38. * @addtogroup DDL_DVP
  39. * @{
  40. */
  41. #if (DDL_DVP_ENABLE == DDL_ON)
  42. /*******************************************************************************
  43. * Global type definitions ('typedef')
  44. ******************************************************************************/
  45. /**
  46. * @defgroup DVP_Global_Types DVP Global Types
  47. * @{
  48. */
  49. /**
  50. * @brief DVP Initialization Structure definition
  51. */
  52. typedef struct
  53. {
  54. uint32_t u32SyncMode; /*!< The DVP sync mode.
  55. This parameter can be a value of @ref DVP_Sync_Mode. */
  56. uint32_t u32DataWidth; /*!< The DVP data interface width.
  57. This parameter can be a value of @ref DVP_Data_Width. */
  58. uint32_t u32CaptureMode; /*!< The DVP capture mode.
  59. This parameter can be a value of @ref DVP_Capture_Mode. */
  60. uint32_t u32CaptureFreq; /*!< The DVP capture frequence.
  61. This parameter can be a value of @ref DVP_Capture_Frequence. */
  62. uint32_t u32PIXCLKPolarity; /*!< The DVP_PIXCLK Polarity.
  63. This parameter can be a value of @ref DVP_PIXCLK_Polarity. */
  64. uint32_t u32HSYNCPolarity; /*!< The DVP_HSYNC Polarity.
  65. This parameter can be a value of @ref DVP_HSYNC_Polarity. */
  66. uint32_t u32VSYNCPolarity; /*!< The DVP_VSYNC Polarity.
  67. This parameter can be a value of @ref DVP_VSYNC_Polarity. */
  68. } stc_dvp_init_t;
  69. /**
  70. * @brief DVP Crop Window Configure definition
  71. */
  72. typedef struct
  73. {
  74. uint32_t u32X; /*!< The DVP window X offset
  75. This parameter can be a value between 0x00 and 0x3FFF */
  76. uint32_t u32Y; /*!< The DVP window Y offset
  77. This parameter can be a value between 0x00 and 0x3FFF */
  78. uint32_t u32XSize; /*!< The DVP window pixel per line
  79. This parameter can be a value between 0x00 and 0x3FFF */
  80. uint32_t u32YSize; /*!< The DVP window line number.
  81. This parameter can be a value between 0x00 and 0x3FFF */
  82. } stc_dvp_crop_window_config_t;
  83. /**
  84. * @brief DVP Software Sync Code definition
  85. */
  86. typedef struct
  87. {
  88. uint32_t u32FrameStartSyncCode; /*!< The sync code of the frame start delimiter.
  89. This parameter can be a value between 0x00 and 0xFF */
  90. uint32_t u32LineStartSyncCode; /*!< The sync code of the line start delimiter.
  91. This parameter can be a value between 0x00 and 0xFF */
  92. uint32_t u32LineEndSyncCode; /*!< The sync code of the line end delimiter.
  93. This parameter can be a value between 0x00 and 0xFF */
  94. uint32_t u32FrameEndSyncCode; /*!< The sync code of the frame end delimiter.
  95. This parameter can be a value between 0x00 and 0xFF */
  96. } stc_dvp_sw_sync_code_t;
  97. /**
  98. * @brief DVP Software Mask Code definition
  99. */
  100. typedef struct
  101. {
  102. uint32_t u32FrameStartMaskCode; /*!< The mask code of the frame start delimiter.
  103. This parameter can be a value between between 0x00 and 0xFF */
  104. uint32_t u32LineStartMaskCode; /*!< The mask code of the line start delimiter.
  105. This parameter can be a value between between 0x00 and 0xFF */
  106. uint32_t u32LineEndMaskCode; /*!< The mask code of the line end delimiter.
  107. This parameter can be a value between between 0x00 and 0xFF */
  108. uint32_t u32FrameEndMaskCode; /*!< The mask code of the frame end delimiter.
  109. This parameter can be a value between between 0x00 and 0xFF */
  110. } stc_dvp_sw_mask_code_t;
  111. /**
  112. * @}
  113. */
  114. /*******************************************************************************
  115. * Global pre-processor symbols/macros ('#define')
  116. ******************************************************************************/
  117. /**
  118. * @defgroup DVP_Global_Macros DVP Global Macros
  119. * @{
  120. */
  121. /** @defgroup DVP_Capture_Mode DVP Capture Mode
  122. * @{
  123. */
  124. #define DVP_CAPT_MD_CONTINUOS_FRAME (0UL)
  125. #define DVP_CAPT_MD_SINGLE_FRAME (DVP_CTR_CAPMD)
  126. /**
  127. * @}
  128. */
  129. /** @defgroup DVP_Sync_Mode DVP Sync Mode
  130. * @{
  131. */
  132. #define DVP_SYNC_MD_HW (0UL) /*!< Hardware sync */
  133. #define DVP_SYNC_MD_SW (DVP_CTR_SWSYNC) /*!< Software sync */
  134. /**
  135. * @}
  136. */
  137. /** @defgroup DVP_PIXCLK_Polarity DVP PIXCLK Polarity
  138. * @{
  139. */
  140. #define DVP_PIXCLK_FALLING (0UL) /*!< DVP_PIXCLK active on Falling edge */
  141. #define DVP_PIXCLK_RISING (DVP_CTR_PIXCKSEL) /*!< DVP_PIXCLK active on Rising edge */
  142. /**
  143. * @}
  144. */
  145. /** @defgroup DVP_HSYNC_Polarity DVP HSYNC Polarity
  146. * @{
  147. */
  148. #define DVP_HSYNC_LOW (0UL) /*!< DVP_HSYNC active Low */
  149. #define DVP_HSYNC_HIGH (DVP_CTR_HSYNCSEL) /*!< DVP_HSYNC active High */
  150. /**
  151. * @}
  152. */
  153. /** @defgroup DVP_VSYNC_Polarity DVP VSYNC Polarity
  154. * @{
  155. */
  156. #define DVP_VSYNC_LOW (0UL) /*!< DVP_VSYNC active Low */
  157. #define DVP_VSYNC_HIGH (DVP_CTR_VSYNCSEL) /*!< DVP_VSYNC active High */
  158. /**
  159. * @}
  160. */
  161. /**
  162. * @defgroup DVP_Capture_Frequence DVP Capture Frequence
  163. * @{
  164. */
  165. #define DVP_CAPT_FREQ_ALL_FRAME (0UL) /*!< All frames are captured */
  166. #define DVP_CAPT_FREQ_ONT_TIME_2FRAME (DVP_CTR_CAPFRC_0) /*!< One frame per 2 frames captured */
  167. #define DVP_CAPT_FREQ_ONT_TIME_4FRAME (DVP_CTR_CAPFRC_1) /*!< One frame per 4 frames captured */
  168. /**
  169. * @}
  170. */
  171. /**
  172. * @defgroup DVP_Data_Width DVP Data Width
  173. * @{
  174. */
  175. #define DVP_DATA_WIDTH_8BIT (0UL) /*!< DVP captures 8-bit data on every DVP_PIXCLK clock */
  176. #define DVP_DATA_WIDTH_10BIT (DVP_CTR_BITSEL_0) /*!< DVP captures 10-bit data on every DVP_PIXCLK clock */
  177. #define DVP_DATA_WIDTH_12BIT (DVP_CTR_BITSEL_1) /*!< DVP captures 12-bit data on every DVP_PIXCLK clock */
  178. #define DVP_DATA_WIDTH_14BIT (DVP_CTR_BITSEL) /*!< DVP captures 14-bit data on every DVP_PIXCLK clock */
  179. /**
  180. * @}
  181. */
  182. /**
  183. * @defgroup DVP_Flag DVP Flag
  184. * @{
  185. */
  186. #define DVP_FLAG_FRAME_START (DVP_STR_FSF) /*!< Frame start flag */
  187. #define DVP_FLAG_LINE_START (DVP_STR_LSF) /*!< Line start flag */
  188. #define DVP_FLAG_LINE_END (DVP_STR_LEF) /*!< Line end flag */
  189. #define DVP_FLAG_FRAME_END (DVP_STR_FEF) /*!< Frame end flag */
  190. #define DVP_FLAG_FIFO_OVF (DVP_STR_FIFOERF) /*!< FIFO overflow error flag */
  191. #define DVP_FLAG_SYNC_ERR (DVP_STR_SQUERF) /*!< Sync error flag */
  192. #define DVP_FLAG_ALL (DVP_FLAG_SYNC_ERR | \
  193. DVP_FLAG_FIFO_OVF | \
  194. DVP_FLAG_LINE_END | \
  195. DVP_FLAG_LINE_START | \
  196. DVP_FLAG_FRAME_END | \
  197. DVP_FLAG_FRAME_START)
  198. /**
  199. * @}
  200. */
  201. /**
  202. * @defgroup DVP_Interrupt DVP Interrupt
  203. * @{
  204. */
  205. #define DVP_INT_FRAME_START (DVP_IER_FSIEN) /*!< Frame start interrupt */
  206. #define DVP_INT_LINE_START (DVP_IER_LSIEN) /*!< Line start interrupt */
  207. #define DVP_INT_LINE_END (DVP_IER_LEIEN) /*!< Line end interrupt */
  208. #define DVP_INT_FRAME_END (DVP_IER_FEIEN) /*!< Frame end interrupt */
  209. #define DVP_INT_FIFO_OVF (DVP_IER_FIFOERIEN) /*!< FIFO overflow error interrupt */
  210. #define DVP_INT_SYNC_ERR (DVP_IER_SQUERIEN) /*!< Sync error interrupt */
  211. #define DVP_INT_ALL (DVP_INT_SYNC_ERR | \
  212. DVP_INT_FIFO_OVF | \
  213. DVP_INT_LINE_END | \
  214. DVP_INT_LINE_START | \
  215. DVP_INT_FRAME_END | \
  216. DVP_INT_FRAME_START)
  217. /**
  218. * @}
  219. */
  220. /**
  221. * @}
  222. */
  223. /*******************************************************************************
  224. * Global variable definitions ('extern')
  225. ******************************************************************************/
  226. /*******************************************************************************
  227. Global function prototypes (definition in C source)
  228. ******************************************************************************/
  229. /**
  230. * @addtogroup DVP_Global_Functions
  231. * @{
  232. */
  233. en_result_t DVP_Init(const stc_dvp_init_t *pstcDvpInit);
  234. void DVP_DeInit(void);
  235. en_result_t DVP_StructInit(stc_dvp_init_t *pstcDvpInit);
  236. void DVP_Cmd(en_functional_state_t enNewState);
  237. void DVP_IntCmd(uint32_t u32IntType, en_functional_state_t enNewState);
  238. void DVP_CropCmd(en_functional_state_t enNewState);
  239. void DVP_JPEGCmd(en_functional_state_t enNewState);
  240. void DVP_CaptrueCmd(en_functional_state_t enNewState);
  241. en_functional_state_t DVP_GetCaptrueCmdState(void);
  242. en_flag_status_t DVP_GetStatus(uint32_t u32Flag);
  243. void DVP_ClearStatus(uint32_t u32Flag);
  244. en_result_t DVP_SetSWSyncCode(const stc_dvp_sw_sync_code_t *pstcSyncCode);
  245. en_result_t DVP_SetSWMaskCode(const stc_dvp_sw_mask_code_t *pstcMaskCode);
  246. en_result_t DVP_CropWindowConfig(const stc_dvp_crop_window_config_t *pstcConfig);
  247. /**
  248. * @}
  249. */
  250. #endif /* DDL_DVP_ENABLE */
  251. /**
  252. * @}
  253. */
  254. /**
  255. * @}
  256. */
  257. #ifdef __cplusplus
  258. }
  259. #endif
  260. #endif /* __HC32F4A0_DVP_H__ */
  261. /*******************************************************************************
  262. * EOF (not truncated)
  263. ******************************************************************************/