[@blueskycoco] [@saqula] [@zhengmeifu] [@HuaiShuShuV]
代码如下:
void OV5640_init(void)
{
long delay_time;
//15fps VGA YUV output
// 24MHz input clock, 24MHz PCLK
//software reset
sensor_write(0x3103, 0x11); // system clock from pad, bit[1]
sensor_write(0x3008, 0x82); // software reset, bit[7]
for(delay_time = 0; delay_time < 0x4FFFD; delay_time++)
asm("nop;");//复位需要延时5ms
sensor_write(0x3008, 0x42); // software power down, bit[6]
sensor_write(0x3103, 0x03); // system clock from PLL, bit[1]
sensor_write(0x3017, 0xff); // FREX, Vsync, HREF, PCLK, D[9:6] output enable
sensor_write(0x3018, 0xff); // D[5:0], GPIO[1:0] output enable
sensor_write(0x3034, 0x1a); // MIPI 10-bit
sensor_write(0x3037, 0x13); // PLL root divider, bit[4], PLL pre-divider, bit[3:0]
sensor_write(0x3108, 0x01); // PCLK root divider, bit[5:4], SCLK2x root divider, bit[3:2]
// SCLK root divider, bit[1:0]
sensor_write(0x3630, 0x36);
sensor_write(0x3631, 0x0e);
sensor_write(0x3632, 0xe2);
sensor_write(0x3633, 0x12);
sensor_write(0x3621, 0xe0);
sensor_write(0x3704, 0xa0);
sensor_write(0x3703, 0x5a);
sensor_write(0x3715, 0x78);
sensor_write(0x3717, 0x01);
sensor_write(0x370b, 0x60);
sensor_write(0x3705, 0x1a);
sensor_write(0x3905, 0x02);
sensor_write(0x3906, 0x10);
sensor_write(0x3901, 0x0a);
sensor_write(0x3731, 0x12);
sensor_write(0x3600, 0x08); // VCM control
sensor_write(0x3601, 0x33); // VCM control
sensor_write(0x302d, 0x60); // system control
sensor_write(0x3620, 0x52);
sensor_write(0x371b, 0x20);
sensor_write(0x471c, 0x50);
sensor_write(0x3a13, 0x43); // pre-gain = 1.047x
sensor_write(0x3a18, 0x00); // gain ceiling
sensor_write(0x3a19, 0xf8); // gain ceiling = 15.5x
sensor_write(0x3635, 0x13);
sensor_write(0x3636, 0x03);
sensor_write(0x3634, 0x40);
sensor_write(0x3622, 0x01);
// 50/60Hz detection 50/60Hz 灯光条纹过滤