OV5640:寄存器 自用
2023-12-23 19:21:05
正点原子:
//****************************************Copyright (c)***********************************//
//原子哥在线教学平台:www.yuanzige.com
//技术支持:www.openedv.com
//淘宝店铺:http://openedv.taobao.com
//关注微信公众平台微信号:"正点原子",免费获取ZYNQ & FPGA & STM32 & LINUX资料。
//版权所有,盗版必究。
//Copyright(C) 正点原子 2018-2028
//All rights reserved
//----------------------------------------------------------------------------------------
// File name: i2c_ov5640_rgb565_cfg
// Last modified Date: 2020/05/04 9:19:08
// Last Version: V1.0
// Descriptions: iic配置
//
//----------------------------------------------------------------------------------------
// Created by: 正点原子
// Created date: 2019/05/04 9:19:08
// Version: V1.0
// Descriptions: The original version
//
//----------------------------------------------------------------------------------------
//****************************************************************************************//
module i2c_ov5640_rgb565_cfg
(
input clk , //时钟信号
input rst_n , //复位信号,低电平有效
input [7:0] i2c_data_r, //I2C读出的数据
input i2c_done , //I2C寄存器配置完成信号
input [12:0] cmos_h_pixel ,
input [12:0] cmos_v_pixel ,
input [12:0] total_h_pixel, //水平总像素大小
input [12:0] total_v_pixel, //垂直总像素大小
output reg i2c_exec , //I2C触发执行信号
output reg [23:0] i2c_data , //I2C要配置的地址与数据(高16位地址,低8位数据)
output reg i2c_rh_wl, //I2C读写控制信号
output reg init_done //初始化完成信号
);
//parameter define
localparam REG_NUM = 8'd250 ; //总共需要配置的寄存器个数
//reg define
reg [12:0] start_init_cnt; //等待延时计数器
reg [7:0] init_reg_cnt ; //寄存器配置个数计数器
//*****************************************************
//** main code
//*****************************************************
//clk时钟配置成250khz,周期为4us 5000*4us = 20ms
//OV5640上电到开始配置IIC至少等待20ms
always @(posedge clk or negedge rst_n) begin
if(!rst_n)
start_init_cnt <= 13'b0;
else if(start_init_cnt < 13'd5000) begin
start_init_cnt <= start_init_cnt + 1'b1;
end
end
//寄存器配置个数计数
always @(posedge clk or negedge rst_n) begin
if(!rst_n)
init_reg_cnt <= 8'd0;
else if(i2c_exec)
init_reg_cnt <= init_reg_cnt + 8'b1;
end
//i2c触发执行信号
always @(posedge clk or negedge rst_n) begin
if(!rst_n)
i2c_exec <= 1'b0;
else if(start_init_cnt == 13'd4999)
i2c_exec <= 1'b1;
else if(i2c_done && (init_reg_cnt < REG_NUM))
i2c_exec <= 1'b1;
else
i2c_exec <= 1'b0;
end
//配置I2C读写控制信号
always @(posedge clk or negedge rst_n) begin
if(!rst_n)
i2c_rh_wl <= 1'b1;
else if(init_reg_cnt == 8'd2)
i2c_rh_wl <= 1'b0;
end
//初始化完成信号
always @(posedge clk or negedge rst_n) begin
if(!rst_n)
init_done <= 1'b0;
else if((init_reg_cnt == REG_NUM) && i2c_done)
init_done <= 1'b1;
end
//配置寄存器地址与数据
always @(posedge clk or negedge rst_n) begin
if(!rst_n)
i2c_data <= 24'b0;
else begin
case(init_reg_cnt)
//先对寄存器进行软件复位,使寄存器恢复初始值
//寄存器软件复位后,需要延时1ms才能配置其它寄存器
8'd0 : i2c_data <= {16'h300a,8'h0}; //
8'd1 : i2c_data <= {16'h300b,8'h0}; //
8'd2 : i2c_data <= {16'h3008,8'h82}; //Bit[7]:复位 Bit[6]:电源休眠
8'd3 : i2c_data <= {16'h3008,8'h02}; //正常工作模式
8'd4 : i2c_data <= {16'h3103,8'h02}; //Bit[1]:1 PLL Clock
//引脚输入/输出控制 FREX/VSYNC/HREF/PCLK/D[9:6]
8'd5 : i2c_data <= {8'h30,8'h17,8'hff};
//引脚输入/输出控制 D[5:0]/GPIO1/GPIO0
8'd6 : i2c_data <= {16'h3018,8'hff};
8'd7 : i2c_data <= {16'h3037,8'h13}; //PLL分频控制
8'd8 : i2c_data <= {16'h3108,8'h01}; //系统根分频器
8'd9 : i2c_data <= {16'h3630,8'h36};
8'd10 : i2c_data <= {16'h3631,8'h0e};
8'd11 : i2c_data <= {16'h3632,8'he2};
8'd12 : i2c_data <= {16'h3633,8'h12};
8'd13 : i2c_data <= {16'h3621,8'he0};
8'd14 : i2c_data <= {16'h3704,8'ha0};
8'd15 : i2c_data <= {16'h3703,8'h5a};
8'd16 : i2c_data <= {16'h3715,8'h78};
8'd17 : i2c_data <= {16'h3717,8'h01};
8'd18 : i2c_data <= {16'h370b,8'h60};
8'd19 : i2c_data <= {16'h3705,8'h1a};
8'd20 : i2c_data <= {16'h3905,8'h02};
8'd21 : i2c_data <= {16'h3906,8'h10};
8'd22 : i2c_data <= {16'h3901,8'h0a};
8'd23 : i2c_data <= {16'h3731,8'h12};
8'd24 : i2c_data <= {16'h3600,8'h08}; //VCM控制,用于自动聚焦
8'd25 : i2c_data <= {16'h3601,8'h33}; //VCM控制,用于自动聚焦
8'd26 : i2c_data <= {16'h302d,8'h60}; //系统控制
8'd27 : i2c_data <= {16'h3620,8'h52};
8'd28 : i2c_data <= {16'h371b,8'h20};
8'd29 : i2c_data <= {16'h471c,8'h50};
8'd30 : i2c_data <= {16'h3a13,8'h43}; //AEC(自动曝光控制)
8'd31 : i2c_data <= {16'h3a18,8'h00}; //AEC 增益上限
8'd32 : i2c_data <= {16'h3a19,8'hf8}; //AEC 增益上限
8'd33 : i2c_data <= {16'h3635,8'h13};
8'd34 : i2c_data <= {16'h3636,8'h03};
8'd35 : i2c_data <= {16'h3634,8'h40};
8'd36 : i2c_data <= {16'h3622,8'h01};
8'd37 : i2c_data <= {16'h3c01,8'h34};
8'd38 : i2c_data <= {16'h3c04,8'h28};
8'd39 : i2c_data <= {16'h3c05,8'h98};
8'd40 : i2c_data <= {16'h3c06,8'h00}; //light meter 1 阈值[15:8]
8'd41 : i2c_data <= {16'h3c07,8'h08}; //light meter 1 阈值[7:0]
8'd42 : i2c_data <= {16'h3c08,8'h00}; //light meter 2 阈值[15:8]
8'd43 : i2c_data <= {16'h3c09,8'h1c}; //light meter 2 阈值[7:0]
8'd44 : i2c_data <= {16'h3c0a,8'h9c}; //sample number[15:8]
8'd45 : i2c_data <= {16'h3c0b,8'h40}; //sample number[7:0]
8'd46 : i2c_data <= {16'h3810,8'h00}; //Timing Hoffset[11:8] ISP horizontal offset[11:8] high byte
8'd47 : i2c_data <= {16'h3811,8'h10}; //Timing Hoffset[7:0] ISP horizontal offset[7:0] low byte
8'd48 : i2c_data <= {16'h3812,8'h00}; //Timing Voffset[10:8]
8'd49 : i2c_data <= {16'h3708,8'h64};
8'd50 : i2c_data <= {16'h4001,8'h02}; //BLC(黑电平校准)补偿起始行号
8'd51 : i2c_data <= {16'h4005,8'h1a}; //BLC(黑电平校准)补偿始终更新
8'd52 : i2c_data <= {16'h3000,8'h00}; //系统块复位控制
8'd53 : i2c_data <= {16'h3004,8'hff}; //时钟使能控制
8'd54 : i2c_data <= {16'h4300,8'h61}; //格式控制 RGB565
8'd55 : i2c_data <= {16'h501f,8'h01}; //ISP RGB
8'd56 : i2c_data <= {16'h440e,8'h00};
8'd57 : i2c_data <= {16'h5000,8'ha7}; //ISP控制
8'd58 : i2c_data <= {16'h3a0f,8'h30}; //AEC控制;stable range in high
8'd59 : i2c_data <= {16'h3a10,8'h28}; //AEC控制;stable range in low
8'd60 : i2c_data <= {16'h3a1b,8'h30}; //AEC控制;stable range out high
8'd61 : i2c_data <= {16'h3a1e,8'h26}; //AEC控制;stable range out low
8'd62 : i2c_data <= {16'h3a11,8'h60}; //AEC控制; fast zone high
8'd63 : i2c_data <= {16'h3a1f,8'h14}; //AEC控制; fast zone low
//LENC(镜头校正)控制 16'h5800~16'h583d
8'd64 : i2c_data <= {16'h5800,8'h23};
8'd65 : i2c_data <= {16'h5801,8'h14};
8'd66 : i2c_data <= {16'h5802,8'h0f};
8'd67 : i2c_data <= {16'h5803,8'h0f};
8'd68 : i2c_data <= {16'h5804,8'h12};
8'd69 : i2c_data <= {16'h5805,8'h26};
8'd70 : i2c_data <= {16'h5806,8'h0c};
8'd71 : i2c_data <= {16'h5807,8'h08};
8'd72 : i2c_data <= {16'h5808,8'h05};
8'd73 : i2c_data <= {16'h5809,8'h05};
8'd74 : i2c_data <= {16'h580a,8'h08};
8'd75 : i2c_data <= {16'h580b,8'h0d};
8'd76 : i2c_data <= {16'h580c,8'h08};
8'd77 : i2c_data <= {16'h580d,8'h03};
8'd78 : i2c_data <= {16'h580e,8'h00};
8'd79 : i2c_data <= {16'h580f,8'h00};
8'd80 : i2c_data <= {16'h5810,8'h03};
8'd81 : i2c_data <= {16'h5811,8'h09};
8'd82 : i2c_data <= {16'h5812,8'h07};
8'd83 : i2c_data <= {16'h5813,8'h03};
8'd84 : i2c_data <= {16'h5814,8'h00};
8'd85 : i2c_data <= {16'h5815,8'h01};
8'd86 : i2c_data <= {16'h5816,8'h03};
8'd87 : i2c_data <= {16'h5817,8'h08};
8'd88 : i2c_data <= {16'h5818,8'h0d};
8'd89 : i2c_data <= {16'h5819,8'h08};
8'd90 : i2c_data <= {16'h581a,8'h05};
8'd91 : i2c_data <= {16'h581b,8'h06};
8'd92 : i2c_data <= {16'h581c,8'h08};
8'd93 : i2c_data <= {16'h581d,8'h0e};
8'd94 : i2c_data <= {16'h581e,8'h29};
8'd95 : i2c_data <= {16'h581f,8'h17};
8'd96 : i2c_data <= {16'h5820,8'h11};
8'd97 : i2c_data <= {16'h5821,8'h11};
8'd98 : i2c_data <= {16'h5822,8'h15};
8'd99 : i2c_data <= {16'h5823,8'h28};
8'd100: i2c_data <= {16'h5824,8'h46};
8'd101: i2c_data <= {16'h5825,8'h26};
8'd102: i2c_data <= {16'h5826,8'h08};
8'd103: i2c_data <= {16'h5827,8'h26};
8'd104: i2c_data <= {16'h5828,8'h64};
8'd105: i2c_data <= {16'h5829,8'h26};
8'd106: i2c_data <= {16'h582a,8'h24};
8'd107: i2c_data <= {16'h582b,8'h22};
8'd108: i2c_data <= {16'h582c,8'h24};
8'd109: i2c_data <= {16'h582d,8'h24};
8'd110: i2c_data <= {16'h582e,8'h06};
8'd111: i2c_data <= {16'h582f,8'h22};
8'd112: i2c_data <= {16'h5830,8'h40};
8'd113: i2c_data <= {16'h5831,8'h42};
8'd114: i2c_data <= {16'h5832,8'h24};
8'd115: i2c_data <= {16'h5833,8'h26};
8'd116: i2c_data <= {16'h5834,8'h24};
8'd117: i2c_data <= {16'h5835,8'h22};
8'd118: i2c_data <= {16'h5836,8'h22};
8'd119: i2c_data <= {16'h5837,8'h26};
8'd120: i2c_data <= {16'h5838,8'h44};
8'd121: i2c_data <= {16'h5839,8'h24};
8'd122: i2c_data <= {16'h583a,8'h26};
8'd123: i2c_data <= {16'h583b,8'h28};
8'd124: i2c_data <= {16'h583c,8'h42};
8'd125: i2c_data <= {16'h583d,8'hce};
//AWB(自动白平衡控制) 16'h5180~16'h519e
8'd126: i2c_data <= {16'h5180,8'hff};
8'd127: i2c_data <= {16'h5181,8'hf2};
8'd128: i2c_data <= {16'h5182,8'h00};
8'd129: i2c_data <= {16'h5183,8'h14};
8'd130: i2c_data <= {16'h5184,8'h25};
8'd131: i2c_data <= {16'h5185,8'h24};
8'd132: i2c_data <= {16'h5186,8'h09};
8'd133: i2c_data <= {16'h5187,8'h09};
8'd134: i2c_data <= {16'h5188,8'h09};
8'd135: i2c_data <= {16'h5189,8'h75};
8'd136: i2c_data <= {16'h518a,8'h54};
8'd137: i2c_data <= {16'h518b,8'he0};
8'd138: i2c_data <= {16'h518c,8'hb2};
8'd139: i2c_data <= {16'h518d,8'h42};
8'd140: i2c_data <= {16'h518e,8'h3d};
8'd141: i2c_data <= {16'h518f,8'h56};
8'd142: i2c_data <= {16'h5190,8'h46};
8'd143: i2c_data <= {16'h5191,8'hf8};
8'd144: i2c_data <= {16'h5192,8'h04};
8'd145: i2c_data <= {16'h5193,8'h70};
8'd146: i2c_data <= {16'h5194,8'hf0};
8'd147: i2c_data <= {16'h5195,8'hf0};
8'd148: i2c_data <= {16'h5196,8'h03};
8'd149: i2c_data <= {16'h5197,8'h01};
8'd150: i2c_data <= {16'h5198,8'h04};
8'd151: i2c_data <= {16'h5199,8'h12};
8'd152: i2c_data <= {16'h519a,8'h04};
8'd153: i2c_data <= {16'h519b,8'h00};
8'd154: i2c_data <= {16'h519c,8'h06};
8'd155: i2c_data <= {16'h519d,8'h82};
8'd156: i2c_data <= {16'h519e,8'h38};
//Gamma(伽马)控制 16'h5480~16'h5490
8'd157: i2c_data <= {16'h5480,8'h01};
8'd158: i2c_data <= {16'h5481,8'h08};
8'd159: i2c_data <= {16'h5482,8'h14};
8'd160: i2c_data <= {16'h5483,8'h28};
8'd161: i2c_data <= {16'h5484,8'h51};
8'd162: i2c_data <= {16'h5485,8'h65};
8'd163: i2c_data <= {16'h5486,8'h71};
8'd164: i2c_data <= {16'h5487,8'h7d};
8'd165: i2c_data <= {16'h5488,8'h87};
8'd166: i2c_data <= {16'h5489,8'h91};
8'd167: i2c_data <= {16'h548a,8'h9a};
8'd168: i2c_data <= {16'h548b,8'haa};
8'd169: i2c_data <= {16'h548c,8'hb8};
8'd170: i2c_data <= {16'h548d,8'hcd};
8'd171: i2c_data <= {16'h548e,8'hdd};
8'd172: i2c_data <= {16'h548f,8'hea};
8'd173: i2c_data <= {16'h5490,8'h1d};
//CMX(彩色矩阵控制) 16'h5381~16'h538b
8'd174: i2c_data <= {16'h5381,8'h1e};
8'd175: i2c_data <= {16'h5382,8'h5b};
8'd176: i2c_data <= {16'h5383,8'h08};
8'd177: i2c_data <= {16'h5384,8'h0a};
8'd178: i2c_data <= {16'h5385,8'h7e};
8'd179: i2c_data <= {16'h5386,8'h88};
8'd180: i2c_data <= {16'h5387,8'h7c};
8'd181: i2c_data <= {16'h5388,8'h6c};
8'd182: i2c_data <= {16'h5389,8'h10};
8'd183: i2c_data <= {16'h538a,8'h01};
8'd184: i2c_data <= {16'h538b,8'h98};
//SDE(特殊数码效果)控制 16'h5580~16'h558b
8'd185: i2c_data <= {16'h5580,8'h06};
8'd186: i2c_data <= {16'h5583,8'h40};
8'd187: i2c_data <= {16'h5584,8'h10};
8'd188: i2c_data <= {16'h5589,8'h10};
8'd189: i2c_data <= {16'h558a,8'h00};
8'd190: i2c_data <= {16'h558b,8'hf8};
8'd191: i2c_data <= {16'h501d,8'h40}; //ISP MISC
//CIP(颜色插值)控制 (16'h5300~16'h530c)
8'd192: i2c_data <= {16'h5300,8'h08};
8'd193: i2c_data <= {16'h5301,8'h30};
8'd194: i2c_data <= {16'h5302,8'h10};
8'd195: i2c_data <= {16'h5303,8'h00};
8'd196: i2c_data <= {16'h5304,8'h08};
8'd197: i2c_data <= {16'h5305,8'h30};
8'd198: i2c_data <= {16'h5306,8'h08};
8'd199: i2c_data <= {16'h5307,8'h16};
8'd200: i2c_data <= {16'h5309,8'h08};
8'd201: i2c_data <= {16'h530a,8'h30};
8'd202: i2c_data <= {16'h530b,8'h04};
8'd203: i2c_data <= {16'h530c,8'h06};
8'd204: i2c_data <= {16'h5025,8'h00};
//系统时钟分频 Bit[7:4]:系统时钟分频 input clock =24Mhz, PCLK = 48Mhz
8'd205: i2c_data <= {16'h3035,8'h11};
8'd206: i2c_data <= {16'h3036,8'h3c}; //PLL倍频
8'd207: i2c_data <= {16'h3c07,8'h08};
//时序控制 16'h3800~16'h3821
8'd208: i2c_data <= {16'h3820,8'h46};
8'd209: i2c_data <= {16'h3821,8'h01};
8'd210: i2c_data <= {16'h3814,8'h31};
8'd211: i2c_data <= {16'h3815,8'h31};
8'd212: i2c_data <= {16'h3800,8'h00};// 开窗:x 开始位置 0*0~2591*1943
8'd213: i2c_data <= {16'h3801,8'h00};// 开窗:x 开始位置
8'd214: i2c_data <= {16'h3802,8'h00};// 开窗:y 开始位置
8'd215: i2c_data <= {16'h3803,8'h04};// 开窗:y 开始位置
8'd216: i2c_data <= {16'h3804,8'h0a};// 开窗:x 结束位置
8'd217: i2c_data <= {16'h3805,8'h3f};// 开窗:x 结束位置
8'd218: i2c_data <= {16'h3806,8'h07};// 开窗:y 结束位置
8'd219: i2c_data <= {16'h3807,8'h9b};// 开窗:y 结束位置 size:2623*1943
//设置输出像素个数
//DVP 输出水平像素点数高4位
8'd220: i2c_data <= {16'h3808,{4'd0,cmos_h_pixel[11:8]}};
//DVP 输出水平像素点数低8位
8'd221: i2c_data <= {16'h3809,cmos_h_pixel[7:0]};
//DVP 输出垂直像素点数高3位
8'd222: i2c_data <= {16'h380a,{5'd0,cmos_v_pixel[10:8]}};
//DVP 输出垂直像素点数低8位
8'd223: i2c_data <= {16'h380b,cmos_v_pixel[7:0]};
//水平总像素大小高5位
8'd224: i2c_data <= {16'h380c,{3'd0,total_h_pixel[12:8]}};//Total horizontal size[11:8] high byte
//水平总像素大小低8位
8'd225: i2c_data <= {16'h380d,total_h_pixel[7:0]};//Total horizontal size[7:0] low byte
//垂直总像素大小高5位
8'd226: i2c_data <= {16'h380e,{3'd0,total_v_pixel[12:8]}};// Total vertical size[15:8] high byte
//垂直总像素大小低8位
8'd227: i2c_data <= {16'h380f,total_v_pixel[7:0]};// Total vertical size[7:0] low byte
8'd228: i2c_data <= {16'h3813,8'h06};
8'd229: i2c_data <= {16'h3618,8'h00};
8'd230: i2c_data <= {16'h3612,8'h29};
8'd231: i2c_data <= {16'h3709,8'h52};
8'd232: i2c_data <= {16'h370c,8'h03};
8'd233: i2c_data <= {16'h3a02,8'h17}; //60Hz max exposure
8'd234: i2c_data <= {16'h3a03,8'h10}; //60Hz max exposure
8'd235: i2c_data <= {16'h3a14,8'h17}; //50Hz max exposure
8'd236: i2c_data <= {16'h3a15,8'h10}; //50Hz max exposure
8'd237: i2c_data <= {16'h4004,8'h02}; //BLC(背光) 2 lines
8'd238: i2c_data <= {16'h4713,8'h03}; //JPEG mode 3
8'd239: i2c_data <= {16'h4407,8'h04}; //量化标度
8'd240: i2c_data <= {16'h460c,8'h22};
8'd241: i2c_data <= {16'h4837,8'h22}; //DVP CLK divider
8'd242: i2c_data <= {16'h3824,8'h02}; //DVP CLK divider
8'd243: i2c_data <= {16'h5001,8'ha3}; //ISP 控制
8'd244: i2c_data <= {16'h3b07,8'h0a}; //帧曝光模式
//彩条测试使能
8'd245: i2c_data <= {16'h503d,8'h00}; //8'h00:正常模式 8'h80:彩条显示
//测试闪光灯功能
8'd246: i2c_data <= {16'h3016,8'h02};
8'd247: i2c_data <= {16'h301c,8'h02};
8'd248: i2c_data <= {16'h3019,8'h02}; //打开闪光灯
8'd249: i2c_data <= {16'h3019,8'h00}; //关闭闪光灯
//只读存储器,防止在case中没有列举的情况,之前的寄存器被重复改写
default : i2c_data <= {16'h300a,8'h00}; //器件ID高8位
endcase
end
end
endmodule
米联客:
/*******************************MILIANKE*******************************
*Company : MiLianKe Electronic Technology Co., Ltd.
*WebSite:https://www.milianke.com
*TechWeb:https://www.uisrc.com
*tmall-shop:https://milianke.tmall.com
*jd-shop:https://milianke.jd.com
*taobao-shop1: https://milianke.taobao.com
*Create Date: 2021/10/15
*File Name: ui5640reg.v
*Description:
*Declaration:
*The reference demo provided by Milianke is only used for learning.
*We cannot ensure that the demo itself is free of bugs, so users
*should be responsible for the technical problems and consequences
*caused by the use of their own products.
*Copyright: Copyright (c) MiLianKe
*All rights reserved.
*Revision: 1.0
*Signal description
*1) _i input
*2) _o output
*3) _n activ low
*4) _dg debug signal
*5) _r delay or register
*6) _s state mechine
*********************************************************************/
/*******************************ui5640reg***************************
--1.OV5640摄像头芯片寄存器配置参数
*********************************************************************/
module ui5640reg
(
input [8 :0] REG_INDEX,
input [15 :0] CAM_HSIZE,
input [15 :0] CAM_VSIZE,
output reg [31:0] REG_DATA,
output [8 :0] REG_SIZE
);
assign REG_SIZE = 9'd251;
//-----------------------------------------------------------------
/ Config Data REG //
always@(*)
begin
case(REG_INDEX)
0: REG_DATA<=24'h310311; // system clock from pad, bit[1]
1: REG_DATA<=24'h300882; // software reset, bit[7]
// delay 5ms
2: REG_DATA<=24'h300842; // software power down, bit[6]
3: REG_DATA<=24'h310303; // system clock from PLL, bit[1]
4: REG_DATA<=24'h3017ff; // FREX, Vsync, HREF, PCLK, D[9:6] output enable
5: REG_DATA<=24'h3018ff; // D[5:0], GPIO[1:0] output enable
6: REG_DATA<=24'h30341a; // MIPI 10-bit
7: REG_DATA<=24'h303713; // PLL root divider, bit[4], PLL pre-divider, bit[3:0]
8: REG_DATA<=24'h310801; // PCLK root divider, bit[5:4], SCLK2x root divider, bit[3:2]
// SCLK root divider, bit[1:0]
9: REG_DATA<=24'h363036;
10: REG_DATA<=24'h36310e;
11: REG_DATA<=24'h3632e2;
12: REG_DATA<=24'h363312;
13: REG_DATA<=24'h3621e0;
14: REG_DATA<=24'h3704a0;
15: REG_DATA<=24'h37035a;
16: REG_DATA<=24'h371578;
17: REG_DATA<=24'h371701;
18: REG_DATA<=24'h370b60;
19: REG_DATA<=24'h37051a;
20: REG_DATA<=24'h390502;
21: REG_DATA<=24'h390610;
22: REG_DATA<=24'h39010a;
23: REG_DATA<=24'h373112;
24: REG_DATA<=24'h360008; // VCM control
25: REG_DATA<=24'h360133; // VCM control
26: REG_DATA<=24'h302d60; // system control
27: REG_DATA<=24'h362052;
28: REG_DATA<=24'h371b20;
29: REG_DATA<=24'h471c50;
30: REG_DATA<=24'h3a1343; // pre-gain = 1.047x
31: REG_DATA<=24'h3a1800; // gain ceiling
32: REG_DATA<=24'h3a19f8; // gain ceiling = 15.5x
33: REG_DATA<=24'h363513;
34: REG_DATA<=24'h363603;
35: REG_DATA<=24'h363440;
36: REG_DATA<=24'h362201;
// 50/60Hz detection 50/60Hz 灯光条纹过滤
37: REG_DATA<=24'h3c0134; // Band auto, bit[7]
38: REG_DATA<=24'h3c0428; // threshold low sum
39: REG_DATA<=24'h3c0598; // threshold high sum
40: REG_DATA<=24'h3c0600; // light meter 1 threshold[15:8]
41: REG_DATA<=24'h3c0708; // light meter 1 threshold[7:0]
42: REG_DATA<=24'h3c0800; // light meter 2 threshold[15:8]
43: REG_DATA<=24'h3c091c; // light meter 2 threshold[7:0]
44: REG_DATA<=24'h3c0a9c; // sample number[15:8]
45: REG_DATA<=24'h3c0b40; // sample number[7:0]
46: REG_DATA<=24'h381000; // Timing Hoffset[11:8]
47: REG_DATA<=24'h381110; // Timing Hoffset[7:0]
48: REG_DATA<=24'h381200; // Timing Voffset[10:8]
49: REG_DATA<=24'h370864;
50: REG_DATA<=24'h400102; // BLC start from line 2
51: REG_DATA<=24'h40051a; // BLC always update
52: REG_DATA<=24'h300000; // enable blocks
53: REG_DATA<=24'h3004ff; // enable clocks
54: REG_DATA<=24'h300e58; // MIPI power down, DVP enable
55: REG_DATA<=24'h302e00;
56: REG_DATA<=24'h430061; // YUV 422, YUYV
57: REG_DATA<=24'h501f01; // YUV 422
58: REG_DATA<=24'h440e00;
59: REG_DATA<=24'h5000a7; // Lenc on, raw gamma on, BPC on, WPC on, CIP on
// AEC target 自动曝光控制
60: REG_DATA<=24'h3a0f30; // stable range in high
61: REG_DATA<=24'h3a1028; // stable range in low
62: REG_DATA<=24'h3a1b30; // stable range out high
63: REG_DATA<=24'h3a1e26; // stable range out low
64: REG_DATA<=24'h3a1160; // fast zone high
65: REG_DATA<=24'h3a1f14; // fast zone low
// Lens correction for ? 镜头补偿
66: REG_DATA<=24'h580023;
67: REG_DATA<=24'h580114;
68: REG_DATA<=24'h58020f;
69: REG_DATA<=24'h58030f;
70: REG_DATA<=24'h580412;
71: REG_DATA<=24'h580526;
72: REG_DATA<=24'h58060c;
73: REG_DATA<=24'h580708;
74: REG_DATA<=24'h580805;
75: REG_DATA<=24'h580905;
76: REG_DATA<=24'h580a08;
77: REG_DATA<=24'h580b0d;
78: REG_DATA<=24'h580c08;
79: REG_DATA<=24'h580d03;
80: REG_DATA<=24'h580e00;
81: REG_DATA<=24'h580f00;
82: REG_DATA<=24'h581003;
83: REG_DATA<=24'h581109;
84: REG_DATA<=24'h581207;
85: REG_DATA<=24'h581303;
86: REG_DATA<=24'h581400;
87: REG_DATA<=24'h581501;
88: REG_DATA<=24'h581603;
89: REG_DATA<=24'h581708;
90: REG_DATA<=24'h58180d;
91: REG_DATA<=24'h581908;
92: REG_DATA<=24'h581a05;
93: REG_DATA<=24'h581b06;
94: REG_DATA<=24'h581c08;
95: REG_DATA<=24'h581d0e;
96: REG_DATA<=24'h581e29;
97: REG_DATA<=24'h581f17;
98: REG_DATA<=24'h582011;
99: REG_DATA<=24'h582111;
100: REG_DATA<=24'h582215;
101: REG_DATA<=24'h582328;
102: REG_DATA<=24'h582446;
103: REG_DATA<=24'h582526;
104: REG_DATA<=24'h582608;
105: REG_DATA<=24'h582726;
106: REG_DATA<=24'h582864;
107: REG_DATA<=24'h582926;
108: REG_DATA<=24'h582a24;
109: REG_DATA<=24'h582b22;
110: REG_DATA<=24'h582c24;
111: REG_DATA<=24'h582d24;
112: REG_DATA<=24'h582e06;
113: REG_DATA<=24'h582f22;
114: REG_DATA<=24'h583040;
115: REG_DATA<=24'h583142;
116: REG_DATA<=24'h583224;
117: REG_DATA<=24'h583326;
118: REG_DATA<=24'h583424;
119: REG_DATA<=24'h583522;
120: REG_DATA<=24'h583622;
121: REG_DATA<=24'h583726;
122: REG_DATA<=24'h583844;
123: REG_DATA<=24'h583924;
124: REG_DATA<=24'h583a26;
125: REG_DATA<=24'h583b28;
126: REG_DATA<=24'h583c42;
127: REG_DATA<=24'h583dce; // lenc BR offset
128: REG_DATA<=24'h5180ff; // AWB B block
129: REG_DATA<=24'h518158; // AWB control
130: REG_DATA<=24'h518211; // [7:4] max local counter, [3:0] max fast counter
131: REG_DATA<=24'h518390; // AWB advanced
132: REG_DATA<=24'h518425;
133: REG_DATA<=24'h518524;
134: REG_DATA<=24'h518609;
135: REG_DATA<=24'h518709;
136: REG_DATA<=24'h518809;
137: REG_DATA<=24'h518975;
138: REG_DATA<=24'h518a54;
139: REG_DATA<=24'h518be0;
140: REG_DATA<=24'h518cb2;
141: REG_DATA<=24'h518d42;
142: REG_DATA<=24'h518e3d;
143: REG_DATA<=24'h518f56;
144: REG_DATA<=24'h519046;
145: REG_DATA<=24'h5191ff; // AWB top limit
146: REG_DATA<=24'h519200; // AWB bottom limit
147: REG_DATA<=24'h5193f0; // red limit
148: REG_DATA<=24'h5194f0; // green limit
149: REG_DATA<=24'h5195f0; // blue limit
150: REG_DATA<=24'h519603; // AWB control
151: REG_DATA<=24'h519702; // local limit
152: REG_DATA<=24'h519804;
153: REG_DATA<=24'h519912;
154: REG_DATA<=24'h519a04;
155: REG_DATA<=24'h519b00;
156: REG_DATA<=24'h519c06;
157: REG_DATA<=24'h519d82;
158: REG_DATA<=24'h519e00; // AWB control
// Gamma 伽玛曲线
159: REG_DATA<=24'h548001; // Gamma bias plus on, bit[0]
160: REG_DATA<=24'h548108;
161: REG_DATA<=24'h548214;
162: REG_DATA<=24'h548328;
163: REG_DATA<=24'h548451;
164: REG_DATA<=24'h548565;
165: REG_DATA<=24'h548671;
166: REG_DATA<=24'h54877d;
167: REG_DATA<=24'h548887;
168: REG_DATA<=24'h548991;
169: REG_DATA<=24'h548a9a;
170: REG_DATA<=24'h548baa;
171: REG_DATA<=24'h548cb8;
172: REG_DATA<=24'h548dcd;
173: REG_DATA<=24'h548edd;
174: REG_DATA<=24'h548fea;
175: REG_DATA<=24'h54901d;
// color matrix 色彩矩阵
176: REG_DATA<=24'h53811e; // CMX1 for Y
177: REG_DATA<=24'h53825b; // CMX2 for Y
178: REG_DATA<=24'h538308; // CMX3 for Y
179: REG_DATA<=24'h53840a; // CMX4 for U
180: REG_DATA<=24'h53857e; // CMX5 for U
181: REG_DATA<=24'h538688; // CMX6 for U
182: REG_DATA<=24'h53877c; // CMX7 for V
183: REG_DATA<=24'h53886c; // CMX8 for V
184: REG_DATA<=24'h538910; // CMX9 for V
185: REG_DATA<=24'h538a01; // sign[9]
186: REG_DATA<=24'h538b98; // sign[8:1]
// UV adjust UV色彩饱和度调整
187: REG_DATA<=24'h558006; // saturation on, bit[1]
188: REG_DATA<=24'h558340;
189: REG_DATA<=24'h558410;
190: REG_DATA<=24'h558910;
191: REG_DATA<=24'h558a00;
192: REG_DATA<=24'h558bf8;
193: REG_DATA<=24'h501d40; // enable manual offset of contrast
// CIP 锐化和降噪
194: REG_DATA<=24'h530008; // CIP sharpen MT threshold 1
195: REG_DATA<=24'h530130; // CIP sharpen MT threshold 2
196: REG_DATA<=24'h530210; // CIP sharpen MT offset 1
197: REG_DATA<=24'h530300; // CIP sharpen MT offset 2
198: REG_DATA<=24'h530408; // CIP DNS threshold 1
199: REG_DATA<=24'h530530; // CIP DNS threshold 2
200: REG_DATA<=24'h530608; // CIP DNS offset 1
201: REG_DATA<=24'h530716; // CIP DNS offset 2
202: REG_DATA<=24'h530908; // CIP sharpen TH threshold 1
203: REG_DATA<=24'h530a30; // CIP sharpen TH threshold 2
204: REG_DATA<=24'h530b04; // CIP sharpen TH offset 1
205: REG_DATA<=24'h530c06; // CIP sharpen TH offset 2
206: REG_DATA<=24'h502500;
207: REG_DATA<=24'h300802; // wake up from standby, bit[6]
// YUV VGA 30fps, night mode 5fps
// Input Clock = 24Mhz, PCLK = 56MHz
208: REG_DATA<=24'h303541; // PLL
209: REG_DATA<=24'h303669; // PLL
210: REG_DATA<=24'h3c0707; // light meter 1 threshold [7:0]
211: REG_DATA<=24'h382040; // Sensor flip off, ISP flip on
212: REG_DATA<=24'h382101; // Sensor mirror on, ISP mirror on, H binning on
213: REG_DATA<=24'h381431; // X INC
214: REG_DATA<=24'h381531; // Y INC
215: REG_DATA<=24'h380000; // HS
216: REG_DATA<=24'h380100; // HS
217: REG_DATA<=24'h380200; // VS
218: REG_DATA<=24'h3803fa; // VS
219: REG_DATA<=24'h38040a; // HW (HE)
220: REG_DATA<=24'h38053f; // HW (HE)
221: REG_DATA<=24'h380606; // VH (VE)
222: REG_DATA<=24'h3807a9; // VH (VE)
223: REG_DATA<={16'h3808,CAM_HSIZE[15:8]} ; // DVPHO (1280)
224: REG_DATA<={16'h3809,CAM_HSIZE[ 7:0]}; // DVPHO (1280)
225: REG_DATA<={16'h380a,CAM_VSIZE[15:8]} ; // DVPVO (720)
226: REG_DATA<={16'h380b,CAM_VSIZE[ 7:0]}; // DVPVO (720)
227: REG_DATA<=24'h380c07; // HTS
228: REG_DATA<=24'h380d64; // HTS
229: REG_DATA<=24'h380e02; // VTS
230: REG_DATA<=24'h380fe4; // VTS
231: REG_DATA<=24'h381304; // Timing Voffset
232: REG_DATA<=24'h361800;
233: REG_DATA<=24'h361229;
234: REG_DATA<=24'h370952;
235: REG_DATA<=24'h370c03;
236: REG_DATA<=24'h3a0217; // 60Hz max exposure, night mode 5fps
237: REG_DATA<=24'h3a03e0; // 60Hz max exposure
// banding filters are calculated automatically in camera driver
//: REG_DATA<=24'h3a0801; // B50 step
//: REG_DATA<=24'h3a0927; // B50 step
//: REG_DATA<=24'h3a0a00; // B60 step
//: REG_DATA<=24'h3a0bf6; // B60 step
//: REG_DATA<=24'h3a0e03; // 50Hz max band
//: REG_DATA<=24'h3a0d04; // 60Hz max band
238: REG_DATA<=24'h3a1417; // 50Hz max exposure, night mode 5fps
239: REG_DATA<=24'h3a1510; // 50Hz max exposure
240: REG_DATA<=24'h400402; // BLC 2 lines
241: REG_DATA<=24'h30021c; // reset JFIFO, SFIFO, JPEG
242: REG_DATA<=24'h3006c3; // disable clock of JPEG2x, JPEG
243: REG_DATA<=24'h471303; // JPEG mode 3
244: REG_DATA<=24'h440704; // Quantization scale
245: REG_DATA<=24'h460b37;
246: REG_DATA<=24'h460c20;
247: REG_DATA<=24'h483716; // DVP CLK divider
248: REG_DATA<=24'h382402; // DVP CLK divider
249: REG_DATA<=24'h500183; // SDE on, scale on, UV average off, color matrix on, AWB on
250: REG_DATA<=24'h350300; // AEC/AGC on
default: REG_DATA<=24'h000000;
endcase
end
endmodule
其他?
基于FPGA的摄像头控制电路设计之OV5640寄存器配置-RGB565-800×480预览 - mjybk - 博客园 (cnblogs.com)
文章来源:https://blog.csdn.net/NoNoUnknow/article/details/135171605
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!