Without definitions for BSP_CAMERA_IRQHandler and BSP_CAMERA_DMA_IRQHandler methods, DCMI IRQs were not being serviced by HAL_DCMI_IRQHandler. This broke the IRQ-based DCMI API.
Drivers/BSP/STM32746G-Discovery/stm32746g_discovery_camera.c@9:df2ea349c37a, 2017-07-06 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Thu Jul 06 16:58:50 2017 +0200
- Revision:
- 9:df2ea349c37a
- Parent:
- 8:56384bddaba5
- Child:
- 10:b70ba9b9345e
replace HAL_Delay by wait_ms
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 | |
Jerome Coutant
9:df2ea349c37a
|
67
|
void wait_ms(int ms); // MBED to replace HAL_Delay function
|
|
Jerome Coutant
9:df2ea349c37a
|
68
|
|
|
bcostm | 6:e1d9da7fe856 | 69 | /** @addtogroup BSP |
bcostm | 6:e1d9da7fe856 | 70 | * @{ |
bcostm | 6:e1d9da7fe856 | 71 | */ |
bcostm | 6:e1d9da7fe856 | 72 | |
bcostm | 6:e1d9da7fe856 | 73 | /** @addtogroup STM32746G_DISCOVERY |
bcostm | 6:e1d9da7fe856 | 74 | * @{ |
bcostm | 6:e1d9da7fe856 | 75 | */ |
bcostm | 6:e1d9da7fe856 | 76 | |
bcostm | 6:e1d9da7fe856 | 77 | /** @addtogroup STM32746G_DISCOVERY_CAMERA |
bcostm | 6:e1d9da7fe856 | 78 | * @{ |
bcostm | 6:e1d9da7fe856 | 79 | */ |
bcostm | 6:e1d9da7fe856 | 80 | |
bcostm | 6:e1d9da7fe856 | 81 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_TypesDefinitions STM32746G_DISCOVERY_CAMERA Private Types Definitions |
bcostm | 6:e1d9da7fe856 | 82 | * @{ |
bcostm | 6:e1d9da7fe856 | 83 | */ |
bcostm | 6:e1d9da7fe856 | 84 | /** |
bcostm | 6:e1d9da7fe856 | 85 | * @} |
bcostm | 6:e1d9da7fe856 | 86 | */ |
bcostm | 6:e1d9da7fe856 | 87 | |
bcostm | 6:e1d9da7fe856 | 88 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_Defines STM32746G_DISCOVERY_CAMERA Private Defines |
bcostm | 6:e1d9da7fe856 | 89 | * @{ |
bcostm | 6:e1d9da7fe856 | 90 | */ |
bcostm | 6:e1d9da7fe856 | 91 | #define CAMERA_VGA_RES_X 640 |
bcostm | 6:e1d9da7fe856 | 92 | #define CAMERA_VGA_RES_Y 480 |
bcostm | 6:e1d9da7fe856 | 93 | #define CAMERA_480x272_RES_X 480 |
bcostm | 6:e1d9da7fe856 | 94 | #define CAMERA_480x272_RES_Y 272 |
bcostm | 6:e1d9da7fe856 | 95 | #define CAMERA_QVGA_RES_X 320 |
bcostm | 6:e1d9da7fe856 | 96 | #define CAMERA_QVGA_RES_Y 240 |
bcostm | 6:e1d9da7fe856 | 97 | #define CAMERA_QQVGA_RES_X 160 |
bcostm | 6:e1d9da7fe856 | 98 | #define CAMERA_QQVGA_RES_Y 120 |
bcostm | 6:e1d9da7fe856 | 99 | /** |
bcostm | 6:e1d9da7fe856 | 100 | * @} |
bcostm | 6:e1d9da7fe856 | 101 | */ |
bcostm | 6:e1d9da7fe856 | 102 | |
bcostm | 6:e1d9da7fe856 | 103 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_Macros STM32746G_DISCOVERY_CAMERA Private Macros |
bcostm | 6:e1d9da7fe856 | 104 | * @{ |
bcostm | 6:e1d9da7fe856 | 105 | */ |
bcostm | 6:e1d9da7fe856 | 106 | /** |
bcostm | 6:e1d9da7fe856 | 107 | * @} |
bcostm | 6:e1d9da7fe856 | 108 | */ |
bcostm | 6:e1d9da7fe856 | 109 | |
bcostm | 6:e1d9da7fe856 | 110 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_Variables STM32746G_DISCOVERY_CAMERA Private Variables |
bcostm | 6:e1d9da7fe856 | 111 | * @{ |
bcostm | 6:e1d9da7fe856 | 112 | */ |
bcostm | 6:e1d9da7fe856 | 113 | DCMI_HandleTypeDef hDcmiHandler; |
bcostm | 6:e1d9da7fe856 | 114 | CAMERA_DrvTypeDef *camera_drv; |
bcostm | 6:e1d9da7fe856 | 115 | /* Camera current resolution naming (QQVGA, VGA, ...) */ |
bcostm | 6:e1d9da7fe856 | 116 | static uint32_t CameraCurrentResolution; |
bcostm | 6:e1d9da7fe856 | 117 | |
bcostm | 6:e1d9da7fe856 | 118 | /* Camera module I2C HW address */ |
bcostm | 6:e1d9da7fe856 | 119 | static uint32_t CameraHwAddress; |
bcostm | 6:e1d9da7fe856 | 120 | /** |
bcostm | 6:e1d9da7fe856 | 121 | * @} |
bcostm | 6:e1d9da7fe856 | 122 | */ |
bcostm | 6:e1d9da7fe856 | 123 | |
bcostm | 6:e1d9da7fe856 | 124 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_FunctionPrototypes STM32746G_DISCOVERY_CAMERA Private Function Prototypes |
bcostm | 6:e1d9da7fe856 | 125 | * @{ |
bcostm | 6:e1d9da7fe856 | 126 | */ |
bcostm | 6:e1d9da7fe856 | 127 | static uint32_t GetSize(uint32_t resolution); |
bcostm | 6:e1d9da7fe856 | 128 | /** |
bcostm | 6:e1d9da7fe856 | 129 | * @} |
bcostm | 6:e1d9da7fe856 | 130 | */ |
bcostm | 6:e1d9da7fe856 | 131 | |
bcostm | 6:e1d9da7fe856 | 132 | /** @defgroup STM32746G_DISCOVERY_CAMERA_Exported_Functions STM32746G_DISCOVERY_CAMERA Exported Functions |
bcostm | 6:e1d9da7fe856 | 133 | * @{ |
bcostm | 6:e1d9da7fe856 | 134 | */ |
bcostm | 6:e1d9da7fe856 | 135 | |
bcostm | 6:e1d9da7fe856 | 136 | /** |
bcostm | 6:e1d9da7fe856 | 137 | * @brief Initializes the camera. |
bcostm | 6:e1d9da7fe856 | 138 | * @param Resolution : camera sensor requested resolution (x, y) : standard resolution |
bcostm | 6:e1d9da7fe856 | 139 | * naming QQVGA, QVGA, VGA ... |
bcostm | 6:e1d9da7fe856 | 140 | * @retval Camera status |
bcostm | 6:e1d9da7fe856 | 141 | */ |
bcostm | 6:e1d9da7fe856 | 142 | uint8_t BSP_CAMERA_Init(uint32_t Resolution) |
bcostm | 6:e1d9da7fe856 | 143 | { |
bcostm | 6:e1d9da7fe856 | 144 | DCMI_HandleTypeDef *phdcmi; |
bcostm | 6:e1d9da7fe856 | 145 | uint8_t status = CAMERA_ERROR; |
bcostm | 6:e1d9da7fe856 | 146 | |
bcostm | 6:e1d9da7fe856 | 147 | /* Get the DCMI handle structure */ |
bcostm | 6:e1d9da7fe856 | 148 | phdcmi = &hDcmiHandler; |
bcostm | 6:e1d9da7fe856 | 149 | |
bcostm | 6:e1d9da7fe856 | 150 | /*** Configures the DCMI to interface with the camera module ***/ |
bcostm | 6:e1d9da7fe856 | 151 | /* DCMI configuration */ |
bcostm | 6:e1d9da7fe856 | 152 | phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME; |
bcostm | 6:e1d9da7fe856 | 153 | phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_LOW; |
bcostm | 6:e1d9da7fe856 | 154 | phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; |
bcostm | 6:e1d9da7fe856 | 155 | phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_HIGH; |
bcostm | 6:e1d9da7fe856 | 156 | phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; |
bcostm | 6:e1d9da7fe856 | 157 | phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING; |
bcostm | 6:e1d9da7fe856 | 158 | phdcmi->Instance = DCMI; |
bcostm | 6:e1d9da7fe856 | 159 | |
bcostm | 6:e1d9da7fe856 | 160 | /* Power up camera */ |
bcostm | 6:e1d9da7fe856 | 161 | BSP_CAMERA_PwrUp(); |
bcostm | 6:e1d9da7fe856 | 162 | |
bcostm | 6:e1d9da7fe856 | 163 | /* Read ID of Camera module via I2C */ |
bcostm | 6:e1d9da7fe856 | 164 | if(ov9655_ReadID(CAMERA_I2C_ADDRESS) == OV9655_ID) |
bcostm | 6:e1d9da7fe856 | 165 | { |
bcostm | 6:e1d9da7fe856 | 166 | /* Initialize the camera driver structure */ |
bcostm | 6:e1d9da7fe856 | 167 | camera_drv = &ov9655_drv; |
bcostm | 6:e1d9da7fe856 | 168 | CameraHwAddress = CAMERA_I2C_ADDRESS; |
bcostm | 6:e1d9da7fe856 | 169 | |
bcostm | 6:e1d9da7fe856 | 170 | /* DCMI Initialization */ |
bcostm | 6:e1d9da7fe856 | 171 | BSP_CAMERA_MspInit(&hDcmiHandler, NULL); |
bcostm | 6:e1d9da7fe856 | 172 | HAL_DCMI_Init(phdcmi); |
bcostm | 6:e1d9da7fe856 | 173 | |
bcostm | 6:e1d9da7fe856 | 174 | /* Camera Module Initialization via I2C to the wanted 'Resolution' */ |
bcostm | 6:e1d9da7fe856 | 175 | if (Resolution == CAMERA_R480x272) |
bcostm | 6:e1d9da7fe856 | 176 | { /* For 480x272 resolution, the OV9655 sensor is set to VGA resolution |
bcostm | 6:e1d9da7fe856 | 177 | * as OV9655 doesn't supports 480x272 resolution, |
bcostm | 6:e1d9da7fe856 | 178 | * then DCMI is configured to output a 480x272 cropped window */ |
bcostm | 6:e1d9da7fe856 | 179 | camera_drv->Init(CameraHwAddress, CAMERA_R640x480); |
bcostm | 6:e1d9da7fe856 | 180 | HAL_DCMI_ConfigCROP(phdcmi, /* Crop in the middle of the VGA picture */ |
bcostm | 6:e1d9da7fe856 | 181 | (CAMERA_VGA_RES_X - CAMERA_480x272_RES_X)/2, |
bcostm | 6:e1d9da7fe856 | 182 | (CAMERA_VGA_RES_Y - CAMERA_480x272_RES_Y)/2, |
bcostm | 6:e1d9da7fe856 | 183 | (CAMERA_480x272_RES_X * 2) - 1, |
bcostm | 6:e1d9da7fe856 | 184 | CAMERA_480x272_RES_Y - 1); |
bcostm | 6:e1d9da7fe856 | 185 | HAL_DCMI_EnableCROP(phdcmi); |
bcostm | 6:e1d9da7fe856 | 186 | } |
bcostm | 6:e1d9da7fe856 | 187 | else |
bcostm | 6:e1d9da7fe856 | 188 | { |
bcostm | 6:e1d9da7fe856 | 189 | camera_drv->Init(CameraHwAddress, Resolution); |
bcostm | 6:e1d9da7fe856 | 190 | HAL_DCMI_DisableCROP(phdcmi); |
bcostm | 6:e1d9da7fe856 | 191 | } |
bcostm | 6:e1d9da7fe856 | 192 | |
bcostm | 6:e1d9da7fe856 | 193 | CameraCurrentResolution = Resolution; |
bcostm | 6:e1d9da7fe856 | 194 | |
bcostm | 6:e1d9da7fe856 | 195 | /* Return CAMERA_OK status */ |
bcostm | 6:e1d9da7fe856 | 196 | status = CAMERA_OK; |
bcostm | 6:e1d9da7fe856 | 197 | } |
bcostm | 6:e1d9da7fe856 | 198 | else |
bcostm | 6:e1d9da7fe856 | 199 | { |
bcostm | 6:e1d9da7fe856 | 200 | /* Return CAMERA_NOT_SUPPORTED status */ |
bcostm | 6:e1d9da7fe856 | 201 | status = CAMERA_NOT_SUPPORTED; |
bcostm | 6:e1d9da7fe856 | 202 | } |
bcostm | 6:e1d9da7fe856 | 203 | |
bcostm | 6:e1d9da7fe856 | 204 | return status; |
bcostm | 6:e1d9da7fe856 | 205 | } |
bcostm | 6:e1d9da7fe856 | 206 | |
bcostm | 6:e1d9da7fe856 | 207 | /** |
bcostm | 6:e1d9da7fe856 | 208 | * @brief DeInitializes the camera. |
bcostm | 6:e1d9da7fe856 | 209 | * @retval Camera status |
bcostm | 6:e1d9da7fe856 | 210 | */ |
bcostm | 6:e1d9da7fe856 | 211 | uint8_t BSP_CAMERA_DeInit(void) |
bcostm | 6:e1d9da7fe856 | 212 | { |
bcostm | 6:e1d9da7fe856 | 213 | hDcmiHandler.Instance = DCMI; |
bcostm | 6:e1d9da7fe856 | 214 | |
bcostm | 6:e1d9da7fe856 | 215 | HAL_DCMI_DeInit(&hDcmiHandler); |
bcostm | 6:e1d9da7fe856 | 216 | BSP_CAMERA_MspDeInit(&hDcmiHandler, NULL); |
bcostm | 6:e1d9da7fe856 | 217 | return CAMERA_OK; |
bcostm | 6:e1d9da7fe856 | 218 | } |
bcostm | 6:e1d9da7fe856 | 219 | |
bcostm | 6:e1d9da7fe856 | 220 | /** |
bcostm | 6:e1d9da7fe856 | 221 | * @brief Starts the camera capture in continuous mode. |
bcostm | 6:e1d9da7fe856 | 222 | * @param buff: pointer to the camera output buffer |
bcostm | 6:e1d9da7fe856 | 223 | * @retval None |
bcostm | 6:e1d9da7fe856 | 224 | */ |
bcostm | 6:e1d9da7fe856 | 225 | void BSP_CAMERA_ContinuousStart(uint8_t *buff) |
bcostm | 6:e1d9da7fe856 | 226 | { |
bcostm | 6:e1d9da7fe856 | 227 | /* Start the camera capture */ |
bcostm | 6:e1d9da7fe856 | 228 | HAL_DCMI_Start_DMA(&hDcmiHandler, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(CameraCurrentResolution)); |
bcostm | 6:e1d9da7fe856 | 229 | } |
bcostm | 6:e1d9da7fe856 | 230 | |
bcostm | 6:e1d9da7fe856 | 231 | /** |
bcostm | 6:e1d9da7fe856 | 232 | * @brief Starts the camera capture in snapshot mode. |
bcostm | 6:e1d9da7fe856 | 233 | * @param buff: pointer to the camera output buffer |
bcostm | 6:e1d9da7fe856 | 234 | * @retval None |
bcostm | 6:e1d9da7fe856 | 235 | */ |
bcostm | 6:e1d9da7fe856 | 236 | void BSP_CAMERA_SnapshotStart(uint8_t *buff) |
bcostm | 6:e1d9da7fe856 | 237 | { |
bcostm | 6:e1d9da7fe856 | 238 | /* Start the camera capture */ |
bcostm | 6:e1d9da7fe856 | 239 | HAL_DCMI_Start_DMA(&hDcmiHandler, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(CameraCurrentResolution)); |
bcostm | 6:e1d9da7fe856 | 240 | } |
bcostm | 6:e1d9da7fe856 | 241 | |
bcostm | 6:e1d9da7fe856 | 242 | /** |
bcostm | 6:e1d9da7fe856 | 243 | * @brief Suspend the CAMERA capture |
bcostm | 6:e1d9da7fe856 | 244 | * @retval None |
bcostm | 6:e1d9da7fe856 | 245 | */ |
bcostm | 6:e1d9da7fe856 | 246 | void BSP_CAMERA_Suspend(void) |
bcostm | 6:e1d9da7fe856 | 247 | { |
bcostm | 6:e1d9da7fe856 | 248 | /* Suspend the Camera Capture */ |
bcostm | 6:e1d9da7fe856 | 249 | HAL_DCMI_Suspend(&hDcmiHandler); |
bcostm | 6:e1d9da7fe856 | 250 | } |
bcostm | 6:e1d9da7fe856 | 251 | |
bcostm | 6:e1d9da7fe856 | 252 | /** |
bcostm | 6:e1d9da7fe856 | 253 | * @brief Resume the CAMERA capture |
bcostm | 6:e1d9da7fe856 | 254 | * @retval None |
bcostm | 6:e1d9da7fe856 | 255 | */ |
bcostm | 6:e1d9da7fe856 | 256 | void BSP_CAMERA_Resume(void) |
bcostm | 6:e1d9da7fe856 | 257 | { |
bcostm | 6:e1d9da7fe856 | 258 | /* Start the Camera Capture */ |
bcostm | 6:e1d9da7fe856 | 259 | HAL_DCMI_Resume(&hDcmiHandler); |
bcostm | 6:e1d9da7fe856 | 260 | } |
bcostm | 6:e1d9da7fe856 | 261 | |
bcostm | 6:e1d9da7fe856 | 262 | /** |
bcostm | 6:e1d9da7fe856 | 263 | * @brief Stop the CAMERA capture |
bcostm | 6:e1d9da7fe856 | 264 | * @retval Camera status |
bcostm | 6:e1d9da7fe856 | 265 | */ |
bcostm | 6:e1d9da7fe856 | 266 | uint8_t BSP_CAMERA_Stop(void) |
bcostm | 6:e1d9da7fe856 | 267 | { |
bcostm | 6:e1d9da7fe856 | 268 | uint8_t status = CAMERA_ERROR; |
bcostm | 6:e1d9da7fe856 | 269 | |
bcostm | 6:e1d9da7fe856 | 270 | if(HAL_DCMI_Stop(&hDcmiHandler) == HAL_OK) |
bcostm | 6:e1d9da7fe856 | 271 | { |
bcostm | 6:e1d9da7fe856 | 272 | status = CAMERA_OK; |
bcostm | 6:e1d9da7fe856 | 273 | } |
bcostm | 6:e1d9da7fe856 | 274 | |
bcostm | 6:e1d9da7fe856 | 275 | /* Set Camera in Power Down */ |
bcostm | 6:e1d9da7fe856 | 276 | BSP_CAMERA_PwrDown(); |
bcostm | 6:e1d9da7fe856 | 277 | |
bcostm | 6:e1d9da7fe856 | 278 | return status; |
bcostm | 6:e1d9da7fe856 | 279 | } |
bcostm | 6:e1d9da7fe856 | 280 | |
bcostm | 6:e1d9da7fe856 | 281 | /** |
bcostm | 6:e1d9da7fe856 | 282 | * @brief CANERA power up |
bcostm | 6:e1d9da7fe856 | 283 | * @retval None |
bcostm | 6:e1d9da7fe856 | 284 | */ |
bcostm | 6:e1d9da7fe856 | 285 | void BSP_CAMERA_PwrUp(void) |
bcostm | 6:e1d9da7fe856 | 286 | { |
bcostm | 6:e1d9da7fe856 | 287 | GPIO_InitTypeDef gpio_init_structure; |
bcostm | 6:e1d9da7fe856 | 288 | |
bcostm | 6:e1d9da7fe856 | 289 | /* Enable GPIO clock */ |
bcostm | 6:e1d9da7fe856 | 290 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
bcostm | 6:e1d9da7fe856 | 291 | |
bcostm | 6:e1d9da7fe856 | 292 | /*** Configure the GPIO ***/ |
bcostm | 6:e1d9da7fe856 | 293 | /* Configure DCMI GPIO as alternate function */ |
bcostm | 6:e1d9da7fe856 | 294 | gpio_init_structure.Pin = GPIO_PIN_13; |
bcostm | 6:e1d9da7fe856 | 295 | gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; |
bcostm | 6:e1d9da7fe856 | 296 | gpio_init_structure.Pull = GPIO_NOPULL; |
bcostm | 6:e1d9da7fe856 | 297 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 6:e1d9da7fe856 | 298 | HAL_GPIO_Init(GPIOH, &gpio_init_structure); |
bcostm | 6:e1d9da7fe856 | 299 | |
bcostm | 6:e1d9da7fe856 | 300 | /* De-assert the camera POWER_DOWN pin (active high) */ |
bcostm | 6:e1d9da7fe856 | 301 | HAL_GPIO_WritePin(GPIOH, GPIO_PIN_13, GPIO_PIN_RESET); |
bcostm | 6:e1d9da7fe856 | 302 | |
Jerome Coutant
9:df2ea349c37a
|
303
|
wait_ms(3); /* POWER_DOWN de-asserted during 3ms */
|
|
bcostm | 6:e1d9da7fe856 | 304 | } |
bcostm | 6:e1d9da7fe856 | 305 | |
bcostm | 6:e1d9da7fe856 | 306 | /** |
bcostm | 6:e1d9da7fe856 | 307 | * @brief CAMERA power down |
bcostm | 6:e1d9da7fe856 | 308 | * @retval None |
bcostm | 6:e1d9da7fe856 | 309 | */ |
bcostm | 6:e1d9da7fe856 | 310 | void BSP_CAMERA_PwrDown(void) |
bcostm | 6:e1d9da7fe856 | 311 | { |
bcostm | 6:e1d9da7fe856 | 312 | GPIO_InitTypeDef gpio_init_structure; |
bcostm | 6:e1d9da7fe856 | 313 | |
bcostm | 6:e1d9da7fe856 | 314 | /* Enable GPIO clock */ |
bcostm | 6:e1d9da7fe856 | 315 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
bcostm | 6:e1d9da7fe856 | 316 | |
bcostm | 6:e1d9da7fe856 | 317 | /*** Configure the GPIO ***/ |
bcostm | 6:e1d9da7fe856 | 318 | /* Configure DCMI GPIO as alternate function */ |
bcostm | 6:e1d9da7fe856 | 319 | gpio_init_structure.Pin = GPIO_PIN_13; |
bcostm | 6:e1d9da7fe856 | 320 | gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; |
bcostm | 6:e1d9da7fe856 | 321 | gpio_init_structure.Pull = GPIO_NOPULL; |
bcostm | 6:e1d9da7fe856 | 322 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 6:e1d9da7fe856 | 323 | HAL_GPIO_Init(GPIOH, &gpio_init_structure); |
bcostm | 6:e1d9da7fe856 | 324 | |
bcostm | 6:e1d9da7fe856 | 325 | /* Assert the camera POWER_DOWN pin (active high) */ |
bcostm | 6:e1d9da7fe856 | 326 | HAL_GPIO_WritePin(GPIOH, GPIO_PIN_13, GPIO_PIN_SET); |
bcostm | 6:e1d9da7fe856 | 327 | } |
bcostm | 6:e1d9da7fe856 | 328 | |
bcostm | 6:e1d9da7fe856 | 329 | /** |
bcostm | 6:e1d9da7fe856 | 330 | * @brief Configures the camera contrast and brightness. |
bcostm | 6:e1d9da7fe856 | 331 | * @param contrast_level: Contrast level |
bcostm | 6:e1d9da7fe856 | 332 | * This parameter can be one of the following values: |
bcostm | 6:e1d9da7fe856 | 333 | * @arg CAMERA_CONTRAST_LEVEL4: for contrast +2 |
bcostm | 6:e1d9da7fe856 | 334 | * @arg CAMERA_CONTRAST_LEVEL3: for contrast +1 |
bcostm | 6:e1d9da7fe856 | 335 | * @arg CAMERA_CONTRAST_LEVEL2: for contrast 0 |
bcostm | 6:e1d9da7fe856 | 336 | * @arg CAMERA_CONTRAST_LEVEL1: for contrast -1 |
bcostm | 6:e1d9da7fe856 | 337 | * @arg CAMERA_CONTRAST_LEVEL0: for contrast -2 |
bcostm | 6:e1d9da7fe856 | 338 | * @param brightness_level: Contrast level |
bcostm | 6:e1d9da7fe856 | 339 | * This parameter can be one of the following values: |
bcostm | 6:e1d9da7fe856 | 340 | * @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2 |
bcostm | 6:e1d9da7fe856 | 341 | * @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1 |
bcostm | 6:e1d9da7fe856 | 342 | * @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0 |
bcostm | 6:e1d9da7fe856 | 343 | * @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1 |
bcostm | 6:e1d9da7fe856 | 344 | * @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2 |
bcostm | 6:e1d9da7fe856 | 345 | * @retval None |
bcostm | 6:e1d9da7fe856 | 346 | */ |
bcostm | 6:e1d9da7fe856 | 347 | void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level) |
bcostm | 6:e1d9da7fe856 | 348 | { |
bcostm | 6:e1d9da7fe856 | 349 | if(camera_drv->Config != NULL) |
bcostm | 6:e1d9da7fe856 | 350 | { |
bcostm | 6:e1d9da7fe856 | 351 | camera_drv->Config(CameraHwAddress, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level); |
bcostm | 6:e1d9da7fe856 | 352 | } |
bcostm | 6:e1d9da7fe856 | 353 | } |
bcostm | 6:e1d9da7fe856 | 354 | |
bcostm | 6:e1d9da7fe856 | 355 | /** |
bcostm | 6:e1d9da7fe856 | 356 | * @brief Configures the camera white balance. |
bcostm | 6:e1d9da7fe856 | 357 | * @param Mode: black_white mode |
bcostm | 6:e1d9da7fe856 | 358 | * This parameter can be one of the following values: |
bcostm | 6:e1d9da7fe856 | 359 | * @arg CAMERA_BLACK_WHITE_BW |
bcostm | 6:e1d9da7fe856 | 360 | * @arg CAMERA_BLACK_WHITE_NEGATIVE |
bcostm | 6:e1d9da7fe856 | 361 | * @arg CAMERA_BLACK_WHITE_BW_NEGATIVE |
bcostm | 6:e1d9da7fe856 | 362 | * @arg CAMERA_BLACK_WHITE_NORMAL |
bcostm | 6:e1d9da7fe856 | 363 | * @retval None |
bcostm | 6:e1d9da7fe856 | 364 | */ |
bcostm | 6:e1d9da7fe856 | 365 | void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode) |
bcostm | 6:e1d9da7fe856 | 366 | { |
bcostm | 6:e1d9da7fe856 | 367 | if(camera_drv->Config != NULL) |
bcostm | 6:e1d9da7fe856 | 368 | { |
bcostm | 6:e1d9da7fe856 | 369 | camera_drv->Config(CameraHwAddress, CAMERA_BLACK_WHITE, Mode, 0); |
bcostm | 6:e1d9da7fe856 | 370 | } |
bcostm | 6:e1d9da7fe856 | 371 | } |
bcostm | 6:e1d9da7fe856 | 372 | |
bcostm | 6:e1d9da7fe856 | 373 | /** |
bcostm | 6:e1d9da7fe856 | 374 | * @brief Configures the camera color effect. |
bcostm | 6:e1d9da7fe856 | 375 | * @param Effect: Color effect |
bcostm | 6:e1d9da7fe856 | 376 | * This parameter can be one of the following values: |
bcostm | 6:e1d9da7fe856 | 377 | * @arg CAMERA_COLOR_EFFECT_ANTIQUE |
bcostm | 6:e1d9da7fe856 | 378 | * @arg CAMERA_COLOR_EFFECT_BLUE |
bcostm | 6:e1d9da7fe856 | 379 | * @arg CAMERA_COLOR_EFFECT_GREEN |
bcostm | 6:e1d9da7fe856 | 380 | * @arg CAMERA_COLOR_EFFECT_RED |
bcostm | 6:e1d9da7fe856 | 381 | * @retval None |
bcostm | 6:e1d9da7fe856 | 382 | */ |
bcostm | 6:e1d9da7fe856 | 383 | void BSP_CAMERA_ColorEffectConfig(uint32_t Effect) |
bcostm | 6:e1d9da7fe856 | 384 | { |
bcostm | 6:e1d9da7fe856 | 385 | if(camera_drv->Config != NULL) |
bcostm | 6:e1d9da7fe856 | 386 | { |
bcostm | 6:e1d9da7fe856 | 387 | camera_drv->Config(CameraHwAddress, CAMERA_COLOR_EFFECT, Effect, 0); |
bcostm | 6:e1d9da7fe856 | 388 | } |
bcostm | 6:e1d9da7fe856 | 389 | } |
bcostm | 6:e1d9da7fe856 | 390 | |
bcostm | 6:e1d9da7fe856 | 391 | /** |
bcostm | 6:e1d9da7fe856 | 392 | * @brief Get the capture size in pixels unit. |
bcostm | 6:e1d9da7fe856 | 393 | * @param resolution: the current resolution. |
bcostm | 6:e1d9da7fe856 | 394 | * @retval capture size in pixels unit. |
bcostm | 6:e1d9da7fe856 | 395 | */ |
bcostm | 6:e1d9da7fe856 | 396 | static uint32_t GetSize(uint32_t resolution) |
bcostm | 6:e1d9da7fe856 | 397 | { |
bcostm | 6:e1d9da7fe856 | 398 | uint32_t size = 0; |
bcostm | 6:e1d9da7fe856 | 399 | |
bcostm | 6:e1d9da7fe856 | 400 | /* Get capture size */ |
bcostm | 6:e1d9da7fe856 | 401 | switch (resolution) |
bcostm | 6:e1d9da7fe856 | 402 | { |
bcostm | 6:e1d9da7fe856 | 403 | case CAMERA_R160x120: |
bcostm | 6:e1d9da7fe856 | 404 | { |
bcostm | 6:e1d9da7fe856 | 405 | size = 0x2580; |
bcostm | 6:e1d9da7fe856 | 406 | } |
bcostm | 6:e1d9da7fe856 | 407 | break; |
bcostm | 6:e1d9da7fe856 | 408 | case CAMERA_R320x240: |
bcostm | 6:e1d9da7fe856 | 409 | { |
bcostm | 6:e1d9da7fe856 | 410 | size = 0x9600; |
bcostm | 6:e1d9da7fe856 | 411 | } |
bcostm | 6:e1d9da7fe856 | 412 | break; |
bcostm | 6:e1d9da7fe856 | 413 | case CAMERA_R480x272: |
bcostm | 6:e1d9da7fe856 | 414 | { |
bcostm | 6:e1d9da7fe856 | 415 | size = 0xFF00; |
bcostm | 6:e1d9da7fe856 | 416 | } |
bcostm | 6:e1d9da7fe856 | 417 | break; |
bcostm | 6:e1d9da7fe856 | 418 | case CAMERA_R640x480: |
bcostm | 6:e1d9da7fe856 | 419 | { |
bcostm | 6:e1d9da7fe856 | 420 | size = 0x25800; |
bcostm | 6:e1d9da7fe856 | 421 | } |
bcostm | 6:e1d9da7fe856 | 422 | break; |
bcostm | 6:e1d9da7fe856 | 423 | default: |
bcostm | 6:e1d9da7fe856 | 424 | { |
bcostm | 6:e1d9da7fe856 | 425 | break; |
bcostm | 6:e1d9da7fe856 | 426 | } |
bcostm | 6:e1d9da7fe856 | 427 | } |
bcostm | 6:e1d9da7fe856 | 428 | |
bcostm | 6:e1d9da7fe856 | 429 | return size; |
bcostm | 6:e1d9da7fe856 | 430 | } |
bcostm | 6:e1d9da7fe856 | 431 | |
bcostm | 6:e1d9da7fe856 | 432 | /** |
bcostm | 6:e1d9da7fe856 | 433 | * @brief Initializes the DCMI MSP. |
bcostm | 6:e1d9da7fe856 | 434 | * @param hdcmi: HDMI handle |
bcostm | 6:e1d9da7fe856 | 435 | * @param Params |
bcostm | 6:e1d9da7fe856 | 436 | * @retval None |
bcostm | 6:e1d9da7fe856 | 437 | */ |
bcostm | 6:e1d9da7fe856 | 438 | __weak void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params) |
bcostm | 6:e1d9da7fe856 | 439 | { |
bcostm | 6:e1d9da7fe856 | 440 | static DMA_HandleTypeDef hdma_handler; |
bcostm | 6:e1d9da7fe856 | 441 | GPIO_InitTypeDef gpio_init_structure; |
bcostm | 6:e1d9da7fe856 | 442 | |
bcostm | 6:e1d9da7fe856 | 443 | /*** Enable peripherals and GPIO clocks ***/ |
bcostm | 6:e1d9da7fe856 | 444 | /* Enable DCMI clock */ |
bcostm | 6:e1d9da7fe856 | 445 | __HAL_RCC_DCMI_CLK_ENABLE(); |
bcostm | 6:e1d9da7fe856 | 446 | |
bcostm | 6:e1d9da7fe856 | 447 | /* Enable DMA2 clock */ |
bcostm | 6:e1d9da7fe856 | 448 | __HAL_RCC_DMA2_CLK_ENABLE(); |
bcostm | 6:e1d9da7fe856 | 449 | |
bcostm | 6:e1d9da7fe856 | 450 | /* Enable GPIO clocks */ |
bcostm | 6:e1d9da7fe856 | 451 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
bcostm | 6:e1d9da7fe856 | 452 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
bcostm | 6:e1d9da7fe856 | 453 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
bcostm | 6:e1d9da7fe856 | 454 | __HAL_RCC_GPIOG_CLK_ENABLE(); |
bcostm | 6:e1d9da7fe856 | 455 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
bcostm | 6:e1d9da7fe856 | 456 | |
bcostm | 6:e1d9da7fe856 | 457 | /*** Configure the GPIO ***/ |
bcostm | 6:e1d9da7fe856 | 458 | /* Configure DCMI GPIO as alternate function */ |
bcostm | 6:e1d9da7fe856 | 459 | gpio_init_structure.Pin = GPIO_PIN_4 | GPIO_PIN_6; |
bcostm | 6:e1d9da7fe856 | 460 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 6:e1d9da7fe856 | 461 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 6:e1d9da7fe856 | 462 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 6:e1d9da7fe856 | 463 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 6:e1d9da7fe856 | 464 | HAL_GPIO_Init(GPIOA, &gpio_init_structure); |
bcostm | 6:e1d9da7fe856 | 465 | |
bcostm | 6:e1d9da7fe856 | 466 | gpio_init_structure.Pin = GPIO_PIN_3; |
bcostm | 6:e1d9da7fe856 | 467 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 6:e1d9da7fe856 | 468 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 6:e1d9da7fe856 | 469 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 6:e1d9da7fe856 | 470 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 6:e1d9da7fe856 | 471 | HAL_GPIO_Init(GPIOD, &gpio_init_structure); |
bcostm | 6:e1d9da7fe856 | 472 | |
bcostm | 6:e1d9da7fe856 | 473 | gpio_init_structure.Pin = GPIO_PIN_5 | GPIO_PIN_6; |
bcostm | 6:e1d9da7fe856 | 474 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 6:e1d9da7fe856 | 475 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 6:e1d9da7fe856 | 476 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 6:e1d9da7fe856 | 477 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 6:e1d9da7fe856 | 478 | HAL_GPIO_Init(GPIOE, &gpio_init_structure); |
bcostm | 6:e1d9da7fe856 | 479 | |
bcostm | 6:e1d9da7fe856 | 480 | gpio_init_structure.Pin = GPIO_PIN_9; |
bcostm | 6:e1d9da7fe856 | 481 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 6:e1d9da7fe856 | 482 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 6:e1d9da7fe856 | 483 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 6:e1d9da7fe856 | 484 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 6:e1d9da7fe856 | 485 | HAL_GPIO_Init(GPIOG, &gpio_init_structure); |
bcostm | 6:e1d9da7fe856 | 486 | |
bcostm | 6:e1d9da7fe856 | 487 | gpio_init_structure.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ |
bcostm | 6:e1d9da7fe856 | 488 | GPIO_PIN_12 | GPIO_PIN_14; |
bcostm | 6:e1d9da7fe856 | 489 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
bcostm | 6:e1d9da7fe856 | 490 | gpio_init_structure.Pull = GPIO_PULLUP; |
bcostm | 6:e1d9da7fe856 | 491 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
bcostm | 6:e1d9da7fe856 | 492 | gpio_init_structure.Alternate = GPIO_AF13_DCMI; |
bcostm | 6:e1d9da7fe856 | 493 | HAL_GPIO_Init(GPIOH, &gpio_init_structure); |
bcostm | 6:e1d9da7fe856 | 494 | |
bcostm | 6:e1d9da7fe856 | 495 | /*** Configure the DMA ***/ |
bcostm | 6:e1d9da7fe856 | 496 | /* Set the parameters to be configured */ |
bcostm | 6:e1d9da7fe856 | 497 | hdma_handler.Init.Channel = DMA_CHANNEL_1; |
bcostm | 6:e1d9da7fe856 | 498 | hdma_handler.Init.Direction = DMA_PERIPH_TO_MEMORY; |
bcostm | 6:e1d9da7fe856 | 499 | hdma_handler.Init.PeriphInc = DMA_PINC_DISABLE; |
bcostm | 6:e1d9da7fe856 | 500 | hdma_handler.Init.MemInc = DMA_MINC_ENABLE; |
bcostm | 6:e1d9da7fe856 | 501 | hdma_handler.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; |
bcostm | 6:e1d9da7fe856 | 502 | hdma_handler.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; |
bcostm | 6:e1d9da7fe856 | 503 | hdma_handler.Init.Mode = DMA_CIRCULAR; |
bcostm | 6:e1d9da7fe856 | 504 | hdma_handler.Init.Priority = DMA_PRIORITY_HIGH; |
bcostm | 6:e1d9da7fe856 | 505 | hdma_handler.Init.FIFOMode = DMA_FIFOMODE_DISABLE; |
bcostm | 6:e1d9da7fe856 | 506 | hdma_handler.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; |
bcostm | 6:e1d9da7fe856 | 507 | hdma_handler.Init.MemBurst = DMA_MBURST_SINGLE; |
bcostm | 6:e1d9da7fe856 | 508 | hdma_handler.Init.PeriphBurst = DMA_PBURST_SINGLE; |
bcostm | 6:e1d9da7fe856 | 509 | |
bcostm | 6:e1d9da7fe856 | 510 | hdma_handler.Instance = DMA2_Stream1; |
bcostm | 6:e1d9da7fe856 | 511 | |
bcostm | 6:e1d9da7fe856 | 512 | /* Associate the initialized DMA handle to the DCMI handle */ |
bcostm | 6:e1d9da7fe856 | 513 | __HAL_LINKDMA(hdcmi, DMA_Handle, hdma_handler); |
bcostm | 6:e1d9da7fe856 | 514 | |
bcostm | 6:e1d9da7fe856 | 515 | /*** Configure the NVIC for DCMI and DMA ***/ |
bcostm | 6:e1d9da7fe856 | 516 | /* NVIC configuration for DCMI transfer complete interrupt */ |
bcostm | 6:e1d9da7fe856 | 517 | HAL_NVIC_SetPriority(DCMI_IRQn, 0x0F, 0); |
bcostm | 6:e1d9da7fe856 | 518 | HAL_NVIC_EnableIRQ(DCMI_IRQn); |
bcostm | 6:e1d9da7fe856 | 519 | |
bcostm | 6:e1d9da7fe856 | 520 | /* NVIC configuration for DMA2D transfer complete interrupt */ |
bcostm | 6:e1d9da7fe856 | 521 | HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 0x0F, 0); |
bcostm | 6:e1d9da7fe856 | 522 | HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); |
bcostm | 6:e1d9da7fe856 | 523 | |
bcostm | 6:e1d9da7fe856 | 524 | /* Configure the DMA stream */ |
bcostm | 6:e1d9da7fe856 | 525 | HAL_DMA_Init(hdcmi->DMA_Handle); |
bcostm | 6:e1d9da7fe856 | 526 | } |
bcostm | 6:e1d9da7fe856 | 527 | |
bcostm | 6:e1d9da7fe856 | 528 | |
bcostm | 6:e1d9da7fe856 | 529 | /** |
bcostm | 6:e1d9da7fe856 | 530 | * @brief DeInitializes the DCMI MSP. |
bcostm | 6:e1d9da7fe856 | 531 | * @param hdcmi: HDMI handle |
bcostm | 6:e1d9da7fe856 | 532 | * @param Params |
bcostm | 6:e1d9da7fe856 | 533 | * @retval None |
bcostm | 6:e1d9da7fe856 | 534 | */ |
bcostm | 6:e1d9da7fe856 | 535 | __weak void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params) |
bcostm | 6:e1d9da7fe856 | 536 | { |
bcostm | 6:e1d9da7fe856 | 537 | /* Disable NVIC for DCMI transfer complete interrupt */ |
bcostm | 6:e1d9da7fe856 | 538 | HAL_NVIC_DisableIRQ(DCMI_IRQn); |
bcostm | 6:e1d9da7fe856 | 539 | |
bcostm | 6:e1d9da7fe856 | 540 | /* Disable NVIC for DMA2 transfer complete interrupt */ |
bcostm | 6:e1d9da7fe856 | 541 | HAL_NVIC_DisableIRQ(DMA2_Stream1_IRQn); |
bcostm | 6:e1d9da7fe856 | 542 | |
bcostm | 6:e1d9da7fe856 | 543 | /* Configure the DMA stream */ |
bcostm | 6:e1d9da7fe856 | 544 | HAL_DMA_DeInit(hdcmi->DMA_Handle); |
bcostm | 6:e1d9da7fe856 | 545 | |
bcostm | 6:e1d9da7fe856 | 546 | /* Disable DCMI clock */ |
bcostm | 6:e1d9da7fe856 | 547 | __HAL_RCC_DCMI_CLK_DISABLE(); |
bcostm | 6:e1d9da7fe856 | 548 | |
bcostm | 6:e1d9da7fe856 | 549 | /* GPIO pins clock and DMA clock can be shut down in the application |
bcostm | 6:e1d9da7fe856 | 550 | by surcharging this __weak function */ |
bcostm | 6:e1d9da7fe856 | 551 | } |
bcostm | 6:e1d9da7fe856 | 552 | |
bcostm | 6:e1d9da7fe856 | 553 | /** |
bcostm | 6:e1d9da7fe856 | 554 | * @brief Line event callback |
bcostm | 6:e1d9da7fe856 | 555 | * @param hdcmi: pointer to the DCMI handle |
bcostm | 6:e1d9da7fe856 | 556 | * @retval None |
bcostm | 6:e1d9da7fe856 | 557 | */ |
bcostm | 6:e1d9da7fe856 | 558 | void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) |
bcostm | 6:e1d9da7fe856 | 559 | { |
bcostm | 6:e1d9da7fe856 | 560 | BSP_CAMERA_LineEventCallback(); |
bcostm | 6:e1d9da7fe856 | 561 | } |
bcostm | 6:e1d9da7fe856 | 562 | |
bcostm | 6:e1d9da7fe856 | 563 | /** |
bcostm | 6:e1d9da7fe856 | 564 | * @brief Line Event callback. |
bcostm | 6:e1d9da7fe856 | 565 | * @retval None |
bcostm | 6:e1d9da7fe856 | 566 | */ |
bcostm | 6:e1d9da7fe856 | 567 | __weak void BSP_CAMERA_LineEventCallback(void) |
bcostm | 6:e1d9da7fe856 | 568 | { |
bcostm | 6:e1d9da7fe856 | 569 | /* NOTE : This function Should not be modified, when the callback is needed, |
bcostm | 6:e1d9da7fe856 | 570 | the HAL_DCMI_LineEventCallback could be implemented in the user file |
bcostm | 6:e1d9da7fe856 | 571 | */ |
bcostm | 6:e1d9da7fe856 | 572 | } |
bcostm | 6:e1d9da7fe856 | 573 | |
bcostm | 6:e1d9da7fe856 | 574 | /** |
bcostm | 6:e1d9da7fe856 | 575 | * @brief VSYNC event callback |
bcostm | 6:e1d9da7fe856 | 576 | * @param hdcmi: pointer to the DCMI handle |
bcostm | 6:e1d9da7fe856 | 577 | * @retval None |
bcostm | 6:e1d9da7fe856 | 578 | */ |
bcostm | 6:e1d9da7fe856 | 579 | void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) |
bcostm | 6:e1d9da7fe856 | 580 | { |
bcostm | 6:e1d9da7fe856 | 581 | BSP_CAMERA_VsyncEventCallback(); |
bcostm | 6:e1d9da7fe856 | 582 | } |
bcostm | 6:e1d9da7fe856 | 583 | |
bcostm | 6:e1d9da7fe856 | 584 | /** |
bcostm | 6:e1d9da7fe856 | 585 | * @brief VSYNC Event callback. |
bcostm | 6:e1d9da7fe856 | 586 | * @retval None |
bcostm | 6:e1d9da7fe856 | 587 | */ |
bcostm | 6:e1d9da7fe856 | 588 | __weak void BSP_CAMERA_VsyncEventCallback(void) |
bcostm | 6:e1d9da7fe856 | 589 | { |
bcostm | 6:e1d9da7fe856 | 590 | /* NOTE : This function Should not be modified, when the callback is needed, |
bcostm | 6:e1d9da7fe856 | 591 | the HAL_DCMI_VsyncEventCallback could be implemented in the user file |
bcostm | 6:e1d9da7fe856 | 592 | */ |
bcostm | 6:e1d9da7fe856 | 593 | } |
bcostm | 6:e1d9da7fe856 | 594 | |
bcostm | 6:e1d9da7fe856 | 595 | /** |
bcostm | 6:e1d9da7fe856 | 596 | * @brief Frame event callback |
bcostm | 6:e1d9da7fe856 | 597 | * @param hdcmi: pointer to the DCMI handle |
bcostm | 6:e1d9da7fe856 | 598 | * @retval None |
bcostm | 6:e1d9da7fe856 | 599 | */ |
bcostm | 6:e1d9da7fe856 | 600 | void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) |
bcostm | 6:e1d9da7fe856 | 601 | { |
bcostm | 6:e1d9da7fe856 | 602 | BSP_CAMERA_FrameEventCallback(); |
bcostm | 6:e1d9da7fe856 | 603 | } |
bcostm | 6:e1d9da7fe856 | 604 | |
bcostm | 6:e1d9da7fe856 | 605 | /** |
bcostm | 6:e1d9da7fe856 | 606 | * @brief Frame Event callback. |
bcostm | 6:e1d9da7fe856 | 607 | * @retval None |
bcostm | 6:e1d9da7fe856 | 608 | */ |
bcostm | 6:e1d9da7fe856 | 609 | __weak void BSP_CAMERA_FrameEventCallback(void) |
bcostm | 6:e1d9da7fe856 | 610 | { |
bcostm | 6:e1d9da7fe856 | 611 | /* NOTE : This function Should not be modified, when the callback is needed, |
bcostm | 6:e1d9da7fe856 | 612 | the HAL_DCMI_FrameEventCallback could be implemented in the user file |
bcostm | 6:e1d9da7fe856 | 613 | */ |
bcostm | 6:e1d9da7fe856 | 614 | } |
bcostm | 6:e1d9da7fe856 | 615 | |
bcostm | 6:e1d9da7fe856 | 616 | /** |
bcostm | 6:e1d9da7fe856 | 617 | * @brief Error callback |
bcostm | 6:e1d9da7fe856 | 618 | * @param hdcmi: pointer to the DCMI handle |
bcostm | 6:e1d9da7fe856 | 619 | * @retval None |
bcostm | 6:e1d9da7fe856 | 620 | */ |
bcostm | 6:e1d9da7fe856 | 621 | void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi) |
bcostm | 6:e1d9da7fe856 | 622 | { |
bcostm | 6:e1d9da7fe856 | 623 | BSP_CAMERA_ErrorCallback(); |
bcostm | 6:e1d9da7fe856 | 624 | } |
bcostm | 6:e1d9da7fe856 | 625 | |
bcostm | 6:e1d9da7fe856 | 626 | /** |
bcostm | 6:e1d9da7fe856 | 627 | * @brief Error callback. |
bcostm | 6:e1d9da7fe856 | 628 | * @retval None |
bcostm | 6:e1d9da7fe856 | 629 | */ |
bcostm | 6:e1d9da7fe856 | 630 | __weak void BSP_CAMERA_ErrorCallback(void) |
bcostm | 6:e1d9da7fe856 | 631 | { |
bcostm | 6:e1d9da7fe856 | 632 | /* NOTE : This function Should not be modified, when the callback is needed, |
bcostm | 6:e1d9da7fe856 | 633 | the HAL_DCMI_ErrorCallback could be implemented in the user file |
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 | */ |
bcostm | 6:e1d9da7fe856 | 652 | |
bcostm | 6:e1d9da7fe856 | 653 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |