ov2640.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /**
  2. ******************************************************************************
  3. * @file ov2640.h
  4. * @author MCD Application Team
  5. * @version V1.0.2
  6. * @date 02-December-2014
  7. * @brief This file contains all the functions prototypes for the ov2640.c
  8. * driver.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  13. *
  14. * Redistribution and use in source and binary forms, with or without modification,
  15. * are permitted provided that the following conditions are met:
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************
  37. */
  38. /* Define to prevent recursive inclusion -------------------------------------*/
  39. #ifndef __OV2640_H
  40. #define __OV2640_H
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "../Common/camera.h"
  46. /** @addtogroup BSP
  47. * @{
  48. */
  49. /** @addtogroup Components
  50. * @{
  51. */
  52. /** @addtogroup ov2640
  53. * @{
  54. */
  55. /** @defgroup OV2640_Exported_Types
  56. * @{
  57. */
  58. /**
  59. * @}
  60. */
  61. /** @defgroup OV2640_Exported_Constants
  62. * @{
  63. */
  64. /**
  65. * @brief OV2640 ID
  66. */
  67. #define OV2640_ID 0x26
  68. /**
  69. * @brief OV2640 Registers
  70. */
  71. /* OV2640 Registers definition when DSP bank selected (0xFF = 0x00) */
  72. #define OV2640_DSP_R_BYPASS 0x05
  73. #define OV2640_DSP_Qs 0x44
  74. #define OV2640_DSP_CTRL 0x50
  75. #define OV2640_DSP_HSIZE1 0x51
  76. #define OV2640_DSP_VSIZE1 0x52
  77. #define OV2640_DSP_XOFFL 0x53
  78. #define OV2640_DSP_YOFFL 0x54
  79. #define OV2640_DSP_VHYX 0x55
  80. #define OV2640_DSP_DPRP 0x56
  81. #define OV2640_DSP_TEST 0x57
  82. #define OV2640_DSP_ZMOW 0x5A
  83. #define OV2640_DSP_ZMOH 0x5B
  84. #define OV2640_DSP_ZMHH 0x5C
  85. #define OV2640_DSP_BPADDR 0x7C
  86. #define OV2640_DSP_BPDATA 0x7D
  87. #define OV2640_DSP_CTRL2 0x86
  88. #define OV2640_DSP_CTRL3 0x87
  89. #define OV2640_DSP_SIZEL 0x8C
  90. #define OV2640_DSP_HSIZE2 0xC0
  91. #define OV2640_DSP_VSIZE2 0xC1
  92. #define OV2640_DSP_CTRL0 0xC2
  93. #define OV2640_DSP_CTRL1 0xC3
  94. #define OV2640_DSP_R_DVP_SP 0xD3
  95. #define OV2640_DSP_IMAGE_MODE 0xDA
  96. #define OV2640_DSP_RESET 0xE0
  97. #define OV2640_DSP_MS_SP 0xF0
  98. #define OV2640_DSP_SS_ID 0x7F
  99. #define OV2640_DSP_SS_CTRL 0xF8
  100. #define OV2640_DSP_MC_BIST 0xF9
  101. #define OV2640_DSP_MC_AL 0xFA
  102. #define OV2640_DSP_MC_AH 0xFB
  103. #define OV2640_DSP_MC_D 0xFC
  104. #define OV2640_DSP_P_STATUS 0xFE
  105. #define OV2640_DSP_RA_DLMT 0xFF
  106. /* OV2640 Registers definition when sensor bank selected (0xFF = 0x01) */
  107. #define OV2640_SENSOR_GAIN 0x00
  108. #define OV2640_SENSOR_COM1 0x03
  109. #define OV2640_SENSOR_REG04 0x04
  110. #define OV2640_SENSOR_REG08 0x08
  111. #define OV2640_SENSOR_COM2 0x09
  112. #define OV2640_SENSOR_PIDH 0x0A
  113. #define OV2640_SENSOR_PIDL 0x0B
  114. #define OV2640_SENSOR_COM3 0x0C
  115. #define OV2640_SENSOR_COM4 0x0D
  116. #define OV2640_SENSOR_AEC 0x10
  117. #define OV2640_SENSOR_CLKRC 0x11
  118. #define OV2640_SENSOR_COM7 0x12
  119. #define OV2640_SENSOR_COM8 0x13
  120. #define OV2640_SENSOR_COM9 0x14
  121. #define OV2640_SENSOR_COM10 0x15
  122. #define OV2640_SENSOR_HREFST 0x17
  123. #define OV2640_SENSOR_HREFEND 0x18
  124. #define OV2640_SENSOR_VSTART 0x19
  125. #define OV2640_SENSOR_VEND 0x1A
  126. #define OV2640_SENSOR_MIDH 0x1C
  127. #define OV2640_SENSOR_MIDL 0x1D
  128. #define OV2640_SENSOR_AEW 0x24
  129. #define OV2640_SENSOR_AEB 0x25
  130. #define OV2640_SENSOR_W 0x26
  131. #define OV2640_SENSOR_REG2A 0x2A
  132. #define OV2640_SENSOR_FRARL 0x2B
  133. #define OV2640_SENSOR_ADDVSL 0x2D
  134. #define OV2640_SENSOR_ADDVHS 0x2E
  135. #define OV2640_SENSOR_YAVG 0x2F
  136. #define OV2640_SENSOR_REG32 0x32
  137. #define OV2640_SENSOR_ARCOM2 0x34
  138. #define OV2640_SENSOR_REG45 0x45
  139. #define OV2640_SENSOR_FLL 0x46
  140. #define OV2640_SENSOR_FLH 0x47
  141. #define OV2640_SENSOR_COM19 0x48
  142. #define OV2640_SENSOR_ZOOMS 0x49
  143. #define OV2640_SENSOR_COM22 0x4B
  144. #define OV2640_SENSOR_COM25 0x4E
  145. #define OV2640_SENSOR_BD50 0x4F
  146. #define OV2640_SENSOR_BD60 0x50
  147. #define OV2640_SENSOR_REG5D 0x5D
  148. #define OV2640_SENSOR_REG5E 0x5E
  149. #define OV2640_SENSOR_REG5F 0x5F
  150. #define OV2640_SENSOR_REG60 0x60
  151. #define OV2640_SENSOR_HISTO_LOW 0x61
  152. #define OV2640_SENSOR_HISTO_HIGH 0x62
  153. /**
  154. * @brief OV2640 Features Parameters
  155. */
  156. #define OV2640_BRIGHTNESS_LEVEL0 0x40 /* Brightness level -2 */
  157. #define OV2640_BRIGHTNESS_LEVEL1 0x30 /* Brightness level -1 */
  158. #define OV2640_BRIGHTNESS_LEVEL2 0x20 /* Brightness level 0 */
  159. #define OV2640_BRIGHTNESS_LEVEL3 0x10 /* Brightness level +1 */
  160. #define OV2640_BRIGHTNESS_LEVEL4 0x00 /* Brightness level +2 */
  161. #define OV2640_BLACK_WHITE_BW 0x18 /* Black and white effect */
  162. #define OV2640_BLACK_WHITE_NEGATIVE 0x40 /* Negative effect */
  163. #define OV2640_BLACK_WHITE_BW_NEGATIVE 0x58 /* BW and Negative effect */
  164. #define OV2640_BLACK_WHITE_NORMAL 0x00 /* Normal effect */
  165. #define OV2640_CONTRAST_LEVEL0 0x3418 /* Contrast level -2 */
  166. #define OV2640_CONTRAST_LEVEL1 0x2A1C /* Contrast level -2 */
  167. #define OV2640_CONTRAST_LEVEL2 0x2020 /* Contrast level -2 */
  168. #define OV2640_CONTRAST_LEVEL3 0x1624 /* Contrast level -2 */
  169. #define OV2640_CONTRAST_LEVEL4 0x0C28 /* Contrast level -2 */
  170. #define OV2640_COLOR_EFFECT_ANTIQUE 0xA640 /* Antique effect */
  171. #define OV2640_COLOR_EFFECT_BLUE 0x40A0 /* Blue effect */
  172. #define OV2640_COLOR_EFFECT_GREEN 0x4040 /* Green effect */
  173. #define OV2640_COLOR_EFFECT_RED 0xC040 /* Red effect */
  174. /**
  175. * @}
  176. */
  177. /** @defgroup OV2640_Exported_Functions
  178. * @{
  179. */
  180. void ov2640_Init(uint16_t DeviceAddr, uint32_t resolution);
  181. void ov2640_Config(uint16_t DeviceAddr, uint32_t feature, uint32_t value, uint32_t BR_value);
  182. uint16_t ov2640_ReadID(uint16_t DeviceAddr);
  183. void CAMERA_IO_Init(void);
  184. void CAMERA_IO_Write(uint8_t addr, uint8_t reg, uint8_t value);
  185. uint8_t CAMERA_IO_Read(uint8_t addr, uint8_t reg);
  186. void CAMERA_Delay(uint32_t delay);
  187. /* CAMERA driver structure */
  188. extern CAMERA_DrvTypeDef ov2640_drv;
  189. /**
  190. * @}
  191. */
  192. #ifdef __cplusplus
  193. }
  194. #endif
  195. #endif /* __OV2640_H */
  196. /**
  197. * @}
  198. */
  199. /**
  200. * @}
  201. */
  202. /**
  203. * @}
  204. */
  205. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/