-
Notifications
You must be signed in to change notification settings - Fork 13
/
ov5640.h
261 lines (227 loc) · 10.2 KB
/
ov5640.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
/**
******************************************************************************
* @file ov5640.h
* @author MCD Application Team
* @brief This file contains all the functions prototypes for the ov5640.c
* driver.
******************************************************************************
* @attention
*
* Copyright (c) 2019-2020 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef OV5640_H
#define OV5640_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "ov5640_reg.h"
#include <stddef.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup ov5640
* @{
*/
/** @defgroup OV5640_Exported_Types
* @{
*/
typedef int32_t (*OV5640_Init_Func)(void);
typedef int32_t (*OV5640_DeInit_Func)(void);
typedef int32_t (*OV5640_GetTick_Func)(void);
typedef int32_t (*OV5640_Delay_Func)(uint32_t);
typedef int32_t (*OV5640_WriteReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t);
typedef int32_t (*OV5640_ReadReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t);
typedef struct
{
OV5640_Init_Func Init;
OV5640_DeInit_Func DeInit;
uint16_t Address;
OV5640_WriteReg_Func WriteReg;
OV5640_ReadReg_Func ReadReg;
OV5640_GetTick_Func GetTick;
} OV5640_IO_t;
typedef struct
{
OV5640_IO_t IO;
ov5640_ctx_t Ctx;
uint8_t IsInitialized;
uint8_t Mode;
uint32_t VirtualChannelID;
} OV5640_Object_t;
typedef struct
{
uint8_t FrameStartCode; /*!< Specifies the code of the frame start delimiter. */
uint8_t LineStartCode; /*!< Specifies the code of the line start delimiter. */
uint8_t LineEndCode; /*!< Specifies the code of the line end delimiter. */
uint8_t FrameEndCode; /*!< Specifies the code of the frame end delimiter. */
} OV5640_SyncCodes_t;
typedef struct
{
uint32_t Config_Resolution;
uint32_t Config_LightMode;
uint32_t Config_SpecialEffect;
uint32_t Config_Brightness;
uint32_t Config_Saturation;
uint32_t Config_Contrast;
uint32_t Config_HueDegree;
uint32_t Config_MirrorFlip;
uint32_t Config_Zoom;
uint32_t Config_NightMode;
} OV5640_Capabilities_t;
typedef struct
{
int32_t (*Init)(OV5640_Object_t *, uint32_t, uint32_t);
int32_t (*DeInit)(OV5640_Object_t *);
int32_t (*ReadID)(OV5640_Object_t *, uint32_t *);
int32_t (*GetCapabilities)(OV5640_Object_t *, OV5640_Capabilities_t *);
int32_t (*SetLightMode)(OV5640_Object_t *, uint32_t);
int32_t (*SetColorEffect)(OV5640_Object_t *, uint32_t);
int32_t (*SetBrightness)(OV5640_Object_t *, int32_t);
int32_t (*SetSaturation)(OV5640_Object_t *, int32_t);
int32_t (*SetContrast)(OV5640_Object_t *, int32_t);
int32_t (*SetHueDegree)(OV5640_Object_t *, int32_t);
int32_t (*MirrorFlipConfig)(OV5640_Object_t *, uint32_t);
int32_t (*ZoomConfig)(OV5640_Object_t *, uint32_t);
int32_t (*SetResolution)(OV5640_Object_t *, uint32_t);
int32_t (*GetResolution)(OV5640_Object_t *, uint32_t *);
int32_t (*SetPixelFormat)(OV5640_Object_t *, uint32_t);
int32_t (*GetPixelFormat)(OV5640_Object_t *, uint32_t *);
int32_t (*NightModeConfig)(OV5640_Object_t *, uint32_t);
} OV5640_CAMERA_Drv_t;
/**
* @}
*/
/** @defgroup OV5640_Exported_Constants
* @{
*/
#define OV5640_OK (0)
#define OV5640_ERROR (-1)
/**
* @brief OV5640 Features Parameters
*/
/* Camera resolutions */
#define OV5640_R160x120 0x00U /* QQVGA Resolution */
#define OV5640_R320x240 0x01U /* QVGA Resolution */
#define OV5640_R480x272 0x02U /* 480x272 Resolution */
#define OV5640_R640x480 0x03U /* VGA Resolution */
#define OV5640_R800x480 0x04U /* WVGA Resolution */
/* Camera Pixel Format */
#define OV5640_RGB565 0x00U /* Pixel Format RGB565 */
#define OV5640_RGB888 0x01U /* Pixel Format RGB888 */
#define OV5640_YUV422 0x02U /* Pixel Format YUV422 */
#define OV5640_Y8 0x07U /* Pixel Format Y8 */
#define OV5640_JPEG 0x08U /* Compressed format JPEG */
/* Polarity */
#define OV5640_POLARITY_PCLK_LOW 0x00U /* Signal Active Low */
#define OV5640_POLARITY_PCLK_HIGH 0x01U /* Signal Active High */
#define OV5640_POLARITY_HREF_LOW 0x00U /* Signal Active Low */
#define OV5640_POLARITY_HREF_HIGH 0x01U /* Signal Active High */
#define OV5640_POLARITY_VSYNC_LOW 0x01U /* Signal Active Low */
#define OV5640_POLARITY_VSYNC_HIGH 0x00U /* Signal Active High */
/* Mirror/Flip */
#define OV5640_MIRROR_FLIP_NONE 0x00U /* Set camera normal mode */
#define OV5640_FLIP 0x01U /* Set camera flip config */
#define OV5640_MIRROR 0x02U /* Set camera mirror config */
#define OV5640_MIRROR_FLIP 0x03U /* Set camera mirror and flip */
/* Zoom */
#define OV5640_ZOOM_x8 0x00U /* Set zoom to x8 */
#define OV5640_ZOOM_x4 0x11U /* Set zoom to x4 */
#define OV5640_ZOOM_x2 0x22U /* Set zoom to x2 */
#define OV5640_ZOOM_x1 0x44U /* Set zoom to x1 */
/* Special Effect */
#define OV5640_COLOR_EFFECT_NONE 0x00U /* No effect */
#define OV5640_COLOR_EFFECT_BLUE 0x01U /* Blue effect */
#define OV5640_COLOR_EFFECT_RED 0x02U /* Red effect */
#define OV5640_COLOR_EFFECT_GREEN 0x04U /* Green effect */
#define OV5640_COLOR_EFFECT_BW 0x08U /* Black and White effect */
#define OV5640_COLOR_EFFECT_SEPIA 0x10U /* Sepia effect */
#define OV5640_COLOR_EFFECT_NEGATIVE 0x20U /* Negative effect */
/* Light Mode */
#define OV5640_LIGHT_AUTO 0x00U /* Light Mode Auto */
#define OV5640_LIGHT_SUNNY 0x01U /* Light Mode Sunny */
#define OV5640_LIGHT_OFFICE 0x02U /* Light Mode Office */
#define OV5640_LIGHT_HOME 0x04U /* Light Mode Home */
#define OV5640_LIGHT_CLOUDY 0x08U /* Light Mode Claudy */
/* Night Mode */
#define NIGHT_MODE_DISABLE 0x00U /* Disable night mode */
#define NIGHT_MODE_ENABLE 0x01U /* Enable night mode */
/* Colorbar Mode */
#define COLORBAR_MODE_DISABLE 0x00U /* Disable colorbar mode */
#define COLORBAR_MODE_ENABLE 0x01U /* 8 bars W/Y/C/G/M/R/B/Bl */
#define COLORBAR_MODE_GRADUALV 0x02U /* Gradual vertical colorbar */
/* Pixel Clock */
#define OV5640_PCLK_7M 0x00U /* Pixel Clock set to 7Mhz */
#define OV5640_PCLK_8M 0x01U /* Pixel Clock set to 8Mhz */
#define OV5640_PCLK_9M 0x02U /* Pixel Clock set to 9Mhz */
#define OV5640_PCLK_12M 0x04U /* Pixel Clock set to 12Mhz */
#define OV5640_PCLK_24M 0x08U /* Pixel Clock set to 24Mhz */
#define OV5640_PCLK_48M 0x09U /* Pixel Clock set to 48MHz */
/* Mode */
#define PARALLEL_MODE 0x00U /* Parallel Interface Mode */
#define SERIAL_MODE 0x01U /* Serial Interface Mode */
/**
* @}
*/
/** @defgroup OV5640_Exported_Functions OV5640 Exported Functions
* @{
*/
int32_t OV5640_RegisterBusIO(OV5640_Object_t *pObj, OV5640_IO_t *pIO);
int32_t OV5640_Init(OV5640_Object_t *pObj, uint32_t Resolution, uint32_t PixelFormat);
int32_t OV5640_DeInit(OV5640_Object_t *pObj);
int32_t OV5640_ReadID(OV5640_Object_t *pObj, uint32_t *Id);
int32_t OV5640_GetCapabilities(OV5640_Object_t *pObj, OV5640_Capabilities_t *Capabilities);
int32_t OV5640_SetLightMode(OV5640_Object_t *pObj, uint32_t LightMode);
int32_t OV5640_SetColorEffect(OV5640_Object_t *pObj, uint32_t Effect);
int32_t OV5640_SetBrightness(OV5640_Object_t *pObj, int32_t Level);
int32_t OV5640_SetSaturation(OV5640_Object_t *pObj, int32_t Level);
int32_t OV5640_SetContrast(OV5640_Object_t *pObj, int32_t Level);
int32_t OV5640_SetHueDegree(OV5640_Object_t *pObj, int32_t Degree);
int32_t OV5640_MirrorFlipConfig(OV5640_Object_t *pObj, uint32_t Config);
int32_t OV5640_ZoomConfig(OV5640_Object_t *pObj, uint32_t Zoom);
int32_t OV5640_SetResolution(OV5640_Object_t *pObj, uint32_t Resolution);
int32_t OV5640_GetResolution(OV5640_Object_t *pObj, uint32_t *Resolution);
int32_t OV5640_SetPixelFormat(OV5640_Object_t *pObj, uint32_t PixelFormat);
int32_t OV5640_GetPixelFormat(OV5640_Object_t *pObj, uint32_t *PixelFormat);
int32_t OV5640_SetPolarities(OV5640_Object_t *pObj, uint32_t PclkPolarity, uint32_t HrefPolarity,
uint32_t VsyncPolarity);
int32_t OV5640_GetPolarities(OV5640_Object_t *pObj, uint32_t *PclkPolarity, uint32_t *HrefPolarity,
uint32_t *VsyncPolarity);
int32_t OV5640_NightModeConfig(OV5640_Object_t *pObj, uint32_t Cmd);
int32_t OV5640_ColorbarModeConfig(OV5640_Object_t *pObj, uint32_t Cmd);
int32_t OV5640_EmbeddedSynchroConfig(OV5640_Object_t *pObj, OV5640_SyncCodes_t *pSyncCodes);
int32_t OV5640_SetPCLK(OV5640_Object_t *pObj, uint32_t ClockValue);
int OV5640_EnableDVPMode(OV5640_Object_t *pObj);
int32_t OV5640_EnableMIPIMode(OV5640_Object_t *pObj);
int32_t OV5640_SetMIPIVirtualChannel(OV5640_Object_t *pObj, uint32_t vchannel);
int32_t OV5640_Start(OV5640_Object_t *pObj);
int32_t OV5640_Stop(OV5640_Object_t *pObj);
/* CAMERA driver structure */
extern OV5640_CAMERA_Drv_t OV5640_CAMERA_Driver;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* OV5640_H */
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/