stm32f4xx_dcmi.h 13 KB

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