apm32f4xx_dci.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*!
  2. * @file apm32f4xx_dci.h
  3. *
  4. * @brief This file contains all the functions prototypes for the DCI firmware library
  5. *
  6. * @version V1.0.2
  7. *
  8. * @date 2022-06-23
  9. *
  10. * @attention
  11. *
  12. * Copyright (C) 2021-2022 Geehy Semiconductor
  13. *
  14. * You may not use this file except in compliance with the
  15. * GEEHY COPYRIGHT NOTICE (GEEHY SOFTWARE PACKAGE LICENSE).
  16. *
  17. * The program is only for reference, which is distributed in the hope
  18. * that it will be usefull and instructional for customers to develop
  19. * their software. Unless required by applicable law or agreed to in
  20. * writing, the program is distributed on an "AS IS" BASIS, WITHOUT
  21. * ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the GEEHY SOFTWARE PACKAGE LICENSE for the governing permissions
  23. * and limitations under the License.
  24. */
  25. /* Define to prevent recursive inclusion */
  26. #ifndef __APM32F4XX_DCI_H
  27. #define __APM32F4XX_DCI_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* Includes */
  32. #include "apm32f4xx.h"
  33. /** @addtogroup APM32F4xx_StdPeriphDriver
  34. @{
  35. */
  36. /** @addtogroup DCI_Driver
  37. @{
  38. */
  39. /** @defgroup DCI_Enumerations
  40. @{
  41. */
  42. /**
  43. * @brief DCI Capture Mode
  44. */
  45. typedef enum
  46. {
  47. DCI_CAPTURE_MODE_CONTINUOUS, /*!< Continuous capture mode */
  48. DCI_CAPTURE_MODE_SNAPSHOT /*!< Snapshot mode */
  49. } DCI_CAPTURE_MODE_T;
  50. /**
  51. * @brief DCI Synchronization Mode
  52. */
  53. typedef enum
  54. {
  55. DCI_SYNCHRO_MODE_HARDWARE, /*!< Hardware synchronization */
  56. DCI_SYNCHRO_MODE_EMBEDDED /*!< Embedded code synchronization */
  57. } DCI_SYNCHRO_MODEVAL_T;
  58. /**
  59. * @brief DCI Pixel Clock Polarity
  60. */
  61. typedef enum
  62. {
  63. DCI_PCK_POL_FALLING, /*!< Falling edge capture */
  64. DCI_PCK_POL_RISING /*!< Rising edge capture */
  65. } DCI_PCK_POL_T;
  66. /**
  67. * @brief DCI VSYNC Polarity
  68. */
  69. typedef enum
  70. {
  71. DCI_VSYNC_POL_LOW, /*!< VSYNC low-level valid */
  72. DCI_VSYNC_POL_HIGH /*!< VSYNC high-level valid */
  73. } DCI_VSYNC_POL_T;
  74. /**
  75. * @brief DCI HSYNC Polarity
  76. */
  77. typedef enum
  78. {
  79. DCI_HSYNC_POL_LOW, /*!< HSYNC low-level valid */
  80. DCI_HSYNC_POL_HIGH /*!< HSYNC high-level valid */
  81. } DCI_HSYNC_POL_T;
  82. /**
  83. * @brief DCI Capture Rate
  84. */
  85. typedef enum
  86. {
  87. DCI_CAPTURE_RATE_ALL_FRAME, /*!< Capture all frame */
  88. DCI_CAPTURE_RATE_1OF2_FRAME, /*!< Capture every other frame */
  89. DCI_CAPTURE_RATE_1OF4_FRAME /*!< Capture every three frame */
  90. } DCI_CAPTURE_RATE_T;
  91. /**
  92. * @brief DCI Extended Data Mode
  93. */
  94. typedef enum
  95. {
  96. DCI_EXTENDED_DATA_MODE_8B, /*!< Extended 8-bit data mode */
  97. DCI_EXTENDED_DATA_MODE_10B, /*!< Extended 10-bit data mode */
  98. DCI_EXTENDED_DATA_MODE_12B, /*!< Extended 12-bit data mode */
  99. DCI_EXTENDED_DATA_MODE_14B /*!< Extended 14-bit data mode */
  100. } DCI_EXTENDED_DATA_MODE_T;
  101. /**
  102. * @brief DCI interrupt sources
  103. */
  104. typedef enum
  105. {
  106. DCI_INT_CC =((uint16_t)0x0001), /*!< Frame capture complete interrupt mask */
  107. DCI_INT_OVR =((uint16_t)0x0002), /*!< Overflow interrupt mask */
  108. DCI_INT_ERR =((uint16_t)0x0004), /*!< Synchronization error interrupt mask */
  109. DCI_INT_VSYNC =((uint16_t)0x0008), /*!< VSYNC interrupt mask */
  110. DCI_INT_LINE =((uint16_t)0x0010), /*!< Line interrupt mask */
  111. } DCI_INT_T;
  112. /**
  113. * @brief DCI flags
  114. */
  115. typedef enum
  116. {
  117. /* DCI RINTSTS register */
  118. DCI_FLAG_CCI =((uint16_t)0x0001), /*!< Frame capture complete Raw flag mask */
  119. DCI_FLAG_OVRI =((uint16_t)0x0002), /*!< Overflow Raw flag mask */
  120. DCI_FLAG_ERRI =((uint16_t)0x0004), /*!< Synchronization error Raw flag mask */
  121. DCI_FLAG_VSYNCI =((uint16_t)0x0008), /*!< VSYNC Raw flag mask */
  122. DCI_FLAG_LINEI =((uint16_t)0x0010), /*!< Line Raw flag mask */
  123. /* DCI MINTSTS register */
  124. DCI_FLAG_CCMI =((uint16_t)0x1001), /*!< Frame capture complete Masked flag mask */
  125. DCI_FLAG_OVRMI =((uint16_t)0x1002), /*!< Overflow Masked flag mask */
  126. DCI_FLAG_ERRMI =((uint16_t)0x1004), /*!< Synchronization error Masked flag mask */
  127. DCI_FLAG_VSYNCMI =((uint16_t)0x1008), /*!< VSYNC Masked flag mask */
  128. DCI_FLAG_LINEMI =((uint16_t)0x1010), /*!< Line Masked flag mask */
  129. /* DCI STS register */
  130. DCI_FLAG_HSYNC =((uint16_t)0x2001), /*!< HSYNC flag mask */
  131. DCI_FLAG_VSYNC =((uint16_t)0x2002), /*!< VSYNC flag mask */
  132. DCI_FLAG_FNE =((uint16_t)0x2004), /*!< Fifo not empty flag mask */
  133. } DCI_FLAG_T;
  134. /**@} end of group DCI_Enumerations*/
  135. /** @addtogroup DCI_Structure Data Structure
  136. @{
  137. */
  138. /**
  139. * @brief DCI Config structure definition
  140. */
  141. typedef struct
  142. {
  143. DCI_CAPTURE_MODE_T captureMode; /*!< Specifies the Capture Mode: Continuous or Snapshot */
  144. DCI_SYNCHRO_MODEVAL_T synchroMode; /*!< Specifies the Synchronization Mode: Hardware or Embedded */
  145. DCI_PCK_POL_T pckPolarity; /*!< Specifies the Pixel clock polarity: Falling or Rising */
  146. DCI_VSYNC_POL_T vsyncPolarity; /*!< Specifies the Vertical synchronization polarity: High or Low */
  147. DCI_HSYNC_POL_T hsyncPolarity; /*!< Specifies the Horizontal synchronization polarity: High or Low */
  148. DCI_CAPTURE_RATE_T capturerate; /*!< Specifies the frequency of frame capture: All, 1/2 or 1/4 */
  149. DCI_EXTENDED_DATA_MODE_T extendedDataMode; /*!< Specifies the data width: 8-bit, 10-bit, 12-bit or 14-bit */
  150. } DCI_Config_T;
  151. /**
  152. * @brief DCI CROP Init structure definition
  153. */
  154. typedef struct
  155. {
  156. uint16_t verticalStartLine; /*!< Vertical start line count from which the image capture(between 0x00 and 0x1FFF) */
  157. uint16_t horizontalOffsetCount; /*!< number of pixel clocks to count before starting a capture(between 0x00 and 0x3FFF) */
  158. uint16_t verticalLineCount; /*!< number of lines to be captured from the starting point(between 0x00 and 0x3FFF) */
  159. uint16_t captureCount; /*!< number of pixel clocks to be captured from the starting(between 0x00 and 0x3FFF) */
  160. } DCI_CropConfig_T;
  161. /**
  162. * @brief DCI Embedded Synchronisation CODE Init structure definition
  163. */
  164. typedef struct
  165. {
  166. uint8_t frameStartCode; /*!< Specifies the code of the frame start delimiter */
  167. uint8_t lineStartCode; /*!< Specifies the code of the line start delimiter */
  168. uint8_t lineEndCode; /*!< Specifies the code of the line end delimiter */
  169. uint8_t frameEndCode; /*!< Specifies the code of the frame end delimiter */
  170. } DCI_CodeConfig_T;
  171. /**@} end of group DCI_Structure*/
  172. /** @defgroup DCI_Functions
  173. @{
  174. */
  175. /** DCI Configuration */
  176. void DCI_Rest(void);
  177. void DCI_Config(DCI_Config_T* dciConfig);
  178. void DCI_ConfigStructInit(DCI_Config_T* dciConfig);
  179. void DCI_ConfigCROP(DCI_CropConfig_T* cropConfig);
  180. void DCI_EnableCROP(void);
  181. void DCI_DisableCROP(void);
  182. void DCI_ConfigSynchroCode(DCI_CodeConfig_T* codeConfig);
  183. void DCI_EnableJPEG(void);
  184. void DCI_DisableJPEG(void);
  185. /** DCI Image capture */
  186. void DCI_Enable(void);
  187. void DCI_Disable(void);
  188. void DCI_EnableCapture(void);
  189. void DCI_DisableCapture(void);
  190. uint32_t DCI_ReadData(void);
  191. /** Interrupts and flags */
  192. void DCI_EnableInterrupt(uint32_t interrupt);
  193. void DCI_DisableInterrupt(uint32_t interrupt);
  194. uint16_t DCI_ReadStatusFlag(DCI_FLAG_T flag);
  195. void DCI_ClearStatusFlag(uint16_t flag);
  196. uint16_t DCI_ReadIntFlag(DCI_INT_T flag);
  197. void DCI_ClearIntFlag(uint16_t flag);
  198. #ifdef __cplusplus
  199. }
  200. #endif
  201. #endif /* __APM32F4XX_DCI_H */
  202. /**@} end of group DCI_Enumerations */
  203. /**@} end of group DCI_Driver */
  204. /**@} end of group APM32F4xx_StdPeriphDriver */