OV5640摄像头初始化

// system registers
write_i2c(0x3035, 0x11); // pll, System clock divider 1, Scale divider 1, default value
write_i2c(0x3036, 0x54); // pll multiplier
write_i2c(0x3c07, 0x07); // light meter 1 threshold, root divider and pre-divider
write_i2c(0x3820, 0x41); // ISP flip off, sensor flip off
write_i2c(0x3821, 0x07); // ISP mirror on, sensor mirror on, horizontal binning enable
// timing  时序
write_i2c(0x3814, 0x31); // X inc
write_i2c(0x3815, 0x31); // Y inc
write_i2c(0x3803, 0xfa); // VS 0xfa=250
write_i2c(0x3806, 0x06); // VH
write_i2c(0x3807, 0xa9); // VH 0x6a9 = 1705
write_i2c(0x3808, 0x05); // DVPHO
write_i2c(0x3809, 0x00); // DVPHO 0x500 = 1280
write_i2c(0x380a, 0x02); // DVPVO
write_i2c(0x380b, 0xd0); // DVPVO 0x2d0 = 720
write_i2c(0x380c, 0x07); // HTS
write_i2c(0x380d, 0x64); // HTS 0x764 = 1892
write_i2c(0x380e, 0x02); // VTS
write_i2c(0x380f, 0xe4); // VTS 0x2e4 = 740
write_i2c(0x3813, 0x04); // V offset
// not found in datasheet
write_i2c(0x3618, 0x00);
write_i2c(0x3612, 0x29);
write_i2c(0x3709, 0x52);
write_i2c(0x370c, 0x03);
// banding filter  去除灯光条纹
write_i2c(0x3a02, 0x02); // 60Hz max exposure
write_i2c(0x3a03, 0xe4); // 60Hz max exposure
write_i2c(0x3a09, 0xbc); // B50 low
write_i2c(0x3a0a, 0x01); // B60 high
write_i2c(0x3a0b, 0x72); // B60 low
write_i2c(0x3a0e, 0x01); // B50 max
write_i2c(0x3a0d, 0x02); // B60 max
write_i2c(0x3a14, 0x02); // 50Hz max exposure
write_i2c(0x3a15, 0xe4); // 50Hz max exposure
write_i2c(0x4004, 0x02); // BLC line number
write_i2c(0x4713, 0x02); // JPEG mode 2
write_i2c(0x460b, 0x37);
write_i2c(0x460c, 0x20); // VFIFO, PCLK auto
write_i2c(0x4837, 0x16); // MIPI global timing
write_i2c(0x3824, 0x04); // PCLK divider
write_i2c(0x5001, 0x83); // SDE on, scale off, UV average off, CMX on, AWB on

MIPI 数据流开启关闭:

write_i2c(0x4202,0x00); // 开启
write_i2c(0x4202,0x0F); // 关闭

输出时序:

// Y U Y V
write_i2c(0x4300,0x30);
// Y V Y U
write_i2c(0x4300,0x31);
// V Y U Y
write_i2c(0x4300,0x33);
// U Y V Y
write_i2c(0x4300,0x32);

测试图案:

// color bar
write_i2c(0x503d,0x80);
write_i2c(0x4741,0x00);
// Color square
write_i2c(0x503d,0x82);
write_i2c(0x4741,0x00);

本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议进行许可。

发表新评论