ov2640_regs.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. /*
  2. * This file is part of the OpenMV project.
  3. * Copyright (c) 2013/2014 Ibrahim Abdelkader <i.abdalkader@gmail.com>
  4. * This work is licensed under the MIT license, see the file LICENSE for details.
  5. *
  6. * OV2640 register definitions.
  7. */
  8. #ifndef __REG_REGS_H__
  9. #define __REG_REGS_H__
  10. /* DSP register bank FF=0x00*/
  11. #define R_BYPASS 0x05
  12. #define QS 0x44
  13. #define CTRLI 0x50
  14. #define HSIZE 0x51
  15. #define VSIZE 0x52
  16. #define XOFFL 0x53
  17. #define YOFFL 0x54
  18. #define VHYX 0x55
  19. #define DPRP 0x56
  20. #define TEST 0x57
  21. #define ZMOW 0x5A
  22. #define ZMOH 0x5B
  23. #define ZMHH 0x5C
  24. #define BPADDR 0x7C
  25. #define BPDATA 0x7D
  26. #define CTRL2 0x86
  27. #define CTRL3 0x87
  28. #define SIZEL 0x8C
  29. #define HSIZE8 0xC0
  30. #define VSIZE8 0xC1
  31. #define CTRL0 0xC2
  32. #define CTRL1 0xC3
  33. #define R_DVP_SP 0xD3
  34. #define IMAGE_MODE 0xDA
  35. #define RESET 0xE0
  36. #define MS_SP 0xF0
  37. #define SS_ID 0xF7
  38. #define SS_CTRL 0xF7
  39. #define MC_BIST 0xF9
  40. #define MC_AL 0xFA
  41. #define MC_AH 0xFB
  42. #define MC_D 0xFC
  43. #define P_CMD 0xFD
  44. #define P_STATUS 0xFE
  45. #define BANK_SEL 0xFF
  46. #define CTRLI_LP_DP 0x80
  47. #define CTRLI_ROUND 0x40
  48. #define CTRL0_AEC_EN 0x80
  49. #define CTRL0_AEC_SEL 0x40
  50. #define CTRL0_STAT_SEL 0x20
  51. #define CTRL0_VFIRST 0x10
  52. #define CTRL0_YUV422 0x08
  53. #define CTRL0_YUV_EN 0x04
  54. #define CTRL0_RGB_EN 0x02
  55. #define CTRL0_RAW_EN 0x01
  56. #define CTRL2_DCW_EN 0x20
  57. #define CTRL2_SDE_EN 0x10
  58. #define CTRL2_UV_ADJ_EN 0x08
  59. #define CTRL2_UV_AVG_EN 0x04
  60. #define CTRL2_CMX_EN 0x01
  61. #define CTRL3_BPC_EN 0x80
  62. #define CTRL3_WPC_EN 0x40
  63. #define R_DVP_SP_AUTO_MODE 0x80
  64. #define R_BYPASS_DSP_EN 0x00
  65. #define R_BYPASS_DSP_BYPAS 0x01
  66. #define IMAGE_MODE_Y8_DVP_EN 0x40
  67. #define IMAGE_MODE_JPEG_EN 0x10
  68. #define IMAGE_MODE_YUV422 0x00
  69. #define IMAGE_MODE_RAW10 0x04
  70. #define IMAGE_MODE_RGB565 0x08
  71. #define IMAGE_MODE_HREF_VSYNC 0x02
  72. #define IMAGE_MODE_LBYTE_FIRST 0x01
  73. #define RESET_MICROC 0x40
  74. #define RESET_SCCB 0x20
  75. #define RESET_JPEG 0x10
  76. #define RESET_DVP 0x04
  77. #define RESET_IPU 0x02
  78. #define RESET_CIF 0x01
  79. #define MC_BIST_RESET 0x80
  80. #define MC_BIST_BOOT_ROM_SEL 0x40
  81. #define MC_BIST_12KB_SEL 0x20
  82. #define MC_BIST_12KB_MASK 0x30
  83. #define MC_BIST_512KB_SEL 0x08
  84. #define MC_BIST_512KB_MASK 0x0C
  85. #define MC_BIST_BUSY_BIT_R 0x02
  86. #define MC_BIST_MC_RES_ONE_SH_W 0x02
  87. #define MC_BIST_LAUNCH 0x01
  88. typedef enum {
  89. BANK_DSP, BANK_SENSOR, BANK_MAX
  90. } ov2640_bank_t;
  91. /* Sensor register bank FF=0x01*/
  92. #define GAIN 0x00
  93. #define COM1 0x03
  94. #define REG04 0x04
  95. #define REG08 0x08
  96. #define COM2 0x09
  97. #define REG_PID 0x0A
  98. #define REG_VER 0x0B
  99. #define COM3 0x0C
  100. #define COM4 0x0D
  101. #define AEC 0x10
  102. #define CLKRC 0x11
  103. #define COM7 0x12
  104. #define COM8 0x13
  105. #define COM9 0x14 /* AGC gain ceiling */
  106. #define COM10 0x15
  107. #define HSTART 0x17
  108. #define HSTOP 0x18
  109. #define VSTART 0x19
  110. #define VSTOP 0x1A
  111. #define REG_MIDH 0x1C
  112. #define REG_MIDL 0x1D
  113. #define AEW 0x24
  114. #define AEB 0x25
  115. #define VV 0x26
  116. #define REG2A 0x2A
  117. #define FRARL 0x2B
  118. #define ADDVSL 0x2D
  119. #define ADDVSH 0x2E
  120. #define YAVG 0x2F
  121. #define HSDY 0x30
  122. #define HEDY 0x31
  123. #define REG32 0x32
  124. #define ARCOM2 0x34
  125. #define REG45 0x45
  126. #define FLL 0x46
  127. #define FLH 0x47
  128. #define COM19 0x48
  129. #define ZOOMS 0x49
  130. #define COM22 0x4B
  131. #define COM25 0x4E
  132. #define BD50 0x4F
  133. #define BD60 0x50
  134. #define REG5D 0x5D
  135. #define REG5E 0x5E
  136. #define REG5F 0x5F
  137. #define REG60 0x60
  138. #define HISTO_LOW 0x61
  139. #define HISTO_HIGH 0x62
  140. #define REG04_DEFAULT 0x28
  141. #define REG04_HFLIP_IMG 0x80
  142. #define REG04_VFLIP_IMG 0x40
  143. #define REG04_VREF_EN 0x10
  144. #define REG04_HREF_EN 0x08
  145. #define REG04_SET(x) (REG04_DEFAULT|x)
  146. #define COM2_STDBY 0x10
  147. #define COM2_OUT_DRIVE_1x 0x00
  148. #define COM2_OUT_DRIVE_2x 0x01
  149. #define COM2_OUT_DRIVE_3x 0x02
  150. #define COM2_OUT_DRIVE_4x 0x03
  151. #define COM3_DEFAULT 0x38
  152. #define COM3_BAND_50Hz 0x04
  153. #define COM3_BAND_60Hz 0x00
  154. #define COM3_BAND_AUTO 0x02
  155. #define COM3_BAND_SET(x) (COM3_DEFAULT|x)
  156. #define COM7_SRST 0x80
  157. #define COM7_RES_UXGA 0x00 /* UXGA */
  158. #define COM7_RES_SVGA 0x40 /* SVGA */
  159. #define COM7_RES_CIF 0x20 /* CIF */
  160. #define COM7_ZOOM_EN 0x04 /* Enable Zoom */
  161. #define COM7_COLOR_BAR 0x02 /* Enable Color Bar Test */
  162. #define COM8_DEFAULT 0xC0
  163. #define COM8_BNDF_EN 0x20 /* Enable Banding filter */
  164. #define COM8_AGC_EN 0x04 /* AGC Auto/Manual control selection */
  165. #define COM8_AEC_EN 0x01 /* Auto/Manual Exposure control */
  166. #define COM8_SET(x) (COM8_DEFAULT|x)
  167. #define COM9_DEFAULT 0x08
  168. #define COM9_AGC_GAIN_2x 0x00 /* AGC: 2x */
  169. #define COM9_AGC_GAIN_4x 0x01 /* AGC: 4x */
  170. #define COM9_AGC_GAIN_8x 0x02 /* AGC: 8x */
  171. #define COM9_AGC_GAIN_16x 0x03 /* AGC: 16x */
  172. #define COM9_AGC_GAIN_32x 0x04 /* AGC: 32x */
  173. #define COM9_AGC_GAIN_64x 0x05 /* AGC: 64x */
  174. #define COM9_AGC_GAIN_128x 0x06 /* AGC: 128x */
  175. #define COM9_AGC_SET(x) (COM9_DEFAULT|(x<<5))
  176. #define COM10_HREF_EN 0x80 /* HSYNC changes to HREF */
  177. #define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */
  178. #define COM10_PCLK_FREE 0x20 /* PCLK output option: free running PCLK */
  179. #define COM10_PCLK_EDGE 0x10 /* Data is updated at the rising edge of PCLK */
  180. #define COM10_HREF_NEG 0x08 /* HREF negative */
  181. #define COM10_VSYNC_NEG 0x02 /* VSYNC negative */
  182. #define COM10_HSYNC_NEG 0x01 /* HSYNC negative */
  183. #define CTRL1_AWB 0x08 /* Enable AWB */
  184. #define VV_AGC_TH_SET(h,l) ((h<<4)|(l&0x0F))
  185. #define REG32_UXGA 0x36
  186. #define REG32_SVGA 0x09
  187. #define REG32_CIF 0x89
  188. #define CLKRC_2X 0x80
  189. #define CLKRC_2X_UXGA (0x01 | CLKRC_2X)
  190. #define CLKRC_2X_SVGA CLKRC_2X
  191. #define CLKRC_2X_CIF CLKRC_2X
  192. #endif //__REG_REGS_H__