BSP_DISCO_L4R9I
Dependents: DISCO_L4R9I-LCD-demo
Drivers/BSP/STM32L4R9I-Discovery/stm32l4r9i_discovery_camera.c@1:2105b8894450, 2019-11-26 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Tue Nov 26 14:35:07 2019 +0100
- Revision:
- 1:2105b8894450
- Parent:
- 0:31ddfafdd3da
Update for MBED use
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jerome Coutant
0:31ddfafdd3da
|
1
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
2
|
******************************************************************************
|
|
Jerome Coutant
0:31ddfafdd3da
|
3
|
* @file stm32l4r9i_discovery_camera.c
|
|
Jerome Coutant
0:31ddfafdd3da
|
4
|
* @author MCD Application Team
|
|
Jerome Coutant
0:31ddfafdd3da
|
5
|
* @brief This file includes the driver for Camera modules mounted on
|
|
Jerome Coutant
0:31ddfafdd3da
|
6
|
* STM32L4R9I_DISCOVERY board.
|
|
Jerome Coutant
0:31ddfafdd3da
|
7
|
@verbatim
|
|
Jerome Coutant
0:31ddfafdd3da
|
8
|
How to use this driver:
|
|
Jerome Coutant
0:31ddfafdd3da
|
9
|
------------------------
|
|
Jerome Coutant
0:31ddfafdd3da
|
10
|
- This driver is used to drive the camera.
|
|
Jerome Coutant
0:31ddfafdd3da
|
11
|
- The OV9655 component driver MUST be included with this driver.
|
|
Jerome Coutant
0:31ddfafdd3da
|
12
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
13
|
Driver description:
|
|
Jerome Coutant
0:31ddfafdd3da
|
14
|
-------------------
|
|
Jerome Coutant
0:31ddfafdd3da
|
15
|
+ Initialization steps:
|
|
Jerome Coutant
0:31ddfafdd3da
|
16
|
o Initialize the camera using the BSP_CAMERA_Init() function.
|
|
Jerome Coutant
0:31ddfafdd3da
|
17
|
o Start the camera capture/snapshot using the CAMERA_Start() function.
|
|
Jerome Coutant
0:31ddfafdd3da
|
18
|
o Suspend, resume or stop the camera capture using the following functions:
|
|
Jerome Coutant
0:31ddfafdd3da
|
19
|
- BSP_CAMERA_Suspend()
|
|
Jerome Coutant
0:31ddfafdd3da
|
20
|
- BSP_CAMERA_Resume()
|
|
Jerome Coutant
0:31ddfafdd3da
|
21
|
- BSP_CAMERA_Stop()
|
|
Jerome Coutant
0:31ddfafdd3da
|
22
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
23
|
+ Options
|
|
Jerome Coutant
0:31ddfafdd3da
|
24
|
o Increase or decrease on the fly the brightness and/or contrast
|
|
Jerome Coutant
0:31ddfafdd3da
|
25
|
using the following function:
|
|
Jerome Coutant
0:31ddfafdd3da
|
26
|
- BSP_CAMERA_ContrastBrightnessConfig
|
|
Jerome Coutant
0:31ddfafdd3da
|
27
|
o Add a special effect on the fly using the following functions:
|
|
Jerome Coutant
0:31ddfafdd3da
|
28
|
- BSP_CAMERA_BlackWhiteConfig()
|
|
Jerome Coutant
0:31ddfafdd3da
|
29
|
- BSP_CAMERA_ColorEffectConfig()
|
|
Jerome Coutant
0:31ddfafdd3da
|
30
|
@endverbatim
|
|
Jerome Coutant
0:31ddfafdd3da
|
31
|
******************************************************************************
|
|
Jerome Coutant
0:31ddfafdd3da
|
32
|
* @attention
|
|
Jerome Coutant
0:31ddfafdd3da
|
33
|
*
|
|
Jerome Coutant
0:31ddfafdd3da
|
34
|
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
|
Jerome Coutant
0:31ddfafdd3da
|
35
|
* All rights reserved.</center></h2>
|
|
Jerome Coutant
0:31ddfafdd3da
|
36
|
*
|
|
Jerome Coutant
0:31ddfafdd3da
|
37
|
* This software component is licensed by ST under BSD 3-Clause license,
|
|
Jerome Coutant
0:31ddfafdd3da
|
38
|
* the "License"; You may not use this file except in compliance with the
|
|
Jerome Coutant
0:31ddfafdd3da
|
39
|
* License. You may obtain a copy of the License at:
|
|
Jerome Coutant
0:31ddfafdd3da
|
40
|
* opensource.org/licenses/BSD-3-Clause
|
|
Jerome Coutant
0:31ddfafdd3da
|
41
|
*
|
|
Jerome Coutant
0:31ddfafdd3da
|
42
|
******************************************************************************
|
|
Jerome Coutant
0:31ddfafdd3da
|
43
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
44
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
45
|
/* Includes ------------------------------------------------------------------*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
46
|
#include "stm32l4r9i_discovery_camera.h"
|
|
Jerome Coutant
0:31ddfafdd3da
|
47
|
#include "stm32l4r9i_discovery.h"
|
|
Jerome Coutant
0:31ddfafdd3da
|
48
|
#include "stm32l4r9i_discovery_io.h"
|
|
Jerome Coutant
0:31ddfafdd3da
|
49
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
50
|
/** @addtogroup BSP
|
|
Jerome Coutant
0:31ddfafdd3da
|
51
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
52
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
53
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
54
|
/** @addtogroup STM32L4R9I_DISCOVERY
|
|
Jerome Coutant
0:31ddfafdd3da
|
55
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
56
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
57
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
58
|
/** @defgroup STM32L4R9I_DISCOVERY_CAMERA STM32L4R9I_DISCOVERY CAMERA
|
|
Jerome Coutant
0:31ddfafdd3da
|
59
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
60
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
61
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
62
|
/** @defgroup STM32L4R9I_DISCOVERY_CAMERA_Private_Defines Private Defines
|
|
Jerome Coutant
0:31ddfafdd3da
|
63
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
64
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
65
|
#define CAMERA_VGA_RES_X 640
|
|
Jerome Coutant
0:31ddfafdd3da
|
66
|
#define CAMERA_VGA_RES_Y 480
|
|
Jerome Coutant
0:31ddfafdd3da
|
67
|
#define CAMERA_480x272_RES_X 480
|
|
Jerome Coutant
0:31ddfafdd3da
|
68
|
#define CAMERA_480x272_RES_Y 272
|
|
Jerome Coutant
0:31ddfafdd3da
|
69
|
#define CAMERA_QVGA_RES_X 320
|
|
Jerome Coutant
0:31ddfafdd3da
|
70
|
#define CAMERA_QVGA_RES_Y 240
|
|
Jerome Coutant
0:31ddfafdd3da
|
71
|
#define CAMERA_QQVGA_RES_X 160
|
|
Jerome Coutant
0:31ddfafdd3da
|
72
|
#define CAMERA_QQVGA_RES_Y 120
|
|
Jerome Coutant
0:31ddfafdd3da
|
73
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
74
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
75
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
76
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
77
|
/** @defgroup STM32L4R9I_DISCOVERY_CAMERA_Private_Variables Private Variables
|
|
Jerome Coutant
0:31ddfafdd3da
|
78
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
79
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
80
|
DCMI_HandleTypeDef hDcmiHandler;
|
|
Jerome Coutant
0:31ddfafdd3da
|
81
|
CAMERA_DrvTypeDef *camera_drv;
|
|
Jerome Coutant
0:31ddfafdd3da
|
82
|
/* Camera current resolution naming (QQVGA, VGA, ...) */
|
|
Jerome Coutant
0:31ddfafdd3da
|
83
|
static uint32_t CameraCurrentResolution;
|
|
Jerome Coutant
0:31ddfafdd3da
|
84
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
85
|
/* Camera module I2C HW address */
|
|
Jerome Coutant
0:31ddfafdd3da
|
86
|
static uint32_t CameraHwAddress;
|
|
Jerome Coutant
0:31ddfafdd3da
|
87
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
88
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
89
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
90
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
91
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
92
|
/** @defgroup STM32L4R9I_DISCOVERY_CAMERA_Private_FunctionPrototypes Private Function Prototypes
|
|
Jerome Coutant
0:31ddfafdd3da
|
93
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
94
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
95
|
static uint32_t GetSize(uint32_t resolution);
|
|
Jerome Coutant
0:31ddfafdd3da
|
96
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
97
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
98
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
99
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
100
|
/** @defgroup STM32L4R9I_DISCOVERY_CAMERA_Exported_Functions Exported Functions
|
|
Jerome Coutant
0:31ddfafdd3da
|
101
|
* @{
|
|
Jerome Coutant
0:31ddfafdd3da
|
102
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
103
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
104
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
105
|
* @brief Initializes the camera.
|
|
Jerome Coutant
0:31ddfafdd3da
|
106
|
* @param Resolution : camera sensor requested resolution (x, y) : standard resolution
|
|
Jerome Coutant
0:31ddfafdd3da
|
107
|
* naming QQVGA, QVGA, VGA ...
|
|
Jerome Coutant
0:31ddfafdd3da
|
108
|
* @retval Camera status
|
|
Jerome Coutant
0:31ddfafdd3da
|
109
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
110
|
uint8_t BSP_CAMERA_Init(uint32_t Resolution)
|
|
Jerome Coutant
0:31ddfafdd3da
|
111
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
112
|
DCMI_HandleTypeDef *phdcmi;
|
|
Jerome Coutant
0:31ddfafdd3da
|
113
|
uint8_t status = CAMERA_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
114
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
115
|
/* Get the DCMI handle structure */
|
|
Jerome Coutant
0:31ddfafdd3da
|
116
|
phdcmi = &hDcmiHandler;
|
|
Jerome Coutant
0:31ddfafdd3da
|
117
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
118
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
119
|
/* Initialize the IO functionalities */
|
|
Jerome Coutant
0:31ddfafdd3da
|
120
|
BSP_IO_Init();
|
|
Jerome Coutant
0:31ddfafdd3da
|
121
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
122
|
/* Set up the Camera */
|
|
Jerome Coutant
0:31ddfafdd3da
|
123
|
BSP_CAMERA_PwrUp();
|
|
Jerome Coutant
0:31ddfafdd3da
|
124
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
125
|
/*** Configures the DCMI to interface with the camera module ***/
|
|
Jerome Coutant
0:31ddfafdd3da
|
126
|
/* DCMI configuration */
|
|
Jerome Coutant
0:31ddfafdd3da
|
127
|
phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME;
|
|
Jerome Coutant
0:31ddfafdd3da
|
128
|
phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
129
|
phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
130
|
phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
131
|
phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B;
|
|
Jerome Coutant
0:31ddfafdd3da
|
132
|
phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
|
|
Jerome Coutant
0:31ddfafdd3da
|
133
|
phdcmi->Init.ByteSelectMode = DCMI_BSM_ALL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
134
|
phdcmi->Init.ByteSelectStart = DCMI_OEBS_ODD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
135
|
phdcmi->Init.LineSelectMode = DCMI_LSM_ALL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
136
|
phdcmi->Instance = DCMI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
137
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
138
|
/* Camera initialization */
|
|
Jerome Coutant
0:31ddfafdd3da
|
139
|
BSP_CAMERA_MspInit(&hDcmiHandler, NULL);
|
|
Jerome Coutant
0:31ddfafdd3da
|
140
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
141
|
/* Read ID of Camera module via I2C */
|
|
Jerome Coutant
0:31ddfafdd3da
|
142
|
if(ov9655_ReadID(CAMERA_I2C_ADDRESS) == OV9655_ID)
|
|
Jerome Coutant
0:31ddfafdd3da
|
143
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
144
|
/* Initialize the camera driver structure */
|
|
Jerome Coutant
0:31ddfafdd3da
|
145
|
camera_drv = &ov9655_drv;
|
|
Jerome Coutant
0:31ddfafdd3da
|
146
|
CameraHwAddress = CAMERA_I2C_ADDRESS;
|
|
Jerome Coutant
0:31ddfafdd3da
|
147
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
148
|
/* DCMI Initialization */
|
|
Jerome Coutant
0:31ddfafdd3da
|
149
|
HAL_DCMI_Init(phdcmi);
|
|
Jerome Coutant
0:31ddfafdd3da
|
150
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
151
|
camera_drv->Init(CameraHwAddress, Resolution);
|
|
Jerome Coutant
0:31ddfafdd3da
|
152
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
153
|
/* Set the RGB565 mode */
|
|
Jerome Coutant
0:31ddfafdd3da
|
154
|
MFX_IO_Write(CameraHwAddress, 0x12 /*OV9655_COM7*/, 0x63);
|
|
Jerome Coutant
0:31ddfafdd3da
|
155
|
MFX_IO_Write(CameraHwAddress, 0x40 /*OV9655_COM15*/, 0x10);
|
|
Jerome Coutant
0:31ddfafdd3da
|
156
|
/* Invert the HRef signal */
|
|
Jerome Coutant
0:31ddfafdd3da
|
157
|
MFX_IO_Write(CameraHwAddress, 0x15 /*OV9655_COM10*/, 0x08);
|
|
Jerome Coutant
0:31ddfafdd3da
|
158
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
159
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
160
|
CameraCurrentResolution = Resolution;
|
|
Jerome Coutant
0:31ddfafdd3da
|
161
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
162
|
/* Return CAMERA_OK status */
|
|
Jerome Coutant
0:31ddfafdd3da
|
163
|
status = CAMERA_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
164
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
165
|
else
|
|
Jerome Coutant
0:31ddfafdd3da
|
166
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
167
|
/* Return CAMERA_NOT_SUPPORTED status */
|
|
Jerome Coutant
0:31ddfafdd3da
|
168
|
status = CAMERA_NOT_SUPPORTED;
|
|
Jerome Coutant
0:31ddfafdd3da
|
169
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
170
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
171
|
return status;
|
|
Jerome Coutant
0:31ddfafdd3da
|
172
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
173
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
174
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
175
|
* @brief DeInitializes the camera.
|
|
Jerome Coutant
0:31ddfafdd3da
|
176
|
* @retval Camera status
|
|
Jerome Coutant
0:31ddfafdd3da
|
177
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
178
|
uint8_t BSP_CAMERA_DeInit(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
179
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
180
|
hDcmiHandler.Instance = DCMI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
181
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
182
|
HAL_DCMI_DeInit(&hDcmiHandler);
|
|
Jerome Coutant
0:31ddfafdd3da
|
183
|
BSP_CAMERA_MspDeInit(&hDcmiHandler, NULL);
|
|
Jerome Coutant
0:31ddfafdd3da
|
184
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
185
|
/* Set Camera in Power Down */
|
|
Jerome Coutant
0:31ddfafdd3da
|
186
|
BSP_CAMERA_PwrDown();
|
|
Jerome Coutant
0:31ddfafdd3da
|
187
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
188
|
return CAMERA_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
189
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
190
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
191
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
192
|
* @brief Starts the camera capture in continuous mode.
|
|
Jerome Coutant
0:31ddfafdd3da
|
193
|
* @param buff: pointer to the camera output buffer
|
|
Jerome Coutant
0:31ddfafdd3da
|
194
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
195
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
196
|
void BSP_CAMERA_ContinuousStart(uint8_t *buff)
|
|
Jerome Coutant
0:31ddfafdd3da
|
197
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
198
|
/* Start the camera capture */
|
|
Jerome Coutant
0:31ddfafdd3da
|
199
|
HAL_DCMI_Start_DMA(&hDcmiHandler, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(CameraCurrentResolution));
|
|
Jerome Coutant
0:31ddfafdd3da
|
200
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
201
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
202
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
203
|
* @brief Starts the camera capture in snapshot mode.
|
|
Jerome Coutant
0:31ddfafdd3da
|
204
|
* @param buff: pointer to the camera output buffer
|
|
Jerome Coutant
0:31ddfafdd3da
|
205
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
206
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
207
|
void BSP_CAMERA_SnapshotStart(uint8_t *buff)
|
|
Jerome Coutant
0:31ddfafdd3da
|
208
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
209
|
/* Start the camera capture */
|
|
Jerome Coutant
0:31ddfafdd3da
|
210
|
HAL_DCMI_Start_DMA(&hDcmiHandler, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(CameraCurrentResolution));
|
|
Jerome Coutant
0:31ddfafdd3da
|
211
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
212
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
213
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
214
|
* @brief Suspend the CAMERA capture
|
|
Jerome Coutant
0:31ddfafdd3da
|
215
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
216
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
217
|
void BSP_CAMERA_Suspend(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
218
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
219
|
/* Suspend the Camera Capture */
|
|
Jerome Coutant
0:31ddfafdd3da
|
220
|
HAL_DCMI_Suspend(&hDcmiHandler);
|
|
Jerome Coutant
0:31ddfafdd3da
|
221
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
222
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
223
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
224
|
* @brief Resume the CAMERA capture
|
|
Jerome Coutant
0:31ddfafdd3da
|
225
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
226
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
227
|
void BSP_CAMERA_Resume(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
228
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
229
|
/* Start the Camera Capture */
|
|
Jerome Coutant
0:31ddfafdd3da
|
230
|
HAL_DCMI_Resume(&hDcmiHandler);
|
|
Jerome Coutant
0:31ddfafdd3da
|
231
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
232
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
233
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
234
|
* @brief Stop the CAMERA capture
|
|
Jerome Coutant
0:31ddfafdd3da
|
235
|
* @retval Camera status
|
|
Jerome Coutant
0:31ddfafdd3da
|
236
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
237
|
uint8_t BSP_CAMERA_Stop(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
238
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
239
|
uint8_t status = CAMERA_ERROR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
240
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
241
|
if(HAL_DCMI_Stop(&hDcmiHandler) == HAL_OK)
|
|
Jerome Coutant
0:31ddfafdd3da
|
242
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
243
|
status = CAMERA_OK;
|
|
Jerome Coutant
0:31ddfafdd3da
|
244
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
245
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
246
|
return status;
|
|
Jerome Coutant
0:31ddfafdd3da
|
247
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
248
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
249
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
250
|
* @brief CANERA power up
|
|
Jerome Coutant
0:31ddfafdd3da
|
251
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
252
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
253
|
void BSP_CAMERA_PwrUp(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
254
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
255
|
/* De-assert the camera POWER_DOWN pin (active high) */
|
|
Jerome Coutant
0:31ddfafdd3da
|
256
|
BSP_IO_WritePin(CAMERA_PWR_EN_PIN, GPIO_PIN_RESET);
|
|
Jerome Coutant
0:31ddfafdd3da
|
257
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
258
|
HAL_Delay(3); /* POWER_DOWN de-asserted during 3ms */
|
|
Jerome Coutant
0:31ddfafdd3da
|
259
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
260
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
261
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
262
|
* @brief CAMERA power down
|
|
Jerome Coutant
0:31ddfafdd3da
|
263
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
264
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
265
|
void BSP_CAMERA_PwrDown(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
266
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
267
|
/* Assert the camera POWER_DOWN pin (active high) */
|
|
Jerome Coutant
0:31ddfafdd3da
|
268
|
BSP_IO_WritePin(CAMERA_PWR_EN_PIN, GPIO_PIN_SET);
|
|
Jerome Coutant
0:31ddfafdd3da
|
269
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
270
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
271
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
272
|
* @brief Configures the camera contrast and brightness.
|
|
Jerome Coutant
0:31ddfafdd3da
|
273
|
* @param contrast_level: Contrast level
|
|
Jerome Coutant
0:31ddfafdd3da
|
274
|
* This parameter can be one of the following values:
|
|
Jerome Coutant
0:31ddfafdd3da
|
275
|
* @arg CAMERA_CONTRAST_LEVEL4: for contrast +2
|
|
Jerome Coutant
0:31ddfafdd3da
|
276
|
* @arg CAMERA_CONTRAST_LEVEL3: for contrast +1
|
|
Jerome Coutant
0:31ddfafdd3da
|
277
|
* @arg CAMERA_CONTRAST_LEVEL2: for contrast 0
|
|
Jerome Coutant
0:31ddfafdd3da
|
278
|
* @arg CAMERA_CONTRAST_LEVEL1: for contrast -1
|
|
Jerome Coutant
0:31ddfafdd3da
|
279
|
* @arg CAMERA_CONTRAST_LEVEL0: for contrast -2
|
|
Jerome Coutant
0:31ddfafdd3da
|
280
|
* @param brightness_level: Contrast level
|
|
Jerome Coutant
0:31ddfafdd3da
|
281
|
* This parameter can be one of the following values:
|
|
Jerome Coutant
0:31ddfafdd3da
|
282
|
* @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2
|
|
Jerome Coutant
0:31ddfafdd3da
|
283
|
* @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1
|
|
Jerome Coutant
0:31ddfafdd3da
|
284
|
* @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0
|
|
Jerome Coutant
0:31ddfafdd3da
|
285
|
* @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1
|
|
Jerome Coutant
0:31ddfafdd3da
|
286
|
* @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2
|
|
Jerome Coutant
0:31ddfafdd3da
|
287
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
288
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
289
|
void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level)
|
|
Jerome Coutant
0:31ddfafdd3da
|
290
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
291
|
if(camera_drv->Config != NULL)
|
|
Jerome Coutant
0:31ddfafdd3da
|
292
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
293
|
camera_drv->Config(CameraHwAddress, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level);
|
|
Jerome Coutant
0:31ddfafdd3da
|
294
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
295
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
296
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
297
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
298
|
* @brief Configures the camera white balance.
|
|
Jerome Coutant
0:31ddfafdd3da
|
299
|
* @param Mode: black_white mode
|
|
Jerome Coutant
0:31ddfafdd3da
|
300
|
* This parameter can be one of the following values:
|
|
Jerome Coutant
0:31ddfafdd3da
|
301
|
* @arg CAMERA_BLACK_WHITE_BW
|
|
Jerome Coutant
0:31ddfafdd3da
|
302
|
* @arg CAMERA_BLACK_WHITE_NEGATIVE
|
|
Jerome Coutant
0:31ddfafdd3da
|
303
|
* @arg CAMERA_BLACK_WHITE_BW_NEGATIVE
|
|
Jerome Coutant
0:31ddfafdd3da
|
304
|
* @arg CAMERA_BLACK_WHITE_NORMAL
|
|
Jerome Coutant
0:31ddfafdd3da
|
305
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
306
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
307
|
void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode)
|
|
Jerome Coutant
0:31ddfafdd3da
|
308
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
309
|
if(camera_drv->Config != NULL)
|
|
Jerome Coutant
0:31ddfafdd3da
|
310
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
311
|
camera_drv->Config(CameraHwAddress, CAMERA_BLACK_WHITE, Mode, 0);
|
|
Jerome Coutant
0:31ddfafdd3da
|
312
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
313
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
314
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
315
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
316
|
* @brief Configures the camera color effect.
|
|
Jerome Coutant
0:31ddfafdd3da
|
317
|
* @param Effect: Color effect
|
|
Jerome Coutant
0:31ddfafdd3da
|
318
|
* This parameter can be one of the following values:
|
|
Jerome Coutant
0:31ddfafdd3da
|
319
|
* @arg CAMERA_COLOR_EFFECT_ANTIQUE
|
|
Jerome Coutant
0:31ddfafdd3da
|
320
|
* @arg CAMERA_COLOR_EFFECT_BLUE
|
|
Jerome Coutant
0:31ddfafdd3da
|
321
|
* @arg CAMERA_COLOR_EFFECT_GREEN
|
|
Jerome Coutant
0:31ddfafdd3da
|
322
|
* @arg CAMERA_COLOR_EFFECT_RED
|
|
Jerome Coutant
0:31ddfafdd3da
|
323
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
324
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
325
|
void BSP_CAMERA_ColorEffectConfig(uint32_t Effect)
|
|
Jerome Coutant
0:31ddfafdd3da
|
326
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
327
|
if(camera_drv->Config != NULL)
|
|
Jerome Coutant
0:31ddfafdd3da
|
328
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
329
|
camera_drv->Config(CameraHwAddress, CAMERA_COLOR_EFFECT, Effect, 0);
|
|
Jerome Coutant
0:31ddfafdd3da
|
330
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
331
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
332
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
333
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
334
|
* @brief Get the capture size in pixels unit.
|
|
Jerome Coutant
0:31ddfafdd3da
|
335
|
* @param resolution: the current resolution.
|
|
Jerome Coutant
0:31ddfafdd3da
|
336
|
* @retval capture size in pixels unit.
|
|
Jerome Coutant
0:31ddfafdd3da
|
337
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
338
|
static uint32_t GetSize(uint32_t resolution)
|
|
Jerome Coutant
0:31ddfafdd3da
|
339
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
340
|
uint32_t size = 0;
|
|
Jerome Coutant
0:31ddfafdd3da
|
341
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
342
|
/* Get capture size */
|
|
Jerome Coutant
0:31ddfafdd3da
|
343
|
switch (resolution)
|
|
Jerome Coutant
0:31ddfafdd3da
|
344
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
345
|
case CAMERA_R160x120:
|
|
Jerome Coutant
0:31ddfafdd3da
|
346
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
347
|
size = 0x2580;
|
|
Jerome Coutant
0:31ddfafdd3da
|
348
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
349
|
break;
|
|
Jerome Coutant
0:31ddfafdd3da
|
350
|
case CAMERA_R320x240:
|
|
Jerome Coutant
0:31ddfafdd3da
|
351
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
352
|
size = 0x9600;
|
|
Jerome Coutant
0:31ddfafdd3da
|
353
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
354
|
break;
|
|
Jerome Coutant
0:31ddfafdd3da
|
355
|
case CAMERA_R480x272:
|
|
Jerome Coutant
0:31ddfafdd3da
|
356
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
357
|
size = 0xFF00;
|
|
Jerome Coutant
0:31ddfafdd3da
|
358
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
359
|
break;
|
|
Jerome Coutant
0:31ddfafdd3da
|
360
|
case CAMERA_R640x480:
|
|
Jerome Coutant
0:31ddfafdd3da
|
361
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
362
|
size = 0x25800;
|
|
Jerome Coutant
0:31ddfafdd3da
|
363
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
364
|
break;
|
|
Jerome Coutant
0:31ddfafdd3da
|
365
|
default:
|
|
Jerome Coutant
0:31ddfafdd3da
|
366
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
367
|
break;
|
|
Jerome Coutant
0:31ddfafdd3da
|
368
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
369
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
370
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
371
|
return size;
|
|
Jerome Coutant
0:31ddfafdd3da
|
372
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
373
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
374
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
375
|
* @brief Initializes the DCMI MSP.
|
|
Jerome Coutant
0:31ddfafdd3da
|
376
|
* @param hdcmi: HDMI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
377
|
* @param Params
|
|
Jerome Coutant
0:31ddfafdd3da
|
378
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
379
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
380
|
__weak void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params)
|
|
Jerome Coutant
0:31ddfafdd3da
|
381
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
382
|
static DMA_HandleTypeDef hdma_handler;
|
|
Jerome Coutant
0:31ddfafdd3da
|
383
|
GPIO_InitTypeDef gpio_init_structure;
|
|
Jerome Coutant
0:31ddfafdd3da
|
384
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
385
|
/*** Enable peripherals and GPIO clocks ***/
|
|
Jerome Coutant
0:31ddfafdd3da
|
386
|
/* Enable DCMI clock */
|
|
Jerome Coutant
0:31ddfafdd3da
|
387
|
__HAL_RCC_DCMI_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
388
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
389
|
/* Enable DMA2 clock */
|
|
Jerome Coutant
0:31ddfafdd3da
|
390
|
__HAL_RCC_DMA2_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
391
|
/* Enable DMAmux1 clock to be able to use DMA_REQUEST_DCMI */
|
|
Jerome Coutant
0:31ddfafdd3da
|
392
|
__HAL_RCC_DMAMUX1_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
393
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
394
|
/* Enable GPIO clocks */
|
|
Jerome Coutant
0:31ddfafdd3da
|
395
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
396
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
397
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
398
|
__HAL_RCC_GPIOI_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
399
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
400
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
401
|
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_SYSCLK, RCC_MCODIV_4); /* PA8 Camera modul input clock 20 MHz */
|
|
Jerome Coutant
0:31ddfafdd3da
|
402
|
__HAL_RCC_HSI48_ENABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
403
|
HAL_Delay(10); // HSI48 should start in 10ms
|
|
Jerome Coutant
0:31ddfafdd3da
|
404
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
405
|
/*** Configure the GPIO ***/
|
|
Jerome Coutant
0:31ddfafdd3da
|
406
|
/* Configure DCMI GPIO as alternate function */
|
|
Jerome Coutant
0:31ddfafdd3da
|
407
|
gpio_init_structure.Pin = GPIO_PIN_6 | GPIO_PIN_7;
|
|
Jerome Coutant
0:31ddfafdd3da
|
408
|
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
409
|
gpio_init_structure.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
410
|
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
411
|
gpio_init_structure.Alternate = GPIO_AF10_DCMI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
412
|
HAL_GPIO_Init(GPIOC, &gpio_init_structure);
|
|
Jerome Coutant
0:31ddfafdd3da
|
413
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
414
|
gpio_init_structure.Pin = GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_5;
|
|
Jerome Coutant
0:31ddfafdd3da
|
415
|
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
416
|
gpio_init_structure.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
417
|
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
418
|
gpio_init_structure.Alternate = GPIO_AF10_DCMI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
419
|
HAL_GPIO_Init(GPIOH, &gpio_init_structure);
|
|
Jerome Coutant
0:31ddfafdd3da
|
420
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
421
|
gpio_init_structure.Pin = GPIO_PIN_4;
|
|
Jerome Coutant
0:31ddfafdd3da
|
422
|
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
423
|
gpio_init_structure.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
424
|
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
425
|
gpio_init_structure.Alternate = GPIO_AF10_DCMI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
426
|
HAL_GPIO_Init(GPIOE, &gpio_init_structure);
|
|
Jerome Coutant
0:31ddfafdd3da
|
427
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
428
|
gpio_init_structure.Pin = GPIO_PIN_4 | GPIO_PIN_7 | GPIO_PIN_5;
|
|
Jerome Coutant
0:31ddfafdd3da
|
429
|
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
430
|
gpio_init_structure.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
431
|
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
432
|
gpio_init_structure.Alternate = GPIO_AF10_DCMI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
433
|
HAL_GPIO_Init(GPIOI, &gpio_init_structure);
|
|
Jerome Coutant
0:31ddfafdd3da
|
434
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
435
|
gpio_init_structure.Pin = GPIO_PIN_4;
|
|
Jerome Coutant
0:31ddfafdd3da
|
436
|
gpio_init_structure.Mode = GPIO_MODE_AF_PP;
|
|
Jerome Coutant
0:31ddfafdd3da
|
437
|
gpio_init_structure.Pull = GPIO_NOPULL;
|
|
Jerome Coutant
0:31ddfafdd3da
|
438
|
gpio_init_structure.Speed = GPIO_SPEED_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
439
|
gpio_init_structure.Alternate = GPIO_AF10_DCMI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
440
|
HAL_GPIO_Init(GPIOA, &gpio_init_structure);
|
|
Jerome Coutant
0:31ddfafdd3da
|
441
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
442
|
/*** Configure the DMA ***/
|
|
Jerome Coutant
0:31ddfafdd3da
|
443
|
/* Set the parameters to be configured */
|
|
Jerome Coutant
0:31ddfafdd3da
|
444
|
hdma_handler.Instance = BSP_CAMERA_DMA_INSTANCE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
445
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
446
|
hdma_handler.Init.Request = DMA_REQUEST_DCMI;
|
|
Jerome Coutant
0:31ddfafdd3da
|
447
|
hdma_handler.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
|
Jerome Coutant
0:31ddfafdd3da
|
448
|
hdma_handler.Init.PeriphInc = DMA_PINC_DISABLE;
|
|
Jerome Coutant
0:31ddfafdd3da
|
449
|
hdma_handler.Init.MemInc = DMA_MINC_ENABLE; /* Image captured by the DCMI is stored in memory */
|
|
Jerome Coutant
0:31ddfafdd3da
|
450
|
hdma_handler.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
451
|
hdma_handler.Init.MemDataAlignment = DMA_MDATAALIGN_WORD;
|
|
Jerome Coutant
0:31ddfafdd3da
|
452
|
hdma_handler.Init.Mode = DMA_CIRCULAR;
|
|
Jerome Coutant
0:31ddfafdd3da
|
453
|
hdma_handler.Init.Priority = DMA_PRIORITY_HIGH;
|
|
Jerome Coutant
0:31ddfafdd3da
|
454
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
455
|
/* Associate the initialized DMA handle to the DCMI handle */
|
|
Jerome Coutant
0:31ddfafdd3da
|
456
|
__HAL_LINKDMA(hdcmi, DMA_Handle, hdma_handler);
|
|
Jerome Coutant
0:31ddfafdd3da
|
457
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
458
|
/*** Configure the NVIC for DCMI and DMA ***/
|
|
Jerome Coutant
0:31ddfafdd3da
|
459
|
/* NVIC configuration for DCMI transfer complete interrupt */
|
|
Jerome Coutant
0:31ddfafdd3da
|
460
|
HAL_NVIC_SetPriority(DCMI_IRQn, 0x0F, 0);
|
|
Jerome Coutant
0:31ddfafdd3da
|
461
|
HAL_NVIC_EnableIRQ(DCMI_IRQn);
|
|
Jerome Coutant
0:31ddfafdd3da
|
462
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
463
|
/* NVIC configuration for DMA2D transfer complete interrupt */
|
|
Jerome Coutant
0:31ddfafdd3da
|
464
|
HAL_NVIC_SetPriority(DMA2_Channel6_IRQn, 0x0F, 0);
|
|
Jerome Coutant
0:31ddfafdd3da
|
465
|
HAL_NVIC_EnableIRQ(DMA2_Channel6_IRQn);
|
|
Jerome Coutant
0:31ddfafdd3da
|
466
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
467
|
/* Configure the DMA stream */
|
|
Jerome Coutant
0:31ddfafdd3da
|
468
|
HAL_DMA_Init(hdcmi->DMA_Handle);
|
|
Jerome Coutant
0:31ddfafdd3da
|
469
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
470
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
471
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
472
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
473
|
* @brief DeInitializes the DCMI MSP.
|
|
Jerome Coutant
0:31ddfafdd3da
|
474
|
* @param hdcmi: HDMI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
475
|
* @param Params
|
|
Jerome Coutant
0:31ddfafdd3da
|
476
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
477
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
478
|
__weak void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params)
|
|
Jerome Coutant
0:31ddfafdd3da
|
479
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
480
|
/* Disable NVIC for DCMI transfer complete interrupt */
|
|
Jerome Coutant
0:31ddfafdd3da
|
481
|
HAL_NVIC_DisableIRQ(DCMI_IRQn);
|
|
Jerome Coutant
0:31ddfafdd3da
|
482
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
483
|
/* Disable NVIC for DMA2 transfer complete interrupt */
|
|
Jerome Coutant
0:31ddfafdd3da
|
484
|
HAL_NVIC_DisableIRQ(DMA2_Channel6_IRQn);
|
|
Jerome Coutant
0:31ddfafdd3da
|
485
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
486
|
/* Configure the DMA stream */
|
|
Jerome Coutant
0:31ddfafdd3da
|
487
|
HAL_DMA_DeInit(hdcmi->DMA_Handle);
|
|
Jerome Coutant
0:31ddfafdd3da
|
488
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
489
|
/* Disable DCMI clock */
|
|
Jerome Coutant
0:31ddfafdd3da
|
490
|
__HAL_RCC_DCMI_CLK_DISABLE();
|
|
Jerome Coutant
0:31ddfafdd3da
|
491
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
492
|
/* GPIO pins clock and DMA clock can be shut down in the application
|
|
Jerome Coutant
0:31ddfafdd3da
|
493
|
by surcharging this __weak function */
|
|
Jerome Coutant
0:31ddfafdd3da
|
494
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
495
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
496
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
497
|
* @brief Line event callback
|
|
Jerome Coutant
0:31ddfafdd3da
|
498
|
* @param hdcmi: pointer to the DCMI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
499
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
500
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
501
|
void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi)
|
|
Jerome Coutant
0:31ddfafdd3da
|
502
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
503
|
BSP_CAMERA_LineEventCallback();
|
|
Jerome Coutant
0:31ddfafdd3da
|
504
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
505
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
506
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
507
|
* @brief Line Event callback.
|
|
Jerome Coutant
0:31ddfafdd3da
|
508
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
509
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
510
|
__weak void BSP_CAMERA_LineEventCallback(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
511
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
512
|
/* NOTE : This function should not be modified; when the callback is needed,
|
|
Jerome Coutant
0:31ddfafdd3da
|
513
|
the BSP_CAMERA_LineEventCallback can be implemented in the user file
|
|
Jerome Coutant
0:31ddfafdd3da
|
514
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
515
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
516
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
517
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
518
|
* @brief VSYNC event callback
|
|
Jerome Coutant
0:31ddfafdd3da
|
519
|
* @param hdcmi: pointer to the DCMI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
520
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
521
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
522
|
void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi)
|
|
Jerome Coutant
0:31ddfafdd3da
|
523
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
524
|
BSP_CAMERA_VsyncEventCallback();
|
|
Jerome Coutant
0:31ddfafdd3da
|
525
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
526
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
527
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
528
|
* @brief VSYNC Event callback.
|
|
Jerome Coutant
0:31ddfafdd3da
|
529
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
530
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
531
|
__weak void BSP_CAMERA_VsyncEventCallback(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
532
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
533
|
/* NOTE : This function should not be modified; when the callback is needed,
|
|
Jerome Coutant
0:31ddfafdd3da
|
534
|
the BSP_CAMERA_VsyncEventCallback can be implemented in the user file
|
|
Jerome Coutant
0:31ddfafdd3da
|
535
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
536
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
537
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
538
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
539
|
* @brief Frame event callback
|
|
Jerome Coutant
0:31ddfafdd3da
|
540
|
* @param hdcmi: pointer to the DCMI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
541
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
542
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
543
|
void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi)
|
|
Jerome Coutant
0:31ddfafdd3da
|
544
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
545
|
BSP_CAMERA_FrameEventCallback();
|
|
Jerome Coutant
0:31ddfafdd3da
|
546
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
547
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
548
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
549
|
* @brief Frame Event callback.
|
|
Jerome Coutant
0:31ddfafdd3da
|
550
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
551
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
552
|
__weak void BSP_CAMERA_FrameEventCallback(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
553
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
554
|
/* NOTE : This function should not be modified; when the callback is needed,
|
|
Jerome Coutant
0:31ddfafdd3da
|
555
|
the BSP_CAMERA_FrameEventCallback can be implemented in the user file
|
|
Jerome Coutant
0:31ddfafdd3da
|
556
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
557
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
558
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
559
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
560
|
* @brief Error callback
|
|
Jerome Coutant
0:31ddfafdd3da
|
561
|
* @param hdcmi: pointer to the DCMI handle
|
|
Jerome Coutant
0:31ddfafdd3da
|
562
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
563
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
564
|
void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi)
|
|
Jerome Coutant
0:31ddfafdd3da
|
565
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
566
|
BSP_CAMERA_ErrorCallback();
|
|
Jerome Coutant
0:31ddfafdd3da
|
567
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
568
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
569
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
570
|
* @brief Error callback.
|
|
Jerome Coutant
0:31ddfafdd3da
|
571
|
* @retval None
|
|
Jerome Coutant
0:31ddfafdd3da
|
572
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
573
|
__weak void BSP_CAMERA_ErrorCallback(void)
|
|
Jerome Coutant
0:31ddfafdd3da
|
574
|
{
|
|
Jerome Coutant
0:31ddfafdd3da
|
575
|
/* NOTE : This function should not be modified; when the callback is needed,
|
|
Jerome Coutant
0:31ddfafdd3da
|
576
|
the BSP_CAMERA_ErrorCallback can be implemented in the user file
|
|
Jerome Coutant
0:31ddfafdd3da
|
577
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
578
|
}
|
|
Jerome Coutant
0:31ddfafdd3da
|
579
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
580
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
581
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
582
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
583
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
584
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
585
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
586
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
587
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
588
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
589
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
590
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
591
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
592
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
593
|
/**
|
|
Jerome Coutant
0:31ddfafdd3da
|
594
|
* @}
|
|
Jerome Coutant
0:31ddfafdd3da
|
595
|
*/
|
|
Jerome Coutant
0:31ddfafdd3da
|
596
|
|
|
Jerome Coutant
0:31ddfafdd3da
|
597
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|