PicoCamera 0.2.0
Camera library for RP2040 with an esp32-camera compatible API
GitHub
载入中...
搜索中...
未找到
ov5640_regs.h
浏览该文件的文档.
1/*
2 * This file is part of the PicoCamera project.
3 * https://github.com/umeiko/PicoCamera
4 *
5 * Author: umeko <umeko@stu.xmu.edu.cn>
6 * License: MIT
7 */
8
17#ifndef __OV5640_REGS_H__
18#define __OV5640_REGS_H__
19
20/* product ID registers */
21#define REG_PIDH 0x300A // Product ID high byte (0x56)
22#define REG_PIDL 0x300B // Product ID low byte (0x40)
23
24/* system control registers */
25#define SYSTEM_CTROL0 0x3008 // Bit[7]: Software reset
26 // Bit[6]: Software power down
27 // Bit[5]: Reserved
28 // Bit[4]: SRB clock SYNC enable
29 // Bit[3]: Isolation suspend select
30 // Bit[2:0]: Not used
31
32#define DRIVE_CAPABILITY 0x302c // Bit[7:6]:
33 // 00: 1x
34 // 01: 2x
35 // 10: 3x
36 // 11: 4x
37
38/* PLL registers (OV5640 set_pll uses these, not the SC_PLLS_CTRLx below) */
39#define SC_PLL_CTRL0 0x3034 // Bit[6:4]: PLL charge pump, Bit[3:0]: MIPI bit mode
40#define SC_PLL_CTRL1 0x3035 // Bit[7:4]: system divider, Bit[3:0]: scale divider MIPI
41#define SC_PLL_CTRL2 0x3036 // Bit[7:0]: PLL multiplier (4-252, even above 127)
42#define SC_PLL_CTRL3 0x3037 // Bit[4]: PLL root divider /2, Bit[3:0]: PLL pre-divider
43 // 1,2,3,4,6,8
44#define SC_PLL_BYPASS 0x3039 // Bit[7]: PLL bypass
45#define SC_PLL_CLK_SEL 0x3103 // Bit[1]: system clock from PLL
46#define PCLK_PERIOD 0x3108 // Bit[5:4]: PCLK root divider, Bit[3:0]: SCLK2x root divider
47
48#define SC_PLLS_CTRL0 0x303a // Bit[7]: PLLS bypass
49#define SC_PLLS_CTRL1 0x303b // Bit[4:0]: PLLS multiplier
50#define SC_PLLS_CTRL2 0x303c // Bit[6:4]: PLLS charge pump control
51 // Bit[3:0]: PLLS system divider
52#define SC_PLLS_CTRL3 0x303d // Bit[5:4]: PLLS pre-divider
53 // 00: 1
54 // 01: 1.5
55 // 10: 2
56 // 11: 3
57 // Bit[2]: PLLS root-divider - 1
58 // Bit[1:0]: PLLS seld5
59 // 00: 1
60 // 01: 1
61 // 10: 2
62 // 11: 2.5
63
64/* AEC/AGC control functions */
65#define AEC_PK_MANUAL 0x3503 // AEC Manual Mode Control
66 // Bit[7:6]: Reserved
67 // Bit[5]: Gain delay option
68 // Valid when 0x3503[4]=1’b0
69 // 0: Delay one frame latch
70 // 1: One frame latch
71 // Bit[4:2]: Reserved
72 // Bit[1]: AGC manual
73 // 0: Auto enable
74 // 1: Manual enable
75 // Bit[0]: AEC manual
76 // 0: Auto enable
77 // 1: Manual enable
78
79//gain = {0x350A[1:0], 0x350B[7:0]} / 16
80
81
82#define X_ADDR_ST_H 0x3800 //Bit[3:0]: X address start[11:8]
83#define X_ADDR_ST_L 0x3801 //Bit[7:0]: X address start[7:0]
84#define Y_ADDR_ST_H 0x3802 //Bit[2:0]: Y address start[10:8]
85#define Y_ADDR_ST_L 0x3803 //Bit[7:0]: Y address start[7:0]
86#define X_ADDR_END_H 0x3804 //Bit[3:0]: X address end[11:8]
87#define X_ADDR_END_L 0x3805 //Bit[7:0]:
88#define Y_ADDR_END_H 0x3806 //Bit[2:0]: Y address end[10:8]
89#define Y_ADDR_END_L 0x3807 //Bit[7:0]:
90// Size after scaling
91#define X_OUTPUT_SIZE_H 0x3808 //Bit[3:0]: DVP output horizontal width[11:8]
92#define X_OUTPUT_SIZE_L 0x3809 //Bit[7:0]:
93#define Y_OUTPUT_SIZE_H 0x380a //Bit[2:0]: DVP output vertical height[10:8]
94#define Y_OUTPUT_SIZE_L 0x380b //Bit[7:0]:
95#define X_TOTAL_SIZE_H 0x380c //Bit[3:0]: Total horizontal size[11:8]
96#define X_TOTAL_SIZE_L 0x380d //Bit[7:0]:
97#define Y_TOTAL_SIZE_H 0x380e //Bit[7:0]: Total vertical size[15:8]
98#define Y_TOTAL_SIZE_L 0x380f //Bit[7:0]:
99#define X_OFFSET_H 0x3810 //Bit[3:0]: ISP horizontal offset[11:8]
100#define X_OFFSET_L 0x3811 //Bit[7:0]:
101#define Y_OFFSET_H 0x3812 //Bit[2:0]: ISP vertical offset[10:8]
102#define Y_OFFSET_L 0x3813 //Bit[7:0]:
103#define X_INCREMENT 0x3814 //Bit[7:4]: Horizontal odd subsample increment
104 //Bit[3:0]: Horizontal even subsample increment
105#define Y_INCREMENT 0x3815 //Bit[7:4]: Vertical odd subsample increment
106 //Bit[3:0]: Vertical even subsample increment
107// Size before scaling
108//#define X_INPUT_SIZE (X_ADDR_END - X_ADDR_ST + 1 - (2 * X_OFFSET))
109//#define Y_INPUT_SIZE (Y_ADDR_END - Y_ADDR_ST + 1 - (2 * Y_OFFSET))
110
111/* mirror and flip registers */
112#define TIMING_TC_REG20 0x3820 // Timing Control Register
113 // Bit[2:1]: Vertical flip enable
114 // 00: Normal
115 // 11: Vertical flip
116 // Bit[0]: Vertical binning enable
117#define TIMING_TC_REG21 0x3821 // Timing Control Register
118 // Bit[5]: Compression Enable
119 // Bit[2:1]: Horizontal mirror enable
120 // 00: Normal
121 // 11: Horizontal mirror
122 // Bit[0]: Horizontal binning enable
123
124#define PCLK_RATIO 0x3824 // Bit[4:0]: PCLK ratio manual
125
126/* frame control registers */
127#define FRAME_CTRL01 0x4201 // Control Passed Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode
128 // Bit[7:4]: Not used
129 // Bit[3:0]: Frame ON number
130#define FRAME_CTRL02 0x4202 // Control Masked Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode
131 // Bit[7:4]: Not used
132 // BIT[3:0]: Frame OFF number
133
134/* format control registers */
135#define FORMAT_CTRL00 0x4300
136
137#define CLOCK_POL_CONTROL 0x4740// Bit[5]: PCLK polarity 0: active low
138 // 1: active high
139 // Bit[3]: Gate PCLK under VSYNC
140 // Bit[2]: Gate PCLK under HREF
141 // Bit[1]: HREF polarity
142 // 0: active low
143 // 1: active high
144 // Bit[0] VSYNC polarity
145 // 0: active low
146 // 1: active high
147
148#define ISP_CONTROL_01 0x5001 // Bit[5]: Scale enable
149 // 0: Disable
150 // 1: Enable
151
152/* output format control registers */
153#define FORMAT_CTRL 0x501F // Format select
154 // Bit[2:0]:
155 // 000: YUV422
156 // 001: RGB
157 // 010: Dither
158 // 011: RAW after DPC
159 // 101: RAW after CIP
160
161/* ISP top control registers */
162#define PRE_ISP_TEST_SETTING_1 0x503D // Bit[7]: Test enable
163 // 0: Test disable
164 // 1: Color bar enable
165 // Bit[6]: Rolling
166 // Bit[5]: Transparent
167 // Bit[4]: Square black and white
168 // Bit[3:2]: Color bar style
169 // 00: Standard 8 color bar
170 // 01: Gradual change at vertical mode 1
171 // 10: Gradual change at horizontal
172 // 11: Gradual change at vertical mode 2
173 // Bit[1:0]: Test select
174 // 00: Color bar
175 // 01: Random data
176 // 10: Square data
177 // 11: Black image
178
179//exposure = {0x3500[3:0], 0x3501[7:0], 0x3502[7:0]} / 16 × tROW
180
181#define SCALE_CTRL_1 0x5601 // Bit[6:4]: HDIV RW
182 // DCW scale times
183 // 000: DCW 1 time
184 // 001: DCW 2 times
185 // 010: DCW 4 times
186 // 100: DCW 8 times
187 // 101: DCW 16 times
188 // Others: DCW 16 times
189 // Bit[2:0]: VDIV RW
190 // DCW scale times
191 // 000: DCW 1 time
192 // 001: DCW 2 times
193 // 010: DCW 4 times
194 // 100: DCW 8 times
195 // 101: DCW 16 times
196 // Others: DCW 16 times
197
198#define SCALE_CTRL_2 0x5602 // X_SCALE High Bits
199#define SCALE_CTRL_3 0x5603 // X_SCALE Low Bits
200#define SCALE_CTRL_4 0x5604 // Y_SCALE High Bits
201#define SCALE_CTRL_5 0x5605 // Y_SCALE Low Bits
202#define SCALE_CTRL_6 0x5606 // Bit[3:0]: V Offset
203
204#define VFIFO_CTRL0C 0x460C // Bit[1]: PCLK manual enable
205 // 0: Auto
206 // 1: Manual by PCLK_RATIO
207
208#define VFIFO_X_SIZE_H 0x4602
209#define VFIFO_X_SIZE_L 0x4603
210#define VFIFO_Y_SIZE_H 0x4604
211#define VFIFO_Y_SIZE_L 0x4605
212
213#define COMPRESSION_CTRL00 0x4400 //
214#define COMPRESSION_CTRL01 0x4401 //
215#define COMPRESSION_CTRL02 0x4402 //
216#define COMPRESSION_CTRL03 0x4403 //
217#define COMPRESSION_CTRL04 0x4404 //
218#define COMPRESSION_CTRL05 0x4405 //
219#define COMPRESSION_CTRL06 0x4406 //
220#define COMPRESSION_CTRL07 0x4407 // Bit[5:0]: QS
221#define COMPRESSION_ISI_CTRL 0x4408 //
222#define COMPRESSION_CTRL09 0x4409 //
223#define COMPRESSION_CTRL0a 0x440a //
224#define COMPRESSION_CTRL0b 0x440b //
225#define COMPRESSION_CTRL0c 0x440c //
226#define COMPRESSION_CTRL0d 0x440d //
227#define COMPRESSION_CTRL0E 0x440e //
228
232#define TEST_COLOR_BAR 0xC0 /* Enable Color Bar roling Test */
233
234#define AEC_PK_MANUAL_AGC_MANUALEN 0x02 /* Enable AGC Manual enable */
235#define AEC_PK_MANUAL_AEC_MANUALEN 0x01 /* Enable AEC Manual enable */
236
237#define TIMING_TC_REG20_VFLIP 0x06 /* Vertical flip enable */
238#define TIMING_TC_REG21_HMIRROR 0x06 /* Horizontal mirror enable */
239
240#endif // __OV5640_REGS_H__
English version