PicoCamera 0.2.0
Camera library for RP2040 with an esp32-camera compatible API
GitHub
Loading...
Searching...
No Matches
ov5640_settings.h
Go to the documentation of this file.
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
24#ifndef OV5640_SETTINGS_H
25#define OV5640_SETTINGS_H
26
27#include <stdint.h>
28
29#include "ov5640_regs.h"
30
31#define REG_DLY 0xFFFE // delay marker, value = milliseconds
32#define REGLIST_TAIL 0xFFFF // list terminator
33
34typedef struct {
35 uint16_t max_width;
36 uint16_t max_height;
37 uint16_t start_x;
38 uint16_t start_y;
39 uint16_t end_x;
40 uint16_t end_y;
41 uint16_t offset_x;
42 uint16_t offset_y;
43 uint16_t total_x;
44 uint16_t total_y;
46
47static const ratio_settings_t ratio_table[] = {
48 // mw, mh, sx, sy, ex, ey, ox, oy, tx, ty
49 { 2560, 1920, 0, 0, 2623, 1951, 32, 16, 2844, 1968 }, //4x3
50 { 2560, 1704, 0, 110, 2623, 1843, 32, 16, 2844, 1752 }, //3x2
51 { 2560, 1600, 0, 160, 2623, 1791, 32, 16, 2844, 1648 }, //16x10
52 { 2560, 1536, 0, 192, 2623, 1759, 32, 16, 2844, 1584 }, //5x3
53 { 2560, 1440, 0, 240, 2623, 1711, 32, 16, 2844, 1488 }, //16x9
54 { 2560, 1080, 0, 420, 2623, 1531, 32, 16, 2844, 1128 }, //21x9
55 { 2400, 1920, 80, 0, 2543, 1951, 32, 16, 2684, 1968 }, //5x4
56 { 1920, 1920, 320, 0, 2543, 1951, 32, 16, 2684, 1968 }, //1x1
57 { 1088, 1920, 736, 0, 1887, 1951, 32, 16, 1884, 1968 } //9x16
58};
59
60static const uint16_t ov5640_settings_default[][2] = {
61 {SYSTEM_CTROL0, 0x82}, // software reset
62 {REG_DLY, 10}, // delay 10ms
63 {SYSTEM_CTROL0, 0x42}, // power down
64
65 //enable pll
66 {0x3103, 0x13},
67
68 //io direction
69 {0x3017, 0xff},
70 {0x3018, 0xff},
71
72 {DRIVE_CAPABILITY, 0xc3},
73 {CLOCK_POL_CONTROL, 0x21},
74
75 {0x4713, 0x02},//jpg mode select
76
77 {ISP_CONTROL_01, 0x83}, // turn color matrix, awb and SDE
78
79 //sys reset
80 {0x3000, 0x20}, // reset MCU
81 {REG_DLY, 10}, // delay 10ms
82 {0x3002, 0x1c},
83
84 //clock enable
85 {0x3004, 0xff},
86 {0x3006, 0xc3},
87
88 //isp control
89 {0x5000, 0xa7},
90 {ISP_CONTROL_01, 0xa3},//+scaling?
91 {0x5003, 0x08},//special_effect
92
93 //unknown
94 {0x370c, 0x02},
95 {0x3634, 0x40},
96
97 //AEC/AGC
98 {0x3a02, 0x03},
99 {0x3a03, 0xd8},
100 {0x3a08, 0x01},
101 {0x3a09, 0x27},
102 {0x3a0a, 0x00},
103 {0x3a0b, 0xf6},
104 {0x3a0d, 0x04},
105 {0x3a0e, 0x03},
106 {0x3a0f, 0x30},//ae_level
107 {0x3a10, 0x28},//ae_level
108 {0x3a11, 0x60},//ae_level
109 {0x3a13, 0x43},
110 {0x3a14, 0x03},
111 {0x3a15, 0xd8},
112 {0x3a18, 0x00},//gainceiling
113 {0x3a19, 0xf8},//gainceiling
114 {0x3a1b, 0x30},//ae_level
115 {0x3a1e, 0x26},//ae_level
116 {0x3a1f, 0x14},//ae_level
117
118 //vcm debug
119 {0x3600, 0x08},
120 {0x3601, 0x33},
121
122 //50/60Hz
123 {0x3c01, 0xa4},
124 {0x3c04, 0x28},
125 {0x3c05, 0x98},
126 {0x3c06, 0x00},
127 {0x3c07, 0x08},
128 {0x3c08, 0x00},
129 {0x3c09, 0x1c},
130 {0x3c0a, 0x9c},
131 {0x3c0b, 0x40},
132
133 {0x460c, 0x22},//disable jpeg footer
134
135 //BLC
136 {0x4001, 0x02},
137 {0x4004, 0x02},
138
139 //AWB
140 {0x5180, 0xff},
141 {0x5181, 0xf2},
142 {0x5182, 0x00},
143 {0x5183, 0x14},
144 {0x5184, 0x25},
145 {0x5185, 0x24},
146 {0x5186, 0x09},
147 {0x5187, 0x09},
148 {0x5188, 0x09},
149 {0x5189, 0x75},
150 {0x518a, 0x54},
151 {0x518b, 0xe0},
152 {0x518c, 0xb2},
153 {0x518d, 0x42},
154 {0x518e, 0x3d},
155 {0x518f, 0x56},
156 {0x5190, 0x46},
157 {0x5191, 0xf8},
158 {0x5192, 0x04},
159 {0x5193, 0x70},
160 {0x5194, 0xf0},
161 {0x5195, 0xf0},
162 {0x5196, 0x03},
163 {0x5197, 0x01},
164 {0x5198, 0x04},
165 {0x5199, 0x12},
166 {0x519a, 0x04},
167 {0x519b, 0x00},
168 {0x519c, 0x06},
169 {0x519d, 0x82},
170 {0x519e, 0x38},
171
172 //color matrix (Saturation)
173 {0x5381, 0x1e},
174 {0x5382, 0x5b},
175 {0x5383, 0x08},
176 {0x5384, 0x0a},
177 {0x5385, 0x7e},
178 {0x5386, 0x88},
179 {0x5387, 0x7c},
180 {0x5388, 0x6c},
181 {0x5389, 0x10},
182 {0x538a, 0x01},
183 {0x538b, 0x98},
184
185 //CIP control (Sharpness)
186 {0x5300, 0x10},//sharpness
187 {0x5301, 0x10},//sharpness
188 {0x5302, 0x18},//sharpness
189 {0x5303, 0x19},//sharpness
190 {0x5304, 0x10},
191 {0x5305, 0x10},
192 {0x5306, 0x08},//denoise
193 {0x5307, 0x16},
194 {0x5308, 0x40},
195 {0x5309, 0x10},//sharpness
196 {0x530a, 0x10},//sharpness
197 {0x530b, 0x04},//sharpness
198 {0x530c, 0x06},//sharpness
199
200 //GAMMA
201 {0x5480, 0x01},
202 {0x5481, 0x00},
203 {0x5482, 0x1e},
204 {0x5483, 0x3b},
205 {0x5484, 0x58},
206 {0x5485, 0x66},
207 {0x5486, 0x71},
208 {0x5487, 0x7d},
209 {0x5488, 0x83},
210 {0x5489, 0x8f},
211 {0x548a, 0x98},
212 {0x548b, 0xa6},
213 {0x548c, 0xb8},
214 {0x548d, 0xca},
215 {0x548e, 0xd7},
216 {0x548f, 0xe3},
217 {0x5490, 0x1d},
218
219 //Special Digital Effects (SDE) (UV adjust)
220 {0x5580, 0x06},//enable brightness and contrast
221 {0x5583, 0x40},//special_effect
222 {0x5584, 0x10},//special_effect
223 {0x5586, 0x20},//contrast
224 {0x5587, 0x00},//brightness
225 {0x5588, 0x00},//brightness
226 {0x5589, 0x10},
227 {0x558a, 0x00},
228 {0x558b, 0xf8},
229 {0x501d, 0x40},// enable manual offset of contrast
230
231 //power on
232 {0x3008, 0x02},
233
234 //50Hz
235 {0x3c00, 0x04},
236
237 {REG_DLY, 300},
238 {REGLIST_TAIL, 0x00}, // tail
239};
240
241static const uint16_t ov5640_settings_jpeg[][2] = {
242 {FORMAT_CTRL, 0x00}, // YUV422
243 {FORMAT_CTRL00, 0x30}, // YUYV
244 {0x3002, 0x00},//0x1c to 0x00 !!!
245 {0x3006, 0xff},//0xc3 to 0xff !!!
246 {0x471c, 0x50},//0xd0 to 0x50 !!!
247 {REGLIST_TAIL, 0x00}, // tail
248};
249
250static const uint16_t ov5640_settings_yuv422[][2] = {
251 {FORMAT_CTRL, 0x00}, // YUV422
252 {FORMAT_CTRL00, 0x30}, // YUYV
253 {REGLIST_TAIL, 0x00}
254};
255
256static const uint16_t ov5640_settings_rgb565[][2] = {
257 {FORMAT_CTRL, 0x01}, // RGB
258 {FORMAT_CTRL00, 0x61}, // RGB565 (BGR)
259 {REGLIST_TAIL, 0x00}
260};
261
262#endif // OV5640_SETTINGS_H
OV5640 register definitions (16-bit addresses).
Definition ov2640.cpp:28
中文文档