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