-
Notifications
You must be signed in to change notification settings - Fork 1
/
OV2640.h
153 lines (147 loc) · 4.69 KB
/
OV2640.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#ifndef _OV2640_H
#define _OV2640_H
#include "stm32h7xx_hal.h"
/* OV2640 Registers definition when DSP bank selected (0xFF = 0x00) */
#define OV2640_DSP_R_BYPASS 0x05
#define OV2640_DSP_Qs 0x44
#define OV2640_DSP_CTRL 0x50
#define OV2640_DSP_HSIZE1 0x51
#define OV2640_DSP_VSIZE1 0x52
#define OV2640_DSP_XOFFL 0x53
#define OV2640_DSP_YOFFL 0x54
#define OV2640_DSP_VHYX 0x55
#define OV2640_DSP_DPRP 0x56
#define OV2640_DSP_TEST 0x57
#define OV2640_DSP_ZMOW 0x5A
#define OV2640_DSP_ZMOH 0x5B
#define OV2640_DSP_ZMHH 0x5C
#define OV2640_DSP_BPADDR 0x7C
#define OV2640_DSP_BPDATA 0x7D
#define OV2640_DSP_CTRL2 0x86
#define OV2640_DSP_CTRL3 0x87
#define OV2640_DSP_SIZEL 0x8C
#define OV2640_DSP_HSIZE2 0xC0
#define OV2640_DSP_VSIZE2 0xC1
#define OV2640_DSP_CTRL0 0xC2
#define OV2640_DSP_CTRL1 0xC3
#define OV2640_DSP_R_DVP_SP 0xD3
#define OV2640_DSP_IMAGE_MODE 0xDA
#define OV2640_DSP_RESET 0xE0
#define OV2640_DSP_MS_SP 0xF0
#define OV2640_DSP_SS_ID 0x7F
#define OV2640_DSP_SS_CTRL 0xF8
#define OV2640_DSP_MC_BIST 0xF9
#define OV2640_DSP_MC_AL 0xFA
#define OV2640_DSP_MC_AH 0xFB
#define OV2640_DSP_MC_D 0xFC
#define OV2640_DSP_P_STATUS 0xFE
#define OV2640_DSP_RA_DLMT 0xFF
/* OV2640 Registers definition when sensor bank selected (0xFF = 0x01) */
#define OV2640_SENSOR_GAIN 0x00
#define OV2640_SENSOR_COM1 0x03
#define OV2640_SENSOR_REG04 0x04
#define OV2640_SENSOR_REG08 0x08
#define OV2640_SENSOR_COM2 0x09
#define OV2640_SENSOR_PIDH 0x0A
#define OV2640_SENSOR_PIDL 0x0B
#define OV2640_SENSOR_COM3 0x0C
#define OV2640_SENSOR_COM4 0x0D
#define OV2640_SENSOR_AEC 0x10
#define OV2640_SENSOR_CLKRC 0x11
#define OV2640_SENSOR_COM7 0x12
#define OV2640_SENSOR_COM8 0x13
#define OV2640_SENSOR_COM9 0x14
#define OV2640_SENSOR_COM10 0x15
#define OV2640_SENSOR_HREFST 0x17
#define OV2640_SENSOR_HREFEND 0x18
#define OV2640_SENSOR_VSTART 0x19
#define OV2640_SENSOR_VEND 0x1A
#define OV2640_SENSOR_MIDH 0x1C
#define OV2640_SENSOR_MIDL 0x1D
#define OV2640_SENSOR_AEW 0x24
#define OV2640_SENSOR_AEB 0x25
#define OV2640_SENSOR_W 0x26
#define OV2640_SENSOR_REG2A 0x2A
#define OV2640_SENSOR_FRARL 0x2B
#define OV2640_SENSOR_ADDVSL 0x2D
#define OV2640_SENSOR_ADDVHS 0x2E
#define OV2640_SENSOR_YAVG 0x2F
#define OV2640_SENSOR_REG32 0x32
#define OV2640_SENSOR_ARCOM2 0x34
#define OV2640_SENSOR_REG45 0x45
#define OV2640_SENSOR_FLL 0x46
#define OV2640_SENSOR_FLH 0x47
#define OV2640_SENSOR_COM19 0x48
#define OV2640_SENSOR_ZOOMS 0x49
#define OV2640_SENSOR_COM22 0x4B
#define OV2640_SENSOR_COM25 0x4E
#define OV2640_SENSOR_BD50 0x4F
#define OV2640_SENSOR_BD60 0x50
#define OV2640_SENSOR_REG5D 0x5D
#define OV2640_SENSOR_REG5E 0x5E
#define OV2640_SENSOR_REG5F 0x5F
#define OV2640_SENSOR_REG60 0x60
#define OV2640_SENSOR_HISTO_LOW 0x61
#define OV2640_SENSOR_HISTO_HIGH 0x62
/* Image Sizes enumeration */
const static uint8_t OV2640_AUTOEXPOSURE_LEVEL0[]=
{
0xFF, 0x01, 0xff,
0x24, 0x20, 0xff,
0x25, 0x18, 0xff,
0x26, 0x60, 0xff,
0x00, 0x00, 0x00
};
const static uint8_t OV2640_AUTOEXPOSURE_LEVEL1[]=
{
0xFF, 0x01, 0xff,
0x24, 0x34, 0xff,
0x25, 0x1c, 0xff,
0x26, 0x70, 0xff,
0x00, 0x00, 0x00
};
const static uint8_t OV2640_AUTOEXPOSURE_LEVEL2[]=
{
0xFF, 0x01, 0xff,
0x24, 0x3e, 0xff,
0x25, 0x38, 0xff,
0x26, 0x81, 0xff,
0x00, 0x00, 0x00
};
const static uint8_t OV2640_AUTOEXPOSURE_LEVEL3[]=
{
0xFF, 0x01, 0xff,
0x24, 0x48, 0xff,
0x25, 0x40, 0xff,
0x26, 0x81, 0xff,
0x00, 0x00, 0x00
};
const static uint8_t OV2640_AUTOEXPOSURE_LEVEL4[]=
{
0xFF, 0x01, 0xff,
0x24, 0x58, 0xff,
0x25, 0x50, 0xff,
0x26, 0x92, 0xff,
0x00, 0x00, 0x00
};
typedef enum
{
BMP_QQVGA = 0x00, /* BMP Image QQVGA 160x120 Size */
BMP_QVGA = 0x01, /* BMP Image QVGA 320x240 Size */
JPEG_160x120 = 0x02, /* JPEG Image 160x120 Size */
JPEG_176x144 = 0x03, /* JPEG Image 176x144 Size */
JPEG_320x240 = 0x04, /* JPEG Image 320x240 Size */
JPEG_352x288 = 0x05, /* JPEG Image 352x288 Size */
JPEG_800x600 = 0x06
}ImageFormat_TypeDef;
typedef struct
{
uint8_t Manufacturer_ID1;
uint8_t Manufacturer_ID2;
uint8_t Version;
uint8_t PID;
}OV2640_IDTypeDef;
uint8_t OV2640_Init(I2C_HandleTypeDef *hi2c2,DCMI_HandleTypeDef *hdcmi, UART_HandleTypeDef *huart);
void StartOV2640();
void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi);
#endif