stm32f4xx_dcmi.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_dcmi.h
  4. * @author MCD Application Team
  5. * @version V1.8.0
  6. * @date 04-November-2016
  7. * @brief This file contains all the functions prototypes for the DCMI firmware library.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
  12. *
  13. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  14. * You may not use this file except in compliance with the License.
  15. * You may obtain a copy of the License at:
  16. *
  17. * http://www.st.com/software_license_agreement_liberty_v2
  18. *
  19. * Unless required by applicable law or agreed to in writing, software
  20. * distributed under the License is distributed on an "AS IS" BASIS,
  21. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. * See the License for the specific language governing permissions and
  23. * limitations under the License.
  24. *
  25. ******************************************************************************
  26. */
  27. /* Define to prevent recursive inclusion -------------------------------------*/
  28. #ifndef __STM32F4xx_DCMI_H
  29. #define __STM32F4xx_DCMI_H
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. /* Includes ------------------------------------------------------------------*/
  34. #include "stm32f4xx.h"
  35. /** @addtogroup STM32F4xx_StdPeriph_Driver
  36. * @{
  37. */
  38. /** @addtogroup DCMI
  39. * @{
  40. */
  41. /* Exported types ------------------------------------------------------------*/
  42. /**
  43. * @brief DCMI Init structure definition
  44. */
  45. typedef struct
  46. {
  47. uint16_t DCMI_CaptureMode; /*!< Specifies the Capture Mode: Continuous or Snapshot.
  48. This parameter can be a value of @ref DCMI_Capture_Mode */
  49. uint16_t DCMI_SynchroMode; /*!< Specifies the Synchronization Mode: Hardware or Embedded.
  50. This parameter can be a value of @ref DCMI_Synchronization_Mode */
  51. uint16_t DCMI_PCKPolarity; /*!< Specifies the Pixel clock polarity: Falling or Rising.
  52. This parameter can be a value of @ref DCMI_PIXCK_Polarity */
  53. uint16_t DCMI_VSPolarity; /*!< Specifies the Vertical synchronization polarity: High or Low.
  54. This parameter can be a value of @ref DCMI_VSYNC_Polarity */
  55. uint16_t DCMI_HSPolarity; /*!< Specifies the Horizontal synchronization polarity: High or Low.
  56. This parameter can be a value of @ref DCMI_HSYNC_Polarity */
  57. uint16_t DCMI_CaptureRate; /*!< Specifies the frequency of frame capture: All, 1/2 or 1/4.
  58. This parameter can be a value of @ref DCMI_Capture_Rate */
  59. uint16_t DCMI_ExtendedDataMode; /*!< Specifies the data width: 8-bit, 10-bit, 12-bit or 14-bit.
  60. This parameter can be a value of @ref DCMI_Extended_Data_Mode */
  61. } DCMI_InitTypeDef;
  62. /**
  63. * @brief DCMI CROP Init structure definition
  64. */
  65. typedef struct
  66. {
  67. uint16_t DCMI_VerticalStartLine; /*!< Specifies the Vertical start line count from which the image capture
  68. will start. This parameter can be a value between 0x00 and 0x1FFF */
  69. uint16_t DCMI_HorizontalOffsetCount; /*!< Specifies the number of pixel clocks to count before starting a capture.
  70. This parameter can be a value between 0x00 and 0x3FFF */
  71. uint16_t DCMI_VerticalLineCount; /*!< Specifies the number of lines to be captured from the starting point.
  72. This parameter can be a value between 0x00 and 0x3FFF */
  73. uint16_t DCMI_CaptureCount; /*!< Specifies the number of pixel clocks to be captured from the starting
  74. point on the same line.
  75. This parameter can be a value between 0x00 and 0x3FFF */
  76. } DCMI_CROPInitTypeDef;
  77. /**
  78. * @brief DCMI Embedded Synchronisation CODE Init structure definition
  79. */
  80. typedef struct
  81. {
  82. uint8_t DCMI_FrameStartCode; /*!< Specifies the code of the frame start delimiter. */
  83. uint8_t DCMI_LineStartCode; /*!< Specifies the code of the line start delimiter. */
  84. uint8_t DCMI_LineEndCode; /*!< Specifies the code of the line end delimiter. */
  85. uint8_t DCMI_FrameEndCode; /*!< Specifies the code of the frame end delimiter. */
  86. } DCMI_CodesInitTypeDef;
  87. /* Exported constants --------------------------------------------------------*/
  88. /** @defgroup DCMI_Exported_Constants
  89. * @{
  90. */
  91. /** @defgroup DCMI_Capture_Mode
  92. * @{
  93. */
  94. #define DCMI_CaptureMode_Continuous ((uint16_t)0x0000) /*!< The received data are transferred continuously
  95. into the destination memory through the DMA */
  96. #define DCMI_CaptureMode_SnapShot ((uint16_t)0x0002) /*!< Once activated, the interface waits for the start of
  97. frame and then transfers a single frame through the DMA */
  98. #define IS_DCMI_CAPTURE_MODE(MODE)(((MODE) == DCMI_CaptureMode_Continuous) || \
  99. ((MODE) == DCMI_CaptureMode_SnapShot))
  100. /**
  101. * @}
  102. */
  103. /** @defgroup DCMI_Synchronization_Mode
  104. * @{
  105. */
  106. #define DCMI_SynchroMode_Hardware ((uint16_t)0x0000) /*!< Hardware synchronization data capture (frame/line start/stop)
  107. is synchronized with the HSYNC/VSYNC signals */
  108. #define DCMI_SynchroMode_Embedded ((uint16_t)0x0010) /*!< Embedded synchronization data capture is synchronized with
  109. synchronization codes embedded in the data flow */
  110. #define IS_DCMI_SYNCHRO(MODE)(((MODE) == DCMI_SynchroMode_Hardware) || \
  111. ((MODE) == DCMI_SynchroMode_Embedded))
  112. /**
  113. * @}
  114. */
  115. /** @defgroup DCMI_PIXCK_Polarity
  116. * @{
  117. */
  118. #define DCMI_PCKPolarity_Falling ((uint16_t)0x0000) /*!< Pixel clock active on Falling edge */
  119. #define DCMI_PCKPolarity_Rising ((uint16_t)0x0020) /*!< Pixel clock active on Rising edge */
  120. #define IS_DCMI_PCKPOLARITY(POLARITY)(((POLARITY) == DCMI_PCKPolarity_Falling) || \
  121. ((POLARITY) == DCMI_PCKPolarity_Rising))
  122. /**
  123. * @}
  124. */
  125. /** @defgroup DCMI_VSYNC_Polarity
  126. * @{
  127. */
  128. #define DCMI_VSPolarity_Low ((uint16_t)0x0000) /*!< Vertical synchronization active Low */
  129. #define DCMI_VSPolarity_High ((uint16_t)0x0080) /*!< Vertical synchronization active High */
  130. #define IS_DCMI_VSPOLARITY(POLARITY)(((POLARITY) == DCMI_VSPolarity_Low) || \
  131. ((POLARITY) == DCMI_VSPolarity_High))
  132. /**
  133. * @}
  134. */
  135. /** @defgroup DCMI_HSYNC_Polarity
  136. * @{
  137. */
  138. #define DCMI_HSPolarity_Low ((uint16_t)0x0000) /*!< Horizontal synchronization active Low */
  139. #define DCMI_HSPolarity_High ((uint16_t)0x0040) /*!< Horizontal synchronization active High */
  140. #define IS_DCMI_HSPOLARITY(POLARITY)(((POLARITY) == DCMI_HSPolarity_Low) || \
  141. ((POLARITY) == DCMI_HSPolarity_High))
  142. /**
  143. * @}
  144. */
  145. /** @defgroup DCMI_Capture_Rate
  146. * @{
  147. */
  148. #define DCMI_CaptureRate_All_Frame ((uint16_t)0x0000) /*!< All frames are captured */
  149. #define DCMI_CaptureRate_1of2_Frame ((uint16_t)0x0100) /*!< Every alternate frame captured */
  150. #define DCMI_CaptureRate_1of4_Frame ((uint16_t)0x0200) /*!< One frame in 4 frames captured */
  151. #define IS_DCMI_CAPTURE_RATE(RATE) (((RATE) == DCMI_CaptureRate_All_Frame) || \
  152. ((RATE) == DCMI_CaptureRate_1of2_Frame) ||\
  153. ((RATE) == DCMI_CaptureRate_1of4_Frame))
  154. /**
  155. * @}
  156. */
  157. /** @defgroup DCMI_Extended_Data_Mode
  158. * @{
  159. */
  160. #define DCMI_ExtendedDataMode_8b ((uint16_t)0x0000) /*!< Interface captures 8-bit data on every pixel clock */
  161. #define DCMI_ExtendedDataMode_10b ((uint16_t)0x0400) /*!< Interface captures 10-bit data on every pixel clock */
  162. #define DCMI_ExtendedDataMode_12b ((uint16_t)0x0800) /*!< Interface captures 12-bit data on every pixel clock */
  163. #define DCMI_ExtendedDataMode_14b ((uint16_t)0x0C00) /*!< Interface captures 14-bit data on every pixel clock */
  164. #define IS_DCMI_EXTENDED_DATA(DATA)(((DATA) == DCMI_ExtendedDataMode_8b) || \
  165. ((DATA) == DCMI_ExtendedDataMode_10b) ||\
  166. ((DATA) == DCMI_ExtendedDataMode_12b) ||\
  167. ((DATA) == DCMI_ExtendedDataMode_14b))
  168. /**
  169. * @}
  170. */
  171. /** @defgroup DCMI_interrupt_sources
  172. * @{
  173. */
  174. #define DCMI_IT_FRAME ((uint16_t)0x0001)
  175. #define DCMI_IT_OVF ((uint16_t)0x0002)
  176. #define DCMI_IT_ERR ((uint16_t)0x0004)
  177. #define DCMI_IT_VSYNC ((uint16_t)0x0008)
  178. #define DCMI_IT_LINE ((uint16_t)0x0010)
  179. #define IS_DCMI_CONFIG_IT(IT) ((((IT) & (uint16_t)0xFFE0) == 0x0000) && ((IT) != 0x0000))
  180. #define IS_DCMI_GET_IT(IT) (((IT) == DCMI_IT_FRAME) || \
  181. ((IT) == DCMI_IT_OVF) || \
  182. ((IT) == DCMI_IT_ERR) || \
  183. ((IT) == DCMI_IT_VSYNC) || \
  184. ((IT) == DCMI_IT_LINE))
  185. /**
  186. * @}
  187. */
  188. /** @defgroup DCMI_Flags
  189. * @{
  190. */
  191. /**
  192. * @brief DCMI SR register
  193. */
  194. #define DCMI_FLAG_HSYNC ((uint16_t)0x2001)
  195. #define DCMI_FLAG_VSYNC ((uint16_t)0x2002)
  196. #define DCMI_FLAG_FNE ((uint16_t)0x2004)
  197. /**
  198. * @brief DCMI RISR register
  199. */
  200. #define DCMI_FLAG_FRAMERI ((uint16_t)0x0001)
  201. #define DCMI_FLAG_OVFRI ((uint16_t)0x0002)
  202. #define DCMI_FLAG_ERRRI ((uint16_t)0x0004)
  203. #define DCMI_FLAG_VSYNCRI ((uint16_t)0x0008)
  204. #define DCMI_FLAG_LINERI ((uint16_t)0x0010)
  205. /**
  206. * @brief DCMI MISR register
  207. */
  208. #define DCMI_FLAG_FRAMEMI ((uint16_t)0x1001)
  209. #define DCMI_FLAG_OVFMI ((uint16_t)0x1002)
  210. #define DCMI_FLAG_ERRMI ((uint16_t)0x1004)
  211. #define DCMI_FLAG_VSYNCMI ((uint16_t)0x1008)
  212. #define DCMI_FLAG_LINEMI ((uint16_t)0x1010)
  213. #define IS_DCMI_GET_FLAG(FLAG) (((FLAG) == DCMI_FLAG_HSYNC) || \
  214. ((FLAG) == DCMI_FLAG_VSYNC) || \
  215. ((FLAG) == DCMI_FLAG_FNE) || \
  216. ((FLAG) == DCMI_FLAG_FRAMERI) || \
  217. ((FLAG) == DCMI_FLAG_OVFRI) || \
  218. ((FLAG) == DCMI_FLAG_ERRRI) || \
  219. ((FLAG) == DCMI_FLAG_VSYNCRI) || \
  220. ((FLAG) == DCMI_FLAG_LINERI) || \
  221. ((FLAG) == DCMI_FLAG_FRAMEMI) || \
  222. ((FLAG) == DCMI_FLAG_OVFMI) || \
  223. ((FLAG) == DCMI_FLAG_ERRMI) || \
  224. ((FLAG) == DCMI_FLAG_VSYNCMI) || \
  225. ((FLAG) == DCMI_FLAG_LINEMI))
  226. #define IS_DCMI_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFE0) == 0x0000) && ((FLAG) != 0x0000))
  227. /**
  228. * @}
  229. */
  230. /**
  231. * @}
  232. */
  233. /* Exported macro ------------------------------------------------------------*/
  234. /* Exported functions --------------------------------------------------------*/
  235. /* Function used to set the DCMI configuration to the default reset state ****/
  236. void DCMI_DeInit(void);
  237. /* Initialization and Configuration functions *********************************/
  238. void DCMI_Init(DCMI_InitTypeDef* DCMI_InitStruct);
  239. void DCMI_StructInit(DCMI_InitTypeDef* DCMI_InitStruct);
  240. void DCMI_CROPConfig(DCMI_CROPInitTypeDef* DCMI_CROPInitStruct);
  241. void DCMI_CROPCmd(FunctionalState NewState);
  242. void DCMI_SetEmbeddedSynchroCodes(DCMI_CodesInitTypeDef* DCMI_CodesInitStruct);
  243. void DCMI_JPEGCmd(FunctionalState NewState);
  244. /* Image capture functions ****************************************************/
  245. void DCMI_Cmd(FunctionalState NewState);
  246. void DCMI_CaptureCmd(FunctionalState NewState);
  247. uint32_t DCMI_ReadData(void);
  248. /* Interrupts and flags management functions **********************************/
  249. void DCMI_ITConfig(uint16_t DCMI_IT, FunctionalState NewState);
  250. FlagStatus DCMI_GetFlagStatus(uint16_t DCMI_FLAG);
  251. void DCMI_ClearFlag(uint16_t DCMI_FLAG);
  252. ITStatus DCMI_GetITStatus(uint16_t DCMI_IT);
  253. void DCMI_ClearITPendingBit(uint16_t DCMI_IT);
  254. #ifdef __cplusplus
  255. }
  256. #endif
  257. #endif /*__STM32F4xx_DCMI_H */
  258. /**
  259. * @}
  260. */
  261. /**
  262. * @}
  263. */
  264. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/