-
Notifications
You must be signed in to change notification settings - Fork 4
/
stm32h747i_discovery_camera.h
280 lines (227 loc) · 9.08 KB
/
stm32h747i_discovery_camera.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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/**
******************************************************************************
* @file STM32H747I_discovery_camera.h
* @author MCD Application Team
* @brief This file contains the common defines and functions prototypes for
* the STM32H747I_discovery_camera.c driver.
******************************************************************************
* @attention
*
* Copyright (c) 2019 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 STM32H747I_DISCO_CAMERA_H
#define STM32H747I_DISCO_CAMERA_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32h747i_discovery_errno.h"
#include "stm32h747i_discovery_conf.h"
#include "camera.h"
#ifndef USE_CAMERA_SENSOR_OV9655
#define USE_CAMERA_SENSOR_OV9655 1
#endif
#ifndef USE_CAMERA_SENSOR_OV5640
#define USE_CAMERA_SENSOR_OV5640 1
#endif
#if (USE_CAMERA_SENSOR_OV9655 == 1)
#include "../Components/ov9655/ov9655.h"
#endif
#if (USE_CAMERA_SENSOR_OV5640 == 1)
#include "../Components/ov5640/ov5640.h"
#endif
#include "camera.h"
/** @addtogroup BSP
* @{
*/
/** @addtogroup STM32H747I_DISCO
* @{
*/
/** @defgroup STM32H747I_DISCO_CAMERA CAMERA
* @{
*/
/** @defgroup STM32H747I_DISCO_CAMERA_Exported_Types Exported Types
* @{
*/
typedef struct
{
uint32_t CameraId;
uint32_t Resolution;
uint32_t PixelFormat;
uint32_t LightMode;
uint32_t ColorEffect;
int32_t Brightness;
int32_t Saturation;
int32_t Contrast;
int32_t HueDegree;
uint32_t MirrorFlip;
uint32_t Zoom;
uint32_t NightMode;
uint32_t IsMspCallbacksValid;
}CAMERA_Ctx_t;
typedef struct
{
uint32_t Resolution;
uint32_t LightMode;
uint32_t ColorEffect;
uint32_t Brightness;
uint32_t Saturation;
uint32_t Contrast;
uint32_t HueDegree;
uint32_t MirrorFlip;
uint32_t Zoom;
uint32_t NightMode;
} CAMERA_Capabilities_t;
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
typedef struct
{
void (* pMspInitCb)(DCMI_HandleTypeDef *);
void (* pMspDeInitCb)(DCMI_HandleTypeDef *);
}BSP_CAMERA_Cb_t;
#endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS == 1) */
/**
* @}
*/
/** @defgroup STM32H747I_DISCO_CAMERA_Exported_Constants Exported Constants
* @{
*/
/* Camera instance number */
#define CAMERA_INSTANCES_NBR 1U
#define CAMERA_MODE_CONTINUOUS DCMI_MODE_CONTINUOUS
#define CAMERA_MODE_SNAPSHOT DCMI_MODE_SNAPSHOT
/* Camera resolutions */
#define CAMERA_R160x120 0U /* QQVGA Resolution */
#define CAMERA_R320x240 1U /* QVGA Resolution */
#define CAMERA_R480x272 2U /* 480x272 Resolution */
#define CAMERA_R640x480 3U /* VGA Resolution */
#define CAMERA_R800x480 4U /* WVGA Resolution */
/* Camera Pixel Format */
#define CAMERA_PF_RGB565 0U /* Pixel Format RGB565 */
#define CAMERA_PF_RGB888 1U /* Pixel Format RGB888 */
#define CAMERA_PF_YUV422 2U /* Pixel Format YUV422 */
/* Brightness */
#define CAMERA_BRIGHTNESS_MIN -4
#define CAMERA_BRIGHTNESS_MAX 4
/* Saturation */
#define CAMERA_SATURATION_MIN -4
#define CAMERA_SATURATION_MAX 4
/* Contrast */
#define CAMERA_CONTRAST_MIN -4
#define CAMERA_CONTRAST_MAX 4
/* Hue Control */
#define CAMERA_HUEDEGREE_MIN -6
#define CAMERA_HUEDEGREE_MAX 5
/* Mirror/Flip */
#define CAMERA_MIRRORFLIP_NONE 0x00U /* Set camera normal mode */
#define CAMERA_MIRRORFLIP_FLIP 0x01U /* Set camera flip config */
#define CAMERA_MIRRORFLIP_MIRROR 0x02U /* Set camera mirror config */
/* Zoom */
#define CAMERA_ZOOM_x8 0x00U /* Set zoom to x8 */
#define CAMERA_ZOOM_x4 0x11U /* Set zoom to x4 */
#define CAMERA_ZOOM_x2 0x22U /* Set zoom to x2 */
#define CAMERA_ZOOM_x1 0x44U /* Set zoom to x1 */
/* Color Effect */
#define CAMERA_COLOR_EFFECT_NONE 0x00U /* No effect */
#define CAMERA_COLOR_EFFECT_BLUE 0x01U /* Blue effect */
#define CAMERA_COLOR_EFFECT_RED 0x02U /* Red effect */
#define CAMERA_COLOR_EFFECT_GREEN 0x04U /* Green effect */
#define CAMERA_COLOR_EFFECT_BW 0x08U /* Black and White effect */
#define CAMERA_COLOR_EFFECT_SEPIA 0x10U /* Sepia effect */
#define CAMERA_COLOR_EFFECT_NEGATIVE 0x20U /* Negative effect */
/* Light Mode */
#define CAMERA_LIGHT_AUTO 0x00U /* Light Mode Auto */
#define CAMERA_LIGHT_SUNNY 0x01U /* Light Mode Sunny */
#define CAMERA_LIGHT_OFFICE 0x02U /* Light Mode Office */
#define CAMERA_LIGHT_HOME 0x04U /* Light Mode Home */
#define CAMERA_LIGHT_CLOUDY 0x08U /* Light Mode Claudy */
/* Night Mode */
#define CAMERA_NIGHT_MODE_SET 0x00U /* Disable night mode */
#define CAMERA_NIGHT_MODE_RESET 0x01U /* Enable night mode */
#define CAMERA_IRQHandler DCMI_IRQHandler
#define CAMERA_DMA_IRQHandler DMA2_Stream3_IRQHandler
#define CAMERA_OV9655_ADDRESS 0x60U
#define CAMERA_OV5640_ADDRESS 0x78U
/**
* @}
*/
/** @addtogroup STM32H747I_DISCO_CAMERA_Exported_Variables
* @{
*/
extern void *Camera_CompObj;
extern DCMI_HandleTypeDef hcamera_dcmi;
extern CAMERA_Ctx_t Camera_Ctx[];
/**
* @}
*/
/** @addtogroup STM32H747I_DISCO_CAMERA_Exported_Functions
* @{
*/
int32_t BSP_CAMERA_Init(uint32_t Instance, uint32_t Resolution, uint32_t PixelFormat);
int32_t BSP_CAMERA_DeInit(uint32_t Instance);
#if (USE_HAL_DCMI_REGISTER_CALLBACKS == 1)
int32_t BSP_CAMERA_RegisterDefaultMspCallbacks (uint32_t Instance);
int32_t BSP_CAMERA_RegisterMspCallbacks(uint32_t Instance, BSP_CAMERA_Cb_t *CallBacks);
#endif /* (USE_HAL_DCMI_REGISTER_CALLBACKS == 1) */
int32_t BSP_CAMERA_Start(uint32_t Instance, uint8_t *buff, uint32_t Mode);
int32_t BSP_CAMERA_Stop(uint32_t Instance);
int32_t BSP_CAMERA_Suspend(uint32_t Instance);
int32_t BSP_CAMERA_Resume(uint32_t Instance);
int32_t BSP_CAMERA_GetCapabilities(uint32_t Instance, CAMERA_Capabilities_t *Capabilities);
int32_t BSP_CAMERA_SetResolution(uint32_t Instance, uint32_t Resolution);
int32_t BSP_CAMERA_GetResolution(uint32_t Instance, uint32_t *Resolution);
int32_t BSP_CAMERA_SetPixelFormat(uint32_t Instance, uint32_t PixelFormat);
int32_t BSP_CAMERA_GetPixelFormat(uint32_t Instance, uint32_t *PixelFormat);
int32_t BSP_CAMERA_SetLightMode(uint32_t Instance, uint32_t LightMode);
int32_t BSP_CAMERA_GetLightMode(uint32_t Instance, uint32_t *LightMode);
int32_t BSP_CAMERA_SetColorEffect(uint32_t Instance, uint32_t ColorEffect);
int32_t BSP_CAMERA_GetColorEffect(uint32_t Instance, uint32_t *ColorEffect);
int32_t BSP_CAMERA_SetBrightness(uint32_t Instance, int32_t Brightness);
int32_t BSP_CAMERA_GetBrightness(uint32_t Instance, int32_t *Brightness);
int32_t BSP_CAMERA_SetSaturation(uint32_t Instance, int32_t Saturation);
int32_t BSP_CAMERA_GetSaturation(uint32_t Instance, int32_t *Saturation);
int32_t BSP_CAMERA_SetContrast(uint32_t Instance, int32_t Contrast);
int32_t BSP_CAMERA_GetContrast(uint32_t Instance, int32_t *Contrast);
int32_t BSP_CAMERA_SetHueDegree(uint32_t Instance, int32_t HueDegree);
int32_t BSP_CAMERA_GetHueDegree(uint32_t Instance, int32_t *HueDegree);
int32_t BSP_CAMERA_SetMirrorFlip(uint32_t Instance, uint32_t MirrorFlip);
int32_t BSP_CAMERA_GetMirrorFlip(uint32_t Instance, uint32_t *MirrorFlip);
int32_t BSP_CAMERA_SetZoom(uint32_t Instance, uint32_t Zoom);
int32_t BSP_CAMERA_GetZoom(uint32_t Instance, uint32_t *Zoom);
int32_t BSP_CAMERA_EnableNightMode(uint32_t Instance);
int32_t BSP_CAMERA_DisableNightMode(uint32_t Instance);
int32_t BSP_CAMERA_HwReset(uint32_t Instance);
int32_t BSP_CAMERA_PwrDown(uint32_t Instance);
int32_t BSP_CAMERA_PwrUp(uint32_t Instance);
void BSP_CAMERA_LineEventCallback(uint32_t Instance);
void BSP_CAMERA_FrameEventCallback(uint32_t Instance);
void BSP_CAMERA_VsyncEventCallback(uint32_t Instance);
void BSP_CAMERA_ErrorCallback(uint32_t Instance);
void BSP_CAMERA_IRQHandler(uint32_t Instance);
void BSP_CAMERA_DMA_IRQHandler(uint32_t Instance);
/* These functions can be modified in case the current settings (e.g. DMA stream)
need to be changed for specific application needs */
HAL_StatusTypeDef MX_DCMI_Init(DCMI_HandleTypeDef* hdcmi);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* STM32H747I_DISCO_CAMERA_H */