Projet
Dependents: DISCO-F746NG_Scope_copy
Fork of BSP_DISCO_F746NG by
stm32746g_discovery_camera.c@1:ee089790cdbb, 2016-01-04 (annotated)
- Committer:
- bcostm
- Date:
- Mon Jan 04 15:19:15 2016 +0000
- Revision:
- 1:ee089790cdbb
Add missing files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 1:ee089790cdbb | 1 | /** |
bcostm | 1:ee089790cdbb | 2 | ****************************************************************************** |
bcostm | 1:ee089790cdbb | 3 | * @file stm32746g_discovery_camera.c |
bcostm | 1:ee089790cdbb | 4 | * @author MCD Application Team |
bcostm | 1:ee089790cdbb | 5 | * @version V1.0.0 |
bcostm | 1:ee089790cdbb | 6 | * @date 25-June-2015 |
bcostm | 1:ee089790cdbb | 7 | * @brief This file includes the driver for Camera modules mounted on |
bcostm | 1:ee089790cdbb | 8 | * STM32746G-Discovery board. |
bcostm | 1:ee089790cdbb | 9 | @verbatim |
bcostm | 1:ee089790cdbb | 10 | How to use this driver: |
bcostm | 1:ee089790cdbb | 11 | ------------------------ |
bcostm | 1:ee089790cdbb | 12 | - This driver is used to drive the camera. |
bcostm | 1:ee089790cdbb | 13 | - The OV9655 component driver MUST be included with this driver. |
bcostm | 1:ee089790cdbb | 14 | |
bcostm | 1:ee089790cdbb | 15 | Driver description: |
bcostm | 1:ee089790cdbb | 16 | ------------------- |
bcostm | 1:ee089790cdbb | 17 | + Initialization steps: |
bcostm | 1:ee089790cdbb | 18 | o Initialize the camera using the BSP_CAMERA_Init() function. |
bcostm | 1:ee089790cdbb | 19 | o Start the camera capture/snapshot using the CAMERA_Start() function. |
bcostm | 1:ee089790cdbb | 20 | o Suspend, resume or stop the camera capture using the following functions: |
bcostm | 1:ee089790cdbb | 21 | - BSP_CAMERA_Suspend() |
bcostm | 1:ee089790cdbb | 22 | - BSP_CAMERA_Resume() |
bcostm | 1:ee089790cdbb | 23 | - BSP_CAMERA_Stop() |
bcostm | 1:ee089790cdbb | 24 | |
bcostm | 1:ee089790cdbb | 25 | + Options |
bcostm | 1:ee089790cdbb | 26 | o Increase or decrease on the fly the brightness and/or contrast |
bcostm | 1:ee089790cdbb | 27 | using the following function: |
bcostm | 1:ee089790cdbb | 28 | - BSP_CAMERA_ContrastBrightnessConfig |
bcostm | 1:ee089790cdbb | 29 | o Add a special effect on the fly using the following functions: |
bcostm | 1:ee089790cdbb | 30 | - BSP_CAMERA_BlackWhiteConfig() |
bcostm | 1:ee089790cdbb | 31 | - BSP_CAMERA_ColorEffectConfig() |
bcostm | 1:ee089790cdbb | 32 | @endverbatim |
bcostm | 1:ee089790cdbb | 33 | ****************************************************************************** |
bcostm | 1:ee089790cdbb | 34 | * @attention |
bcostm | 1:ee089790cdbb | 35 | * |
bcostm | 1:ee089790cdbb | 36 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
bcostm | 1:ee089790cdbb | 37 | * |
bcostm | 1:ee089790cdbb | 38 | * Redistribution and use in source and binary forms, with or without modification, |
bcostm | 1:ee089790cdbb | 39 | * are permitted provided that the following conditions are met: |
bcostm | 1:ee089790cdbb | 40 | * 1. Redistributions of source code must retain the above copyright notice, |
bcostm | 1:ee089790cdbb | 41 | * this list of conditions and the following disclaimer. |
bcostm | 1:ee089790cdbb | 42 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bcostm | 1:ee089790cdbb | 43 | * this list of conditions and the following disclaimer in the documentation |
bcostm | 1:ee089790cdbb | 44 | * and/or other materials provided with the distribution. |
bcostm | 1:ee089790cdbb | 45 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bcostm | 1:ee089790cdbb | 46 | * may be used to endorse or promote products derived from this software |
bcostm | 1:ee089790cdbb | 47 | * without specific prior written permission. |
bcostm | 1:ee089790cdbb | 48 | * |
bcostm | 1:ee089790cdbb | 49 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bcostm | 1:ee089790cdbb | 50 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bcostm | 1:ee089790cdbb | 51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bcostm | 1:ee089790cdbb | 52 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bcostm | 1:ee089790cdbb | 53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bcostm | 1:ee089790cdbb | 54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bcostm | 1:ee089790cdbb | 55 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bcostm | 1:ee089790cdbb | 56 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bcostm | 1:ee089790cdbb | 57 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bcostm | 1:ee089790cdbb | 58 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bcostm | 1:ee089790cdbb | 59 | * |
bcostm | 1:ee089790cdbb | 60 | ****************************************************************************** |
bcostm | 1:ee089790cdbb | 61 | */ |
bcostm | 1:ee089790cdbb | 62 | |
bcostm | 1:ee089790cdbb | 63 | /* Includes ------------------------------------------------------------------*/ |
bcostm | 1:ee089790cdbb | 64 | #include "stm32746g_discovery_camera.h" |
bcostm | 1:ee089790cdbb | 65 | #include "stm32746g_discovery.h" |
bcostm | 1:ee089790cdbb | 66 | |
bcostm | 1:ee089790cdbb | 67 | /** @addtogroup BSP |
bcostm | 1:ee089790cdbb | 68 | * @{ |
bcostm | 1:ee089790cdbb | 69 | */ |
bcostm | 1:ee089790cdbb | 70 | |
bcostm | 1:ee089790cdbb | 71 | /** @addtogroup STM32746G_DISCOVERY |
bcostm | 1:ee089790cdbb | 72 | * @{ |
bcostm | 1:ee089790cdbb | 73 | */ |
bcostm | 1:ee089790cdbb | 74 | |
bcostm | 1:ee089790cdbb | 75 | /** @addtogroup STM32746G_DISCOVERY_CAMERA |
bcostm | 1:ee089790cdbb | 76 | * @{ |
bcostm | 1:ee089790cdbb | 77 | */ |
bcostm | 1:ee089790cdbb | 78 | |
bcostm | 1:ee089790cdbb | 79 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_TypesDefinitions STM32746G_DISCOVERY_CAMERA Private Types Definitions |
bcostm | 1:ee089790cdbb | 80 | * @{ |
bcostm | 1:ee089790cdbb | 81 | */ |
bcostm | 1:ee089790cdbb | 82 | /** |
bcostm | 1:ee089790cdbb | 83 | * @} |
bcostm | 1:ee089790cdbb | 84 | */ |
bcostm | 1:ee089790cdbb | 85 | |
bcostm | 1:ee089790cdbb | 86 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_Defines STM32746G_DISCOVERY_CAMERA Private Defines |
bcostm | 1:ee089790cdbb | 87 | * @{ |
bcostm | 1:ee089790cdbb | 88 | */ |
bcostm | 1:ee089790cdbb | 89 | #define CAMERA_VGA_RES_X 640 |
bcostm | 1:ee089790cdbb | 90 | #define CAMERA_VGA_RES_Y 480 |
bcostm | 1:ee089790cdbb | 91 | #define CAMERA_480x272_RES_X 480 |
bcostm | 1:ee089790cdbb | 92 | #define CAMERA_480x272_RES_Y 272 |
bcostm | 1:ee089790cdbb | 93 | #define CAMERA_QVGA_RES_X 320 |
bcostm | 1:ee089790cdbb | 94 | #define CAMERA_QVGA_RES_Y 240 |
bcostm | 1:ee089790cdbb | 95 | #define CAMERA_QQVGA_RES_X 160 |
bcostm | 1:ee089790cdbb | 96 | #define CAMERA_QQVGA_RES_Y 120 |
bcostm | 1:ee089790cdbb | 97 | /** |
bcostm | 1:ee089790cdbb | 98 | * @} |
bcostm | 1:ee089790cdbb | 99 | */ |
bcostm | 1:ee089790cdbb | 100 | |
bcostm | 1:ee089790cdbb | 101 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_Macros STM32746G_DISCOVERY_CAMERA Private Macros |
bcostm | 1:ee089790cdbb | 102 | * @{ |
bcostm | 1:ee089790cdbb | 103 | */ |
bcostm | 1:ee089790cdbb | 104 | /** |
bcostm | 1:ee089790cdbb | 105 | * @} |
bcostm | 1:ee089790cdbb | 106 | */ |
bcostm | 1:ee089790cdbb | 107 | |
bcostm | 1:ee089790cdbb | 108 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_Variables STM32746G_DISCOVERY_CAMERA Private Variables |
bcostm | 1:ee089790cdbb | 109 | * @{ |
bcostm | 1:ee089790cdbb | 110 | */ |
bcostm | 1:ee089790cdbb | 111 | static DCMI_HandleTypeDef hDcmiHandler; |
bcostm | 1:ee089790cdbb | 112 | CAMERA_DrvTypeDef *camera_drv; |
bcostm | 1:ee089790cdbb | 113 | /* Camera current resolution naming (QQVGA, VGA, ...) */ |
bcostm | 1:ee089790cdbb | 114 | static uint32_t CameraCurrentResolution; |
bcostm | 1:ee089790cdbb | 115 | |
bcostm | 1:ee089790cdbb | 116 | /* Camera module I2C HW address */ |
bcostm | 1:ee089790cdbb | 117 | static uint32_t CameraHwAddress; |
bcostm | 1:ee089790cdbb | 118 | /** |
bcostm | 1:ee089790cdbb | 119 | * @} |
bcostm | 1:ee089790cdbb | 120 | */ |
bcostm | 1:ee089790cdbb | 121 | |
bcostm | 1:ee089790cdbb | 122 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_FunctionPrototypes STM32746G_DISCOVERY_CAMERA Private Function Prototypes |
bcostm | 1:ee089790cdbb | 123 | * @{ |
bcostm | 1:ee089790cdbb | 124 | */ |
bcostm | 1:ee089790cdbb | 125 | static uint32_t GetSize(uint32_t resolution); |
bcostm | 1:ee089790cdbb | 126 | /** |
bcostm | 1:ee089790cdbb | 127 | * @} |
bcostm | 1:ee089790cdbb | 128 | */ |
bcostm | 1:ee089790cdbb | 129 | |
bcostm | 1:ee089790cdbb | 130 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Exported_Functions STM32746G_DISCOVERY_CAMERA Exported Functions |
bcostm | 1:ee089790cdbb | 131 | * @{ |
bcostm | 1:ee089790cdbb | 132 | */ |
bcostm | 1:ee089790cdbb | 133 | |
bcostm | 1:ee089790cdbb | 134 | /** |
bcostm | 1:ee089790cdbb | 135 | * @brief Initializes the camera. |
bcostm | 1:ee089790cdbb | 136 | * @param Resolution : camera sensor requested resolution (x, y) : standard resolution |
bcostm | 1:ee089790cdbb | 137 | * naming QQVGA, QVGA, VGA ... |
bcostm | 1:ee089790cdbb | 138 | * @retval Camera status |
bcostm | 1:ee089790cdbb | 139 | */ |
bcostm | 1:ee089790cdbb | 140 | uint8_t BSP_CAMERA_Init(uint32_t Resolution) |
bcostm | 1:ee089790cdbb | 141 | { |
bcostm | 1:ee089790cdbb | 142 | DCMI_HandleTypeDef *phdcmi; |
bcostm | 1:ee089790cdbb | 143 | uint8_t status = CAMERA_ERROR; |
bcostm | 1:ee089790cdbb | 144 | |
bcostm | 1:ee089790cdbb | 145 | /* Get the DCMI handle structure */ |
bcostm | 1:ee089790cdbb | 146 | phdcmi = &hDcmiHandler; |
bcostm | 1:ee089790cdbb | 147 | |
bcostm | 1:ee089790cdbb | 148 | /*** Configures the DCMI to interface with the camera module ***/ |
bcostm | 1:ee089790cdbb | 149 | /* DCMI configuration */ |
bcostm | 1:ee089790cdbb | 150 | phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME; |
bcostm | 1:ee089790cdbb | 151 | phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_LOW; |
bcostm | 1:ee089790cdbb | 152 | phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; |
bcostm | 1:ee089790cdbb | 153 | phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_HIGH; |
bcostm | 1:ee089790cdbb | 154 | phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; |
bcostm | 1:ee089790cdbb | 155 | phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING; |
bcostm | 1:ee089790cdbb | 156 | phdcmi->Instance = DCMI; |
bcostm | 1:ee089790cdbb | 157 | |
bcostm | 1:ee089790cdbb | 158 | /* Power up camera */ |
bcostm | 1:ee089790cdbb | 159 | BSP_CAMERA_PwrUp(); |
bcostm | 1:ee089790cdbb | 160 | |
bcostm | 1:ee089790cdbb | 161 | /* Read ID of Camera module via I2C */ |
bcostm | 1:ee089790cdbb | 162 | if(ov9655_ReadID(CAMERA_I2C_ADDRESS) == OV9655_ID) |
bcostm | 1:ee089790cdbb | 163 | { |
bcostm | 1:ee089790cdbb | 164 | /* Initialize the camera driver structure */ |
bcostm | 1:ee089790cdbb | 165 | camera_drv = &ov9655_drv; |
bcostm | 1:ee089790cdbb | 166 | CameraHwAddress = CAMERA_I2C_ADDRESS; |
bcostm | 1:ee089790cdbb | 167 | |
bcostm | 1:ee089790cdbb | 168 | /* DCMI Initialization */ |
bcostm | 1:ee089790cdbb | 169 | BSP_CAMERA_MspInit(&hDcmiHandler, NULL); |
bcostm | 1:ee089790cdbb | 170 | HAL_DCMI_Init(phdcmi); |
bcostm | 1:ee089790cdbb | 171 | |
bcostm | 1:ee089790cdbb | 172 | /* Camera Module Initialization via I2C to the wanted 'Resolution' */ |
bcostm | 1:ee089790cdbb | 173 | if (Resolution == CAMERA_R480x272) |
bcostm | 1:ee089790cdbb | 174 | { /* For 480x272 resolution, the OV9655 sensor is set to VGA resolution |
bcostm | 1:ee089790cdbb | 175 | * as OV9655 doesn't supports 480x272 resolution, |
bcostm | 1:ee089790cdbb | 176 | * then DCMI is configured to output a 480x272 cropped window */ |
bcostm | 1:ee089790cdbb | 177 | camera_drv->Init(CameraHwAddress, CAMERA_R640x480); |
bcostm | 1:ee089790cdbb | 178 | HAL_DCMI_ConfigCROP(phdcmi, /* Crop in the middle of the VGA picture */ |
bcostm | 1:ee089790cdbb | 179 | (CAMERA_VGA_RES_X - CAMERA_480x272_RES_X)/2, |
bcostm | 1:ee089790cdbb | 180 | (CAMERA_VGA_RES_Y - CAMERA_480x272_RES_Y)/2, |
bcostm | 1:ee089790cdbb | 181 | (CAMERA_480x272_RES_X * 2) - 1, |
bcostm | 1:ee089790cdbb | 182 | CAMERA_480x272_RES_Y - 1); |
bcostm | 1:ee089790cdbb | 183 | HAL_DCMI_EnableCROP(phdcmi); |
bcostm | 1:ee089790cdbb | 184 | } |
bcostm | 1:ee089790cdbb | 185 | else |
bcostm | 1:ee089790cdbb | 186 | { |
bcostm | 1:ee089790cdbb | 187 | camera_drv->Init(CameraHwAddress, Resolution); |
bcostm | 1:ee089790cdbb | 188 | HAL_DCMI_DisableCROP(phdcmi); |
bcostm | 1:ee089790cdbb | 189 | } |
bcostm | 1:ee089790cdbb | 190 | |
bcostm | 1:ee089790cdbb | 191 | CameraCurrentResolution = Resolution; |
bcostm | 1:ee089790cdbb | 192 | |
bcostm | 1:ee089790cdbb | 193 | /* Return CAMERA_OK status */ |
bcostm | 1:ee089790cdbb | 194 | status = CAMERA_OK; |
bcostm | 1:ee089790cdbb | 195 | } |
bcostm | 1:ee089790cdbb | 196 | else |
bcostm | 1:ee089790cdbb | 197 | { |
bcostm | 1:ee089790cdbb | 198 | /* Return CAMERA_NOT_SUPPORTED status */ |
bcostm | 1:ee089790cdbb | 199 | status = CAMERA_NOT_SUPPORTED; |
bcostm | 1:ee089790cdbb | 200 | } |
bcostm | 1:ee089790cdbb | 201 | |
bcostm | 1:ee089790cdbb | 202 | return status; |
bcostm | 1:ee089790cdbb | 203 | } |
bcostm | 1:ee089790cdbb | 204 | |
bcostm | 1:ee089790cdbb | 205 | /** |
bcostm | 1:ee089790cdbb | 206 | * @brief DeInitializes the camera. |
bcostm | 1:ee089790cdbb | 207 | * @retval Camera status |
bcostm | 1:ee089790cdbb | 208 | */ |
bcostm | 1:ee089790cdbb | 209 | uint8_t BSP_CAMERA_DeInit(void) |
bcostm | 1:ee089790cdbb | 210 | { |
bcostm | 1:ee089790cdbb | 211 | hDcmiHandler.Instance = DCMI; |
bcostm | 1:ee089790cdbb | 212 | |
bcostm | 1:ee089790cdbb | 213 | HAL_DCMI_DeInit(&hDcmiHandler); |
bcostm | 1:ee089790cdbb | 214 | BSP_CAMERA_MspDeInit(&hDcmiHandler, NULL); |
bcostm | 1:ee089790cdbb | 215 | return CAMERA_OK; |
bcostm | 1:ee089790cdbb | 216 | } |
bcostm | 1:ee089790cdbb | 217 | |
bcostm | 1:ee089790cdbb | 218 | /** |
bcostm | 1:ee089790cdbb | 219 | * @brief Starts the camera capture in continuous mode. |
bcostm | 1:ee089790cdbb | 220 | * @param buff: pointer to the camera output buffer |
bcostm | 1:ee089790cdbb | 221 | * @retval None |
bcostm | 1:ee089790cdbb | 222 | */ |
bcostm | 1:ee089790cdbb | 223 | void BSP_CAMERA_ContinuousStart(uint8_t *buff) |
bcostm | 1:ee089790cdbb | 224 | { |
bcostm | 1:ee089790cdbb | 225 | /* Start the camera capture */ |
bcostm | 1:ee089790cdbb | 226 | HAL_DCMI_Start_DMA(&hDcmiHandler, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(CameraCurrentResolution)); |
bcostm | 1:ee089790cdbb | 227 | } |
bcostm | 1:ee089790cdbb | 228 | |
bcostm | 1:ee089790cdbb | 229 | /** |
bcostm | 1:ee089790cdbb | 230 | * @brief Starts the camera capture in snapshot mode. |
bcostm | 1:ee089790cdbb | 231 | * @param buff: pointer to the camera output buffer |
bcostm | 1:ee089790cdbb | 232 | * @retval None |
bcostm | 1:ee089790cdbb | 233 | */ |
bcostm | 1:ee089790cdbb | 234 | void BSP_CAMERA_SnapshotStart(uint8_t *buff) |
bcostm | 1:ee089790cdbb | 235 | { |
bcostm | 1:ee089790cdbb | 236 | /* Start the camera capture */ |
bcostm | 1:ee089790cdbb | 237 | HAL_DCMI_Start_DMA(&hDcmiHandler, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(CameraCurrentResolution)); |
bcostm | 1:ee089790cdbb | 238 | } |
bcostm | 1:ee089790cdbb | 239 | |
bcostm | 1:ee089790cdbb | 240 | /** |
bcostm | 1:ee089790cdbb | 241 | * @brief Suspend the CAMERA capture |
bcostm | 1:ee089790cdbb | 242 | * @retval None |
bcostm | 1:ee089790cdbb | 243 | */ |
bcostm | 1:ee089790cdbb | 244 | void BSP_CAMERA_Suspend(void) |
bcostm | 1:ee089790cdbb | 245 | { |
bcostm | 1:ee089790cdbb | 246 | /* Disable the DMA */ |
bcostm | 1:ee089790cdbb | 247 | __HAL_DMA_DISABLE(hDcmiHandler.DMA_Handle); |
bcostm | 1:ee089790cdbb | 248 | /* Disable the DCMI */ |
bcostm | 1:ee089790cdbb | 249 | __HAL_DCMI_DISABLE(&hDcmiHandler); |
bcostm | 1:ee089790cdbb | 250 | |
bcostm | 1:ee089790cdbb | 251 | } |
bcostm | 1:ee089790cdbb | 252 | |
bcostm | 1:ee089790cdbb | 253 | /** |
bcostm | 1:ee089790cdbb | 254 | * @brief Resume the CAMERA capture |
bcostm | 1:ee089790cdbb | 255 | * @retval None |
bcostm | 1:ee089790cdbb | 256 | */ |
bcostm | 1:ee089790cdbb | 257 | void BSP_CAMERA_Resume(void) |
bcostm | 1:ee089790cdbb | 258 | { |
bcostm | 1:ee089790cdbb | 259 | /* Enable the DCMI */ |
bcostm | 1:ee089790cdbb | 260 | __HAL_DCMI_ENABLE(&hDcmiHandler); |
bcostm | 1:ee089790cdbb | 261 | /* Enable the DMA */ |
bcostm | 1:ee089790cdbb | 262 | __HAL_DMA_ENABLE(hDcmiHandler.DMA_Handle); |
bcostm | 1:ee089790cdbb | 263 | } |
bcostm | 1:ee089790cdbb | 264 | |
bcostm | 1:ee089790cdbb | 265 | /** |
bcostm | 1:ee089790cdbb | 266 | * @brief Stop the CAMERA capture |
bcostm | 1:ee089790cdbb | 267 | * @retval Camera status |
bcostm | 1:ee089790cdbb | 268 | */ |
bcostm | 1:ee089790cdbb | 269 | uint8_t BSP_CAMERA_Stop(void) |
bcostm | 1:ee089790cdbb | 270 | { |
bcostm | 1:ee089790cdbb | 271 | uint8_t status = CAMERA_ERROR; |
bcostm | 1:ee089790cdbb | 272 | |
bcostm | 1:ee089790cdbb | 273 | if(HAL_DCMI_Stop(&hDcmiHandler) == HAL_OK) |
bcostm | 1:ee089790cdbb | 274 | { |
bcostm | 1:ee089790cdbb | 275 | status = CAMERA_OK; |
bcostm | 1:ee089790cdbb | 276 | } |
bcostm | 1:ee089790cdbb | 277 | |
bcostm | 1:ee089790cdbb | 278 | /* Set Camera in Power Down */ |
bcostm | 1:ee089790cdbb | 279 | BSP_CAMERA_PwrDown(); |
bcostm | 1:ee089790cdbb | 280 | |
bcostm | 1:ee089790cdbb | 281 | return status; |
bcostm | 1:ee089790cdbb | 282 | } |
bcostm | 1:ee089790cdbb | 283 | |
bcostm | 1:ee089790cdbb | 284 | /** |
bcostm | 1:ee089790cdbb | 285 | * @brief CANERA power up |
bcostm | 1:ee089790cdbb | 286 | * @retval None |
bcostm | 1:ee089790cdbb | 287 | */ |
bcostm | 1:ee089790cdbb | 288 | void BSP_CAMERA_PwrUp(void) |
bcostm | 1:ee089790cdbb | 289 | { |
bcostm | 1:ee089790cdbb | 290 | GPIO_InitTypeDef gpio_init_structure; |
bcostm | 1:ee089790cdbb | 291 | |
bcostm | 1:ee089790cdbb | 292 | /* Enable GPIO clock */ |
bcostm | 1:ee089790cdbb | 293 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
bcostm | 1:ee089790cdbb | 294 | |
bcostm | 1:ee089790cdbb | 295 | /*** Configure the GPIO ***/ |
bcostm | 1:ee089790cdbb | 296 | /* Configure DCMI GPIO as alternate function */ |
bcostm | 1:ee089790cdbb | 297 | gpio_init_structure.Pin = GPIO_PIN_13; |
bcostm | 1:ee089790cdbb | 298 | gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; |
bcostm | 1:ee089790cdbb | 299 | gpio_init_structure.Pull = GPIO_NOPULL; |
bcostm | 1:ee089790cdbb | 300 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 1:ee089790cdbb | 301 | HAL_GPIO_Init(GPIOH, &gpio_init_structure); |
bcostm | 1:ee089790cdbb | 302 | |
bcostm | 1:ee089790cdbb | 303 | /* De-assert the camera POWER_DOWN pin (active high) */ |
bcostm | 1:ee089790cdbb | 304 | HAL_GPIO_WritePin(GPIOH, GPIO_PIN_13, GPIO_PIN_RESET); |
bcostm | 1:ee089790cdbb | 305 | |
bcostm | 1:ee089790cdbb | 306 | HAL_Delay(3); /* POWER_DOWN de-asserted during 3ms */ |
bcostm | 1:ee089790cdbb | 307 | } |
bcostm | 1:ee089790cdbb | 308 | |
bcostm | 1:ee089790cdbb | 309 | /** |
bcostm | 1:ee089790cdbb | 310 | * @brief CAMERA power down |
bcostm | 1:ee089790cdbb | 311 | * @retval None |
bcostm | 1:ee089790cdbb | 312 | */ |
bcostm | 1:ee089790cdbb | 313 | void BSP_CAMERA_PwrDown(void) |
bcostm | 1:ee089790cdbb | 314 | { |
bcostm | 1:ee089790cdbb | 315 | GPIO_InitTypeDef gpio_init_structure; |
bcostm | 1:ee089790cdbb | 316 | |
bcostm | 1:ee089790cdbb | 317 | /* Enable GPIO clock */ |
bcostm | 1:ee089790cdbb | 318 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
bcostm | 1:ee089790cdbb | 319 | |
bcostm | 1:ee089790cdbb | 320 | /*** Configure the GPIO ***/ |
bcostm | 1:ee089790cdbb | 321 | /* Configure DCMI GPIO as alternate function */ |
bcostm | 1:ee089790cdbb | 322 | gpio_init_structure.Pin = GPIO_PIN_13; |
bcostm | 1:ee089790cdbb | 323 | gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; |
bcostm | 1:ee089790cdbb | 324 | gpio_init_structure.Pull = GPIO_NOPULL; |
bcostm | 1:ee089790cdbb | 325 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 1:ee089790cdbb | 326 | HAL_GPIO_Init(GPIOH, &gpio_init_structure); |
bcostm | 1:ee089790cdbb | 327 | |
bcostm | 1:ee089790cdbb | 328 | /* Assert the camera POWER_DOWN pin (active high) */ |
bcostm | 1:ee089790cdbb | 329 | HAL_GPIO_WritePin(GPIOH, GPIO_PIN_13, GPIO_PIN_SET); |
bcostm | 1:ee089790cdbb | 330 | } |
bcostm | 1:ee089790cdbb | 331 | |
bcostm | 1:ee089790cdbb | 332 | /** |
bcostm | 1:ee089790cdbb | 333 | * @brief Configures the camera contrast and brightness. |
bcostm | 1:ee089790cdbb | 334 | * @param contrast_level: Contrast level |
bcostm | 1:ee089790cdbb | 335 | * This parameter can be one of the following values: |
bcostm | 1:ee089790cdbb | 336 | * @arg CAMERA_CONTRAST_LEVEL4: for contrast +2 |
bcostm | 1:ee089790cdbb | 337 | * @arg CAMERA_CONTRAST_LEVEL3: for contrast +1 |
bcostm | 1:ee089790cdbb | 338 | * @arg CAMERA_CONTRAST_LEVEL2: for contrast 0 |
bcostm | 1:ee089790cdbb | 339 | * @arg CAMERA_CONTRAST_LEVEL1: for contrast -1 |
bcostm | 1:ee089790cdbb | 340 | * @arg CAMERA_CONTRAST_LEVEL0: for contrast -2 |
bcostm | 1:ee089790cdbb | 341 | * @param brightness_level: Contrast level |
bcostm | 1:ee089790cdbb | 342 | * This parameter can be one of the following values: |
bcostm | 1:ee089790cdbb | 343 | * @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2 |
bcostm | 1:ee089790cdbb | 344 | * @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1 |
bcostm | 1:ee089790cdbb | 345 | * @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0 |
bcostm | 1:ee089790cdbb | 346 | * @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1 |
bcostm | 1:ee089790cdbb | 347 | * @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2 |
bcostm | 1:ee089790cdbb | 348 | * @retval None |
bcostm | 1:ee089790cdbb | 349 | */ |
bcostm | 1:ee089790cdbb | 350 | void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level) |
bcostm | 1:ee089790cdbb | 351 | { |
bcostm | 1:ee089790cdbb | 352 | if(camera_drv->Config != NULL) |
bcostm | 1:ee089790cdbb | 353 | { |
bcostm | 1:ee089790cdbb | 354 | camera_drv->Config(CameraHwAddress, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level); |
bcostm | 1:ee089790cdbb | 355 | } |
bcostm | 1:ee089790cdbb | 356 | } |
bcostm | 1:ee089790cdbb | 357 | |
bcostm | 1:ee089790cdbb | 358 | /** |
bcostm | 1:ee089790cdbb | 359 | * @brief Configures the camera white balance. |
bcostm | 1:ee089790cdbb | 360 | * @param Mode: black_white mode |
bcostm | 1:ee089790cdbb | 361 | * This parameter can be one of the following values: |
bcostm | 1:ee089790cdbb | 362 | * @arg CAMERA_BLACK_WHITE_BW |
bcostm | 1:ee089790cdbb | 363 | * @arg CAMERA_BLACK_WHITE_NEGATIVE |
bcostm | 1:ee089790cdbb | 364 | * @arg CAMERA_BLACK_WHITE_BW_NEGATIVE |
bcostm | 1:ee089790cdbb | 365 | * @arg CAMERA_BLACK_WHITE_NORMAL |
bcostm | 1:ee089790cdbb | 366 | * @retval None |
bcostm | 1:ee089790cdbb | 367 | */ |
bcostm | 1:ee089790cdbb | 368 | void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode) |
bcostm | 1:ee089790cdbb | 369 | { |
bcostm | 1:ee089790cdbb | 370 | if(camera_drv->Config != NULL) |
bcostm | 1:ee089790cdbb | 371 | { |
bcostm | 1:ee089790cdbb | 372 | camera_drv->Config(CameraHwAddress, CAMERA_BLACK_WHITE, Mode, 0); |
bcostm | 1:ee089790cdbb | 373 | } |
bcostm | 1:ee089790cdbb | 374 | } |
bcostm | 1:ee089790cdbb | 375 | |
bcostm | 1:ee089790cdbb | 376 | /** |
bcostm | 1:ee089790cdbb | 377 | * @brief Configures the camera color effect. |
bcostm | 1:ee089790cdbb | 378 | * @param Effect: Color effect |
bcostm | 1:ee089790cdbb | 379 | * This parameter can be one of the following values: |
bcostm | 1:ee089790cdbb | 380 | * @arg CAMERA_COLOR_EFFECT_ANTIQUE |
bcostm | 1:ee089790cdbb | 381 | * @arg CAMERA_COLOR_EFFECT_BLUE |
bcostm | 1:ee089790cdbb | 382 | * @arg CAMERA_COLOR_EFFECT_GREEN |
bcostm | 1:ee089790cdbb | 383 | * @arg CAMERA_COLOR_EFFECT_RED |
bcostm | 1:ee089790cdbb | 384 | * @retval None |
bcostm | 1:ee089790cdbb | 385 | */ |
bcostm | 1:ee089790cdbb | 386 | void BSP_CAMERA_ColorEffectConfig(uint32_t Effect) |
bcostm | 1:ee089790cdbb | 387 | { |
bcostm | 1:ee089790cdbb | 388 | if(camera_drv->Config != NULL) |
bcostm | 1:ee089790cdbb | 389 | { |
bcostm | 1:ee089790cdbb | 390 | camera_drv->Config(CameraHwAddress, CAMERA_COLOR_EFFECT, Effect, 0); |
bcostm | 1:ee089790cdbb | 391 | } |
bcostm | 1:ee089790cdbb | 392 | } |
bcostm | 1:ee089790cdbb | 393 | |
bcostm | 1:ee089790cdbb | 394 | /** |
bcostm | 1:ee089790cdbb | 395 | * @brief Handles DCMI interrupt request. |
bcostm | 1:ee089790cdbb | 396 | * @retval None |
bcostm | 1:ee089790cdbb | 397 | */ |
bcostm | 1:ee089790cdbb | 398 | void BSP_CAMERA_IRQHandler(void) |
bcostm | 1:ee089790cdbb | 399 | { |
bcostm | 1:ee089790cdbb | 400 | HAL_DCMI_IRQHandler(&hDcmiHandler); |
bcostm | 1:ee089790cdbb | 401 | } |
bcostm | 1:ee089790cdbb | 402 | |
bcostm | 1:ee089790cdbb | 403 | /** |
bcostm | 1:ee089790cdbb | 404 | * @brief Handles DMA interrupt request. |
bcostm | 1:ee089790cdbb | 405 | * @retval None |
bcostm | 1:ee089790cdbb | 406 | */ |
bcostm | 1:ee089790cdbb | 407 | void BSP_CAMERA_DMA_IRQHandler(void) |
bcostm | 1:ee089790cdbb | 408 | { |
bcostm | 1:ee089790cdbb | 409 | HAL_DMA_IRQHandler(hDcmiHandler.DMA_Handle); |
bcostm | 1:ee089790cdbb | 410 | } |
bcostm | 1:ee089790cdbb | 411 | |
bcostm | 1:ee089790cdbb | 412 | /** |
bcostm | 1:ee089790cdbb | 413 | * @brief Get the capture size in pixels unit. |
bcostm | 1:ee089790cdbb | 414 | * @param resolution: the current resolution. |
bcostm | 1:ee089790cdbb | 415 | * @retval capture size in pixels unit. |
bcostm | 1:ee089790cdbb | 416 | */ |
bcostm | 1:ee089790cdbb | 417 | static uint32_t GetSize(uint32_t resolution) |
bcostm | 1:ee089790cdbb | 418 | { |
bcostm | 1:ee089790cdbb | 419 | uint32_t size = 0; |
bcostm | 1:ee089790cdbb | 420 | |
bcostm | 1:ee089790cdbb | 421 | /* Get capture size */ |
bcostm | 1:ee089790cdbb | 422 | switch (resolution) |
bcostm | 1:ee089790cdbb | 423 | { |
bcostm | 1:ee089790cdbb | 424 | case CAMERA_R160x120: |
bcostm | 1:ee089790cdbb | 425 | { |
bcostm | 1:ee089790cdbb | 426 | size = 0x2580; |
bcostm | 1:ee089790cdbb | 427 | } |
bcostm | 1:ee089790cdbb | 428 | break; |
bcostm | 1:ee089790cdbb | 429 | case CAMERA_R320x240: |
bcostm | 1:ee089790cdbb | 430 | { |
bcostm | 1:ee089790cdbb | 431 | size = 0x9600; |
bcostm | 1:ee089790cdbb | 432 | } |
bcostm | 1:ee089790cdbb | 433 | break; |
bcostm | 1:ee089790cdbb | 434 | case CAMERA_R480x272: |
bcostm | 1:ee089790cdbb | 435 | { |
bcostm | 1:ee089790cdbb | 436 | size = 0xFF00; |
bcostm | 1:ee089790cdbb | 437 | } |
bcostm | 1:ee089790cdbb | 438 | break; |
bcostm | 1:ee089790cdbb | 439 | case CAMERA_R640x480: |
bcostm | 1:ee089790cdbb | 440 | { |
bcostm | 1:ee089790cdbb | 441 | size = 0x25800; |
bcostm | 1:ee089790cdbb | 442 | } |
bcostm | 1:ee089790cdbb | 443 | break; |
bcostm | 1:ee089790cdbb | 444 | default: |
bcostm | 1:ee089790cdbb | 445 | { |
bcostm | 1:ee089790cdbb | 446 | break; |
bcostm | 1:ee089790cdbb | 447 | } |
bcostm | 1:ee089790cdbb | 448 | } |
bcostm | 1:ee089790cdbb | 449 | |
bcostm | 1:ee089790cdbb | 450 | return size; |
bcostm | 1:ee089790cdbb | 451 | } |
bcostm | 1:ee089790cdbb | 452 | |
bcostm | 1:ee089790cdbb | 453 | /** |
bcostm | 1:ee089790cdbb | 454 | * @brief Initializes the DCMI MSP. |
bcostm | 1:ee089790cdbb | 455 | * @param hdcmi: HDMI handle |
bcostm | 1:ee089790cdbb | 456 | * @param Params |
bcostm | 1:ee089790cdbb | 457 | * @retval None |
bcostm | 1:ee089790cdbb | 458 | */ |
bcostm | 1:ee089790cdbb | 459 | __weak void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params) |
bcostm | 1:ee089790cdbb | 460 | { |
bcostm | 1:ee089790cdbb | 461 | static DMA_HandleTypeDef hdma_handler; |
bcostm | 1:ee089790cdbb | 462 | GPIO_InitTypeDef gpio_init_structure; |
bcostm | 1:ee089790cdbb | 463 | |
bcostm | 1:ee089790cdbb | 464 | /*** Enable peripherals and GPIO clocks ***/ |
bcostm | 1:ee089790cdbb | 465 | /* Enable DCMI clock */ |
bcostm | 1:ee089790cdbb | 466 | __HAL_RCC_DCMI_CLK_ENABLE(); |
bcostm | 1:ee089790cdbb | 467 | |
bcostm | 1:ee089790cdbb | 468 | /* Enable DMA2 clock */ |
bcostm | 1:ee089790cdbb | 469 | __HAL_RCC_DMA2_CLK_ENABLE(); |
bcostm | 1:ee089790cdbb | 470 | |
bcostm | 1:ee089790cdbb | 471 | /* Enable GPIO clocks */ |
bcostm | 1:ee089790cdbb | 472 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
bcostm | 1:ee089790cdbb | 473 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
bcostm | 1:ee089790cdbb | 474 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
bcostm | 1:ee089790cdbb | 475 | __HAL_RCC_GPIOG_CLK_ENABLE(); |
bcostm | 1:ee089790cdbb | 476 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
bcostm | 1:ee089790cdbb | 477 | |
bcostm | 1:ee089790cdbb | 478 | /*** Configure the GPIO ***/ |
bcostm | 1:ee089790cdbb | 479 | /* Configure DCMI GPIO as alternate function */ |
bcostm | 1:ee089790cdbb | 480 | gpio_init_structure.Pin = GPIO_PIN_4 | GPIO_PIN_6; |
bcostm | 1:ee089790cdbb | 481 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 1:ee089790cdbb | 482 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 1:ee089790cdbb | 483 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 1:ee089790cdbb | 484 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 1:ee089790cdbb | 485 | HAL_GPIO_Init(GPIOA, &gpio_init_structure); |
bcostm | 1:ee089790cdbb | 486 | |
bcostm | 1:ee089790cdbb | 487 | gpio_init_structure.Pin = GPIO_PIN_3; |
bcostm | 1:ee089790cdbb | 488 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 1:ee089790cdbb | 489 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 1:ee089790cdbb | 490 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 1:ee089790cdbb | 491 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 1:ee089790cdbb | 492 | HAL_GPIO_Init(GPIOD, &gpio_init_structure); |
bcostm | 1:ee089790cdbb | 493 | |
bcostm | 1:ee089790cdbb | 494 | gpio_init_structure.Pin = GPIO_PIN_5 | GPIO_PIN_6; |
bcostm | 1:ee089790cdbb | 495 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 1:ee089790cdbb | 496 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 1:ee089790cdbb | 497 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 1:ee089790cdbb | 498 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 1:ee089790cdbb | 499 | HAL_GPIO_Init(GPIOE, &gpio_init_structure); |
bcostm | 1:ee089790cdbb | 500 | |
bcostm | 1:ee089790cdbb | 501 | gpio_init_structure.Pin = GPIO_PIN_9; |
bcostm | 1:ee089790cdbb | 502 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 1:ee089790cdbb | 503 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 1:ee089790cdbb | 504 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 1:ee089790cdbb | 505 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 1:ee089790cdbb | 506 | HAL_GPIO_Init(GPIOG, &gpio_init_structure); |
bcostm | 1:ee089790cdbb | 507 | |
bcostm | 1:ee089790cdbb | 508 | gpio_init_structure.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ |
bcostm | 1:ee089790cdbb | 509 | GPIO_PIN_12 | GPIO_PIN_14; |
bcostm | 1:ee089790cdbb | 510 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 1:ee089790cdbb | 511 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 1:ee089790cdbb | 512 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 1:ee089790cdbb | 513 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 1:ee089790cdbb | 514 | HAL_GPIO_Init(GPIOH, &gpio_init_structure); |
bcostm | 1:ee089790cdbb | 515 | |
bcostm | 1:ee089790cdbb | 516 | /*** Configure the DMA ***/ |
bcostm | 1:ee089790cdbb | 517 | /* Set the parameters to be configured */ |
bcostm | 1:ee089790cdbb | 518 | hdma_handler.Init.Channel = DMA_CHANNEL_1; |
bcostm | 1:ee089790cdbb | 519 | hdma_handler.Init.Direction = DMA_PERIPH_TO_MEMORY; |
bcostm | 1:ee089790cdbb | 520 | hdma_handler.Init.PeriphInc = DMA_PINC_DISABLE; |
bcostm | 1:ee089790cdbb | 521 | hdma_handler.Init.MemInc = DMA_MINC_ENABLE; |
bcostm | 1:ee089790cdbb | 522 | hdma_handler.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; |
bcostm | 1:ee089790cdbb | 523 | hdma_handler.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; |
bcostm | 1:ee089790cdbb | 524 | hdma_handler.Init.Mode = DMA_CIRCULAR; |
bcostm | 1:ee089790cdbb | 525 | hdma_handler.Init.Priority = DMA_PRIORITY_HIGH; |
bcostm | 1:ee089790cdbb | 526 | hdma_handler.Init.FIFOMode = DMA_FIFOMODE_DISABLE; |
bcostm | 1:ee089790cdbb | 527 | hdma_handler.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; |
bcostm | 1:ee089790cdbb | 528 | hdma_handler.Init.MemBurst = DMA_MBURST_SINGLE; |
bcostm | 1:ee089790cdbb | 529 | hdma_handler.Init.PeriphBurst = DMA_PBURST_SINGLE; |
bcostm | 1:ee089790cdbb | 530 | |
bcostm | 1:ee089790cdbb | 531 | hdma_handler.Instance = DMA2_Stream1; |
bcostm | 1:ee089790cdbb | 532 | |
bcostm | 1:ee089790cdbb | 533 | /* Associate the initialized DMA handle to the DCMI handle */ |
bcostm | 1:ee089790cdbb | 534 | __HAL_LINKDMA(hdcmi, DMA_Handle, hdma_handler); |
bcostm | 1:ee089790cdbb | 535 | |
bcostm | 1:ee089790cdbb | 536 | /*** Configure the NVIC for DCMI and DMA ***/ |
bcostm | 1:ee089790cdbb | 537 | /* NVIC configuration for DCMI transfer complete interrupt */ |
bcostm | 1:ee089790cdbb | 538 | HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0); |
bcostm | 1:ee089790cdbb | 539 | HAL_NVIC_EnableIRQ(DCMI_IRQn); |
bcostm | 1:ee089790cdbb | 540 | |
bcostm | 1:ee089790cdbb | 541 | /* NVIC configuration for DMA2D transfer complete interrupt */ |
bcostm | 1:ee089790cdbb | 542 | HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); |
bcostm | 1:ee089790cdbb | 543 | HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); |
bcostm | 1:ee089790cdbb | 544 | |
bcostm | 1:ee089790cdbb | 545 | /* Configure the DMA stream */ |
bcostm | 1:ee089790cdbb | 546 | HAL_DMA_Init(hdcmi->DMA_Handle); |
bcostm | 1:ee089790cdbb | 547 | } |
bcostm | 1:ee089790cdbb | 548 | |
bcostm | 1:ee089790cdbb | 549 | |
bcostm | 1:ee089790cdbb | 550 | /** |
bcostm | 1:ee089790cdbb | 551 | * @brief DeInitializes the DCMI MSP. |
bcostm | 1:ee089790cdbb | 552 | * @param hdcmi: HDMI handle |
bcostm | 1:ee089790cdbb | 553 | * @param Params |
bcostm | 1:ee089790cdbb | 554 | * @retval None |
bcostm | 1:ee089790cdbb | 555 | */ |
bcostm | 1:ee089790cdbb | 556 | __weak void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params) |
bcostm | 1:ee089790cdbb | 557 | { |
bcostm | 1:ee089790cdbb | 558 | /* Disable NVIC for DCMI transfer complete interrupt */ |
bcostm | 1:ee089790cdbb | 559 | HAL_NVIC_DisableIRQ(DCMI_IRQn); |
bcostm | 1:ee089790cdbb | 560 | |
bcostm | 1:ee089790cdbb | 561 | /* Disable NVIC for DMA2 transfer complete interrupt */ |
bcostm | 1:ee089790cdbb | 562 | HAL_NVIC_DisableIRQ(DMA2_Stream1_IRQn); |
bcostm | 1:ee089790cdbb | 563 | |
bcostm | 1:ee089790cdbb | 564 | /* Configure the DMA stream */ |
bcostm | 1:ee089790cdbb | 565 | HAL_DMA_DeInit(hdcmi->DMA_Handle); |
bcostm | 1:ee089790cdbb | 566 | |
bcostm | 1:ee089790cdbb | 567 | /* Disable DCMI clock */ |
bcostm | 1:ee089790cdbb | 568 | __HAL_RCC_DCMI_CLK_DISABLE(); |
bcostm | 1:ee089790cdbb | 569 | |
bcostm | 1:ee089790cdbb | 570 | /* GPIO pins clock and DMA clock can be shut down in the application |
bcostm | 1:ee089790cdbb | 571 | by surcharging this __weak function */ |
bcostm | 1:ee089790cdbb | 572 | } |
bcostm | 1:ee089790cdbb | 573 | |
bcostm | 1:ee089790cdbb | 574 | /** |
bcostm | 1:ee089790cdbb | 575 | * @brief Line event callback |
bcostm | 1:ee089790cdbb | 576 | * @param hdcmi: pointer to the DCMI handle |
bcostm | 1:ee089790cdbb | 577 | * @retval None |
bcostm | 1:ee089790cdbb | 578 | */ |
bcostm | 1:ee089790cdbb | 579 | void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) |
bcostm | 1:ee089790cdbb | 580 | { |
bcostm | 1:ee089790cdbb | 581 | BSP_CAMERA_LineEventCallback(); |
bcostm | 1:ee089790cdbb | 582 | } |
bcostm | 1:ee089790cdbb | 583 | |
bcostm | 1:ee089790cdbb | 584 | /** |
bcostm | 1:ee089790cdbb | 585 | * @brief Line Event callback. |
bcostm | 1:ee089790cdbb | 586 | * @retval None |
bcostm | 1:ee089790cdbb | 587 | */ |
bcostm | 1:ee089790cdbb | 588 | __weak void BSP_CAMERA_LineEventCallback(void) |
bcostm | 1:ee089790cdbb | 589 | { |
bcostm | 1:ee089790cdbb | 590 | /* NOTE : This function Should not be modified, when the callback is needed, |
bcostm | 1:ee089790cdbb | 591 | the HAL_DCMI_LineEventCallback could be implemented in the user file |
bcostm | 1:ee089790cdbb | 592 | */ |
bcostm | 1:ee089790cdbb | 593 | } |
bcostm | 1:ee089790cdbb | 594 | |
bcostm | 1:ee089790cdbb | 595 | /** |
bcostm | 1:ee089790cdbb | 596 | * @brief VSYNC event callback |
bcostm | 1:ee089790cdbb | 597 | * @param hdcmi: pointer to the DCMI handle |
bcostm | 1:ee089790cdbb | 598 | * @retval None |
bcostm | 1:ee089790cdbb | 599 | */ |
bcostm | 1:ee089790cdbb | 600 | void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) |
bcostm | 1:ee089790cdbb | 601 | { |
bcostm | 1:ee089790cdbb | 602 | BSP_CAMERA_VsyncEventCallback(); |
bcostm | 1:ee089790cdbb | 603 | } |
bcostm | 1:ee089790cdbb | 604 | |
bcostm | 1:ee089790cdbb | 605 | /** |
bcostm | 1:ee089790cdbb | 606 | * @brief VSYNC Event callback. |
bcostm | 1:ee089790cdbb | 607 | * @retval None |
bcostm | 1:ee089790cdbb | 608 | */ |
bcostm | 1:ee089790cdbb | 609 | __weak void BSP_CAMERA_VsyncEventCallback(void) |
bcostm | 1:ee089790cdbb | 610 | { |
bcostm | 1:ee089790cdbb | 611 | /* NOTE : This function Should not be modified, when the callback is needed, |
bcostm | 1:ee089790cdbb | 612 | the HAL_DCMI_VsyncEventCallback could be implemented in the user file |
bcostm | 1:ee089790cdbb | 613 | */ |
bcostm | 1:ee089790cdbb | 614 | } |
bcostm | 1:ee089790cdbb | 615 | |
bcostm | 1:ee089790cdbb | 616 | /** |
bcostm | 1:ee089790cdbb | 617 | * @brief Frame event callback |
bcostm | 1:ee089790cdbb | 618 | * @param hdcmi: pointer to the DCMI handle |
bcostm | 1:ee089790cdbb | 619 | * @retval None |
bcostm | 1:ee089790cdbb | 620 | */ |
bcostm | 1:ee089790cdbb | 621 | void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) |
bcostm | 1:ee089790cdbb | 622 | { |
bcostm | 1:ee089790cdbb | 623 | BSP_CAMERA_FrameEventCallback(); |
bcostm | 1:ee089790cdbb | 624 | } |
bcostm | 1:ee089790cdbb | 625 | |
bcostm | 1:ee089790cdbb | 626 | /** |
bcostm | 1:ee089790cdbb | 627 | * @brief Frame Event callback. |
bcostm | 1:ee089790cdbb | 628 | * @retval None |
bcostm | 1:ee089790cdbb | 629 | */ |
bcostm | 1:ee089790cdbb | 630 | __weak void BSP_CAMERA_FrameEventCallback(void) |
bcostm | 1:ee089790cdbb | 631 | { |
bcostm | 1:ee089790cdbb | 632 | /* NOTE : This function Should not be modified, when the callback is needed, |
bcostm | 1:ee089790cdbb | 633 | the HAL_DCMI_FrameEventCallback could be implemented in the user file |
bcostm | 1:ee089790cdbb | 634 | */ |
bcostm | 1:ee089790cdbb | 635 | } |
bcostm | 1:ee089790cdbb | 636 | |
bcostm | 1:ee089790cdbb | 637 | /** |
bcostm | 1:ee089790cdbb | 638 | * @brief Error callback |
bcostm | 1:ee089790cdbb | 639 | * @param hdcmi: pointer to the DCMI handle |
bcostm | 1:ee089790cdbb | 640 | * @retval None |
bcostm | 1:ee089790cdbb | 641 | */ |
bcostm | 1:ee089790cdbb | 642 | void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi) |
bcostm | 1:ee089790cdbb | 643 | { |
bcostm | 1:ee089790cdbb | 644 | BSP_CAMERA_ErrorCallback(); |
bcostm | 1:ee089790cdbb | 645 | } |
bcostm | 1:ee089790cdbb | 646 | |
bcostm | 1:ee089790cdbb | 647 | /** |
bcostm | 1:ee089790cdbb | 648 | * @brief Error callback. |
bcostm | 1:ee089790cdbb | 649 | * @retval None |
bcostm | 1:ee089790cdbb | 650 | */ |
bcostm | 1:ee089790cdbb | 651 | __weak void BSP_CAMERA_ErrorCallback(void) |
bcostm | 1:ee089790cdbb | 652 | { |
bcostm | 1:ee089790cdbb | 653 | /* NOTE : This function Should not be modified, when the callback is needed, |
bcostm | 1:ee089790cdbb | 654 | the HAL_DCMI_ErrorCallback could be implemented in the user file |
bcostm | 1:ee089790cdbb | 655 | */ |
bcostm | 1:ee089790cdbb | 656 | } |
bcostm | 1:ee089790cdbb | 657 | |
bcostm | 1:ee089790cdbb | 658 | /** |
bcostm | 1:ee089790cdbb | 659 | * @} |
bcostm | 1:ee089790cdbb | 660 | */ |
bcostm | 1:ee089790cdbb | 661 | |
bcostm | 1:ee089790cdbb | 662 | /** |
bcostm | 1:ee089790cdbb | 663 | * @} |
bcostm | 1:ee089790cdbb | 664 | */ |
bcostm | 1:ee089790cdbb | 665 | |
bcostm | 1:ee089790cdbb | 666 | /** |
bcostm | 1:ee089790cdbb | 667 | * @} |
bcostm | 1:ee089790cdbb | 668 | */ |
bcostm | 1:ee089790cdbb | 669 | |
bcostm | 1:ee089790cdbb | 670 | /** |
bcostm | 1:ee089790cdbb | 671 | * @} |
bcostm | 1:ee089790cdbb | 672 | */ |
bcostm | 1:ee089790cdbb | 673 | |
bcostm | 1:ee089790cdbb | 674 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |