STM32746G-Discovery board drivers V1.0.0
Dependents: F746_SD_GraphicEqualizer_ren0620
Fork of BSP_DISCO_F746NG by
stm32746g_discovery_camera.c
00001 /** 00002 ****************************************************************************** 00003 * @file stm32746g_discovery_camera.c 00004 * @author MCD Application Team 00005 * @version V1.0.0 00006 * @date 25-June-2015 00007 * @brief This file includes the driver for Camera modules mounted on 00008 * STM32746G-Discovery board. 00009 @verbatim 00010 How to use this driver: 00011 ------------------------ 00012 - This driver is used to drive the camera. 00013 - The OV9655 component driver MUST be included with this driver. 00014 00015 Driver description: 00016 ------------------- 00017 + Initialization steps: 00018 o Initialize the camera using the BSP_CAMERA_Init() function. 00019 o Start the camera capture/snapshot using the CAMERA_Start() function. 00020 o Suspend, resume or stop the camera capture using the following functions: 00021 - BSP_CAMERA_Suspend() 00022 - BSP_CAMERA_Resume() 00023 - BSP_CAMERA_Stop() 00024 00025 + Options 00026 o Increase or decrease on the fly the brightness and/or contrast 00027 using the following function: 00028 - BSP_CAMERA_ContrastBrightnessConfig 00029 o Add a special effect on the fly using the following functions: 00030 - BSP_CAMERA_BlackWhiteConfig() 00031 - BSP_CAMERA_ColorEffectConfig() 00032 @endverbatim 00033 ****************************************************************************** 00034 * @attention 00035 * 00036 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00037 * 00038 * Redistribution and use in source and binary forms, with or without modification, 00039 * are permitted provided that the following conditions are met: 00040 * 1. Redistributions of source code must retain the above copyright notice, 00041 * this list of conditions and the following disclaimer. 00042 * 2. Redistributions in binary form must reproduce the above copyright notice, 00043 * this list of conditions and the following disclaimer in the documentation 00044 * and/or other materials provided with the distribution. 00045 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00046 * may be used to endorse or promote products derived from this software 00047 * without specific prior written permission. 00048 * 00049 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00050 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00051 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00052 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00053 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00054 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00055 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00056 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00057 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00058 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00059 * 00060 ****************************************************************************** 00061 */ 00062 00063 /* Includes ------------------------------------------------------------------*/ 00064 #include "stm32746g_discovery_camera.h" 00065 #include "stm32746g_discovery.h" 00066 00067 /** @addtogroup BSP 00068 * @{ 00069 */ 00070 00071 /** @addtogroup STM32746G_DISCOVERY 00072 * @{ 00073 */ 00074 00075 /** @addtogroup STM32746G_DISCOVERY_CAMERA 00076 * @{ 00077 */ 00078 00079 /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_TypesDefinitions STM32746G_DISCOVERY_CAMERA Private Types Definitions 00080 * @{ 00081 */ 00082 /** 00083 * @} 00084 */ 00085 00086 /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_Defines STM32746G_DISCOVERY_CAMERA Private Defines 00087 * @{ 00088 */ 00089 #define CAMERA_VGA_RES_X 640 00090 #define CAMERA_VGA_RES_Y 480 00091 #define CAMERA_480x272_RES_X 480 00092 #define CAMERA_480x272_RES_Y 272 00093 #define CAMERA_QVGA_RES_X 320 00094 #define CAMERA_QVGA_RES_Y 240 00095 #define CAMERA_QQVGA_RES_X 160 00096 #define CAMERA_QQVGA_RES_Y 120 00097 /** 00098 * @} 00099 */ 00100 00101 /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_Macros STM32746G_DISCOVERY_CAMERA Private Macros 00102 * @{ 00103 */ 00104 /** 00105 * @} 00106 */ 00107 00108 /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_Variables STM32746G_DISCOVERY_CAMERA Private Variables 00109 * @{ 00110 */ 00111 static DCMI_HandleTypeDef hDcmiHandler; 00112 CAMERA_DrvTypeDef *camera_drv; 00113 /* Camera current resolution naming (QQVGA, VGA, ...) */ 00114 static uint32_t CameraCurrentResolution; 00115 00116 /* Camera module I2C HW address */ 00117 static uint32_t CameraHwAddress; 00118 /** 00119 * @} 00120 */ 00121 00122 /** @defgroup STM32746G_DISCOVERY_CAMERA_Private_FunctionPrototypes STM32746G_DISCOVERY_CAMERA Private Function Prototypes 00123 * @{ 00124 */ 00125 static uint32_t GetSize(uint32_t resolution); 00126 /** 00127 * @} 00128 */ 00129 00130 /** @defgroup STM32746G_DISCOVERY_CAMERA_Exported_Functions STM32746G_DISCOVERY_CAMERA Exported Functions 00131 * @{ 00132 */ 00133 00134 /** 00135 * @brief Initializes the camera. 00136 * @param Resolution : camera sensor requested resolution (x, y) : standard resolution 00137 * naming QQVGA, QVGA, VGA ... 00138 * @retval Camera status 00139 */ 00140 uint8_t BSP_CAMERA_Init(uint32_t Resolution) 00141 { 00142 DCMI_HandleTypeDef *phdcmi; 00143 uint8_t status = CAMERA_ERROR; 00144 00145 /* Get the DCMI handle structure */ 00146 phdcmi = &hDcmiHandler; 00147 00148 /*** Configures the DCMI to interface with the camera module ***/ 00149 /* DCMI configuration */ 00150 phdcmi->Init.CaptureRate = DCMI_CR_ALL_FRAME; 00151 phdcmi->Init.HSPolarity = DCMI_HSPOLARITY_LOW; 00152 phdcmi->Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; 00153 phdcmi->Init.VSPolarity = DCMI_VSPOLARITY_HIGH; 00154 phdcmi->Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; 00155 phdcmi->Init.PCKPolarity = DCMI_PCKPOLARITY_RISING; 00156 phdcmi->Instance = DCMI; 00157 00158 /* Power up camera */ 00159 BSP_CAMERA_PwrUp(); 00160 00161 /* Read ID of Camera module via I2C */ 00162 if(ov9655_ReadID(CAMERA_I2C_ADDRESS) == OV9655_ID) 00163 { 00164 /* Initialize the camera driver structure */ 00165 camera_drv = &ov9655_drv; 00166 CameraHwAddress = CAMERA_I2C_ADDRESS; 00167 00168 /* DCMI Initialization */ 00169 BSP_CAMERA_MspInit(&hDcmiHandler, NULL); 00170 HAL_DCMI_Init(phdcmi); 00171 00172 /* Camera Module Initialization via I2C to the wanted 'Resolution' */ 00173 if (Resolution == CAMERA_R480x272) 00174 { /* For 480x272 resolution, the OV9655 sensor is set to VGA resolution 00175 * as OV9655 doesn't supports 480x272 resolution, 00176 * then DCMI is configured to output a 480x272 cropped window */ 00177 camera_drv->Init(CameraHwAddress, CAMERA_R640x480); 00178 HAL_DCMI_ConfigCROP(phdcmi, /* Crop in the middle of the VGA picture */ 00179 (CAMERA_VGA_RES_X - CAMERA_480x272_RES_X)/2, 00180 (CAMERA_VGA_RES_Y - CAMERA_480x272_RES_Y)/2, 00181 (CAMERA_480x272_RES_X * 2) - 1, 00182 CAMERA_480x272_RES_Y - 1); 00183 HAL_DCMI_EnableCROP(phdcmi); 00184 } 00185 else 00186 { 00187 camera_drv->Init(CameraHwAddress, Resolution); 00188 HAL_DCMI_DisableCROP(phdcmi); 00189 } 00190 00191 CameraCurrentResolution = Resolution; 00192 00193 /* Return CAMERA_OK status */ 00194 status = CAMERA_OK; 00195 } 00196 else 00197 { 00198 /* Return CAMERA_NOT_SUPPORTED status */ 00199 status = CAMERA_NOT_SUPPORTED; 00200 } 00201 00202 return status; 00203 } 00204 00205 /** 00206 * @brief DeInitializes the camera. 00207 * @retval Camera status 00208 */ 00209 uint8_t BSP_CAMERA_DeInit(void) 00210 { 00211 hDcmiHandler.Instance = DCMI; 00212 00213 HAL_DCMI_DeInit(&hDcmiHandler); 00214 BSP_CAMERA_MspDeInit(&hDcmiHandler, NULL); 00215 return CAMERA_OK; 00216 } 00217 00218 /** 00219 * @brief Starts the camera capture in continuous mode. 00220 * @param buff: pointer to the camera output buffer 00221 * @retval None 00222 */ 00223 void BSP_CAMERA_ContinuousStart(uint8_t *buff) 00224 { 00225 /* Start the camera capture */ 00226 HAL_DCMI_Start_DMA(&hDcmiHandler, DCMI_MODE_CONTINUOUS, (uint32_t)buff, GetSize(CameraCurrentResolution)); 00227 } 00228 00229 /** 00230 * @brief Starts the camera capture in snapshot mode. 00231 * @param buff: pointer to the camera output buffer 00232 * @retval None 00233 */ 00234 void BSP_CAMERA_SnapshotStart(uint8_t *buff) 00235 { 00236 /* Start the camera capture */ 00237 HAL_DCMI_Start_DMA(&hDcmiHandler, DCMI_MODE_SNAPSHOT, (uint32_t)buff, GetSize(CameraCurrentResolution)); 00238 } 00239 00240 /** 00241 * @brief Suspend the CAMERA capture 00242 * @retval None 00243 */ 00244 void BSP_CAMERA_Suspend(void) 00245 { 00246 /* Disable the DMA */ 00247 __HAL_DMA_DISABLE(hDcmiHandler.DMA_Handle); 00248 /* Disable the DCMI */ 00249 __HAL_DCMI_DISABLE(&hDcmiHandler); 00250 00251 } 00252 00253 /** 00254 * @brief Resume the CAMERA capture 00255 * @retval None 00256 */ 00257 void BSP_CAMERA_Resume(void) 00258 { 00259 /* Enable the DCMI */ 00260 __HAL_DCMI_ENABLE(&hDcmiHandler); 00261 /* Enable the DMA */ 00262 __HAL_DMA_ENABLE(hDcmiHandler.DMA_Handle); 00263 } 00264 00265 /** 00266 * @brief Stop the CAMERA capture 00267 * @retval Camera status 00268 */ 00269 uint8_t BSP_CAMERA_Stop(void) 00270 { 00271 uint8_t status = CAMERA_ERROR; 00272 00273 if(HAL_DCMI_Stop(&hDcmiHandler) == HAL_OK) 00274 { 00275 status = CAMERA_OK; 00276 } 00277 00278 /* Set Camera in Power Down */ 00279 BSP_CAMERA_PwrDown(); 00280 00281 return status; 00282 } 00283 00284 /** 00285 * @brief CANERA power up 00286 * @retval None 00287 */ 00288 void BSP_CAMERA_PwrUp(void) 00289 { 00290 GPIO_InitTypeDef gpio_init_structure; 00291 00292 /* Enable GPIO clock */ 00293 __HAL_RCC_GPIOH_CLK_ENABLE(); 00294 00295 /*** Configure the GPIO ***/ 00296 /* Configure DCMI GPIO as alternate function */ 00297 gpio_init_structure.Pin = GPIO_PIN_13; 00298 gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; 00299 gpio_init_structure.Pull = GPIO_NOPULL; 00300 gpio_init_structure.Speed = GPIO_SPEED_HIGH; 00301 HAL_GPIO_Init(GPIOH, &gpio_init_structure); 00302 00303 /* De-assert the camera POWER_DOWN pin (active high) */ 00304 HAL_GPIO_WritePin(GPIOH, GPIO_PIN_13, GPIO_PIN_RESET); 00305 00306 HAL_Delay(3); /* POWER_DOWN de-asserted during 3ms */ 00307 } 00308 00309 /** 00310 * @brief CAMERA power down 00311 * @retval None 00312 */ 00313 void BSP_CAMERA_PwrDown(void) 00314 { 00315 GPIO_InitTypeDef gpio_init_structure; 00316 00317 /* Enable GPIO clock */ 00318 __HAL_RCC_GPIOH_CLK_ENABLE(); 00319 00320 /*** Configure the GPIO ***/ 00321 /* Configure DCMI GPIO as alternate function */ 00322 gpio_init_structure.Pin = GPIO_PIN_13; 00323 gpio_init_structure.Mode = GPIO_MODE_OUTPUT_PP; 00324 gpio_init_structure.Pull = GPIO_NOPULL; 00325 gpio_init_structure.Speed = GPIO_SPEED_HIGH; 00326 HAL_GPIO_Init(GPIOH, &gpio_init_structure); 00327 00328 /* Assert the camera POWER_DOWN pin (active high) */ 00329 HAL_GPIO_WritePin(GPIOH, GPIO_PIN_13, GPIO_PIN_SET); 00330 } 00331 00332 /** 00333 * @brief Configures the camera contrast and brightness. 00334 * @param contrast_level: Contrast level 00335 * This parameter can be one of the following values: 00336 * @arg CAMERA_CONTRAST_LEVEL4: for contrast +2 00337 * @arg CAMERA_CONTRAST_LEVEL3: for contrast +1 00338 * @arg CAMERA_CONTRAST_LEVEL2: for contrast 0 00339 * @arg CAMERA_CONTRAST_LEVEL1: for contrast -1 00340 * @arg CAMERA_CONTRAST_LEVEL0: for contrast -2 00341 * @param brightness_level: Contrast level 00342 * This parameter can be one of the following values: 00343 * @arg CAMERA_BRIGHTNESS_LEVEL4: for brightness +2 00344 * @arg CAMERA_BRIGHTNESS_LEVEL3: for brightness +1 00345 * @arg CAMERA_BRIGHTNESS_LEVEL2: for brightness 0 00346 * @arg CAMERA_BRIGHTNESS_LEVEL1: for brightness -1 00347 * @arg CAMERA_BRIGHTNESS_LEVEL0: for brightness -2 00348 * @retval None 00349 */ 00350 void BSP_CAMERA_ContrastBrightnessConfig(uint32_t contrast_level, uint32_t brightness_level) 00351 { 00352 if(camera_drv->Config != NULL) 00353 { 00354 camera_drv->Config(CameraHwAddress, CAMERA_CONTRAST_BRIGHTNESS, contrast_level, brightness_level); 00355 } 00356 } 00357 00358 /** 00359 * @brief Configures the camera white balance. 00360 * @param Mode: black_white mode 00361 * This parameter can be one of the following values: 00362 * @arg CAMERA_BLACK_WHITE_BW 00363 * @arg CAMERA_BLACK_WHITE_NEGATIVE 00364 * @arg CAMERA_BLACK_WHITE_BW_NEGATIVE 00365 * @arg CAMERA_BLACK_WHITE_NORMAL 00366 * @retval None 00367 */ 00368 void BSP_CAMERA_BlackWhiteConfig(uint32_t Mode) 00369 { 00370 if(camera_drv->Config != NULL) 00371 { 00372 camera_drv->Config(CameraHwAddress, CAMERA_BLACK_WHITE, Mode, 0); 00373 } 00374 } 00375 00376 /** 00377 * @brief Configures the camera color effect. 00378 * @param Effect: Color effect 00379 * This parameter can be one of the following values: 00380 * @arg CAMERA_COLOR_EFFECT_ANTIQUE 00381 * @arg CAMERA_COLOR_EFFECT_BLUE 00382 * @arg CAMERA_COLOR_EFFECT_GREEN 00383 * @arg CAMERA_COLOR_EFFECT_RED 00384 * @retval None 00385 */ 00386 void BSP_CAMERA_ColorEffectConfig(uint32_t Effect) 00387 { 00388 if(camera_drv->Config != NULL) 00389 { 00390 camera_drv->Config(CameraHwAddress, CAMERA_COLOR_EFFECT, Effect, 0); 00391 } 00392 } 00393 00394 /** 00395 * @brief Handles DCMI interrupt request. 00396 * @retval None 00397 */ 00398 void BSP_CAMERA_IRQHandler(void) 00399 { 00400 HAL_DCMI_IRQHandler(&hDcmiHandler); 00401 } 00402 00403 /** 00404 * @brief Handles DMA interrupt request. 00405 * @retval None 00406 */ 00407 void BSP_CAMERA_DMA_IRQHandler(void) 00408 { 00409 HAL_DMA_IRQHandler(hDcmiHandler.DMA_Handle); 00410 } 00411 00412 /** 00413 * @brief Get the capture size in pixels unit. 00414 * @param resolution: the current resolution. 00415 * @retval capture size in pixels unit. 00416 */ 00417 static uint32_t GetSize(uint32_t resolution) 00418 { 00419 uint32_t size = 0; 00420 00421 /* Get capture size */ 00422 switch (resolution) 00423 { 00424 case CAMERA_R160x120: 00425 { 00426 size = 0x2580; 00427 } 00428 break; 00429 case CAMERA_R320x240: 00430 { 00431 size = 0x9600; 00432 } 00433 break; 00434 case CAMERA_R480x272: 00435 { 00436 size = 0xFF00; 00437 } 00438 break; 00439 case CAMERA_R640x480: 00440 { 00441 size = 0x25800; 00442 } 00443 break; 00444 default: 00445 { 00446 break; 00447 } 00448 } 00449 00450 return size; 00451 } 00452 00453 /** 00454 * @brief Initializes the DCMI MSP. 00455 * @param hdcmi: HDMI handle 00456 * @param Params 00457 * @retval None 00458 */ 00459 __weak void BSP_CAMERA_MspInit(DCMI_HandleTypeDef *hdcmi, void *Params) 00460 { 00461 static DMA_HandleTypeDef hdma_handler; 00462 GPIO_InitTypeDef gpio_init_structure; 00463 00464 /*** Enable peripherals and GPIO clocks ***/ 00465 /* Enable DCMI clock */ 00466 __HAL_RCC_DCMI_CLK_ENABLE(); 00467 00468 /* Enable DMA2 clock */ 00469 __HAL_RCC_DMA2_CLK_ENABLE(); 00470 00471 /* Enable GPIO clocks */ 00472 __HAL_RCC_GPIOA_CLK_ENABLE(); 00473 __HAL_RCC_GPIOD_CLK_ENABLE(); 00474 __HAL_RCC_GPIOE_CLK_ENABLE(); 00475 __HAL_RCC_GPIOG_CLK_ENABLE(); 00476 __HAL_RCC_GPIOH_CLK_ENABLE(); 00477 00478 /*** Configure the GPIO ***/ 00479 /* Configure DCMI GPIO as alternate function */ 00480 gpio_init_structure.Pin = GPIO_PIN_4 | GPIO_PIN_6; 00481 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00482 gpio_init_structure.Pull = GPIO_PULLUP; 00483 gpio_init_structure.Speed = GPIO_SPEED_HIGH; 00484 gpio_init_structure.Alternate = GPIO_AF13_DCMI; 00485 HAL_GPIO_Init(GPIOA, &gpio_init_structure); 00486 00487 gpio_init_structure.Pin = GPIO_PIN_3; 00488 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00489 gpio_init_structure.Pull = GPIO_PULLUP; 00490 gpio_init_structure.Speed = GPIO_SPEED_HIGH; 00491 gpio_init_structure.Alternate = GPIO_AF13_DCMI; 00492 HAL_GPIO_Init(GPIOD, &gpio_init_structure); 00493 00494 gpio_init_structure.Pin = GPIO_PIN_5 | GPIO_PIN_6; 00495 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00496 gpio_init_structure.Pull = GPIO_PULLUP; 00497 gpio_init_structure.Speed = GPIO_SPEED_HIGH; 00498 gpio_init_structure.Alternate = GPIO_AF13_DCMI; 00499 HAL_GPIO_Init(GPIOE, &gpio_init_structure); 00500 00501 gpio_init_structure.Pin = GPIO_PIN_9; 00502 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00503 gpio_init_structure.Pull = GPIO_PULLUP; 00504 gpio_init_structure.Speed = GPIO_SPEED_HIGH; 00505 gpio_init_structure.Alternate = GPIO_AF13_DCMI; 00506 HAL_GPIO_Init(GPIOG, &gpio_init_structure); 00507 00508 gpio_init_structure.Pin = GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |\ 00509 GPIO_PIN_12 | GPIO_PIN_14; 00510 gpio_init_structure.Mode = GPIO_MODE_AF_PP; 00511 gpio_init_structure.Pull = GPIO_PULLUP; 00512 gpio_init_structure.Speed = GPIO_SPEED_HIGH; 00513 gpio_init_structure.Alternate = GPIO_AF13_DCMI; 00514 HAL_GPIO_Init(GPIOH, &gpio_init_structure); 00515 00516 /*** Configure the DMA ***/ 00517 /* Set the parameters to be configured */ 00518 hdma_handler.Init.Channel = DMA_CHANNEL_1; 00519 hdma_handler.Init.Direction = DMA_PERIPH_TO_MEMORY; 00520 hdma_handler.Init.PeriphInc = DMA_PINC_DISABLE; 00521 hdma_handler.Init.MemInc = DMA_MINC_ENABLE; 00522 hdma_handler.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; 00523 hdma_handler.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; 00524 hdma_handler.Init.Mode = DMA_CIRCULAR; 00525 hdma_handler.Init.Priority = DMA_PRIORITY_HIGH; 00526 hdma_handler.Init.FIFOMode = DMA_FIFOMODE_DISABLE; 00527 hdma_handler.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; 00528 hdma_handler.Init.MemBurst = DMA_MBURST_SINGLE; 00529 hdma_handler.Init.PeriphBurst = DMA_PBURST_SINGLE; 00530 00531 hdma_handler.Instance = DMA2_Stream1; 00532 00533 /* Associate the initialized DMA handle to the DCMI handle */ 00534 __HAL_LINKDMA(hdcmi, DMA_Handle, hdma_handler); 00535 00536 /*** Configure the NVIC for DCMI and DMA ***/ 00537 /* NVIC configuration for DCMI transfer complete interrupt */ 00538 HAL_NVIC_SetPriority(DCMI_IRQn, 5, 0); 00539 HAL_NVIC_EnableIRQ(DCMI_IRQn); 00540 00541 /* NVIC configuration for DMA2D transfer complete interrupt */ 00542 HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0); 00543 HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn); 00544 00545 /* Configure the DMA stream */ 00546 HAL_DMA_Init(hdcmi->DMA_Handle); 00547 } 00548 00549 00550 /** 00551 * @brief DeInitializes the DCMI MSP. 00552 * @param hdcmi: HDMI handle 00553 * @param Params 00554 * @retval None 00555 */ 00556 __weak void BSP_CAMERA_MspDeInit(DCMI_HandleTypeDef *hdcmi, void *Params) 00557 { 00558 /* Disable NVIC for DCMI transfer complete interrupt */ 00559 HAL_NVIC_DisableIRQ(DCMI_IRQn); 00560 00561 /* Disable NVIC for DMA2 transfer complete interrupt */ 00562 HAL_NVIC_DisableIRQ(DMA2_Stream1_IRQn); 00563 00564 /* Configure the DMA stream */ 00565 HAL_DMA_DeInit(hdcmi->DMA_Handle); 00566 00567 /* Disable DCMI clock */ 00568 __HAL_RCC_DCMI_CLK_DISABLE(); 00569 00570 /* GPIO pins clock and DMA clock can be shut down in the application 00571 by surcharging this __weak function */ 00572 } 00573 00574 /** 00575 * @brief Line event callback 00576 * @param hdcmi: pointer to the DCMI handle 00577 * @retval None 00578 */ 00579 void HAL_DCMI_LineEventCallback(DCMI_HandleTypeDef *hdcmi) 00580 { 00581 BSP_CAMERA_LineEventCallback(); 00582 } 00583 00584 /** 00585 * @brief Line Event callback. 00586 * @retval None 00587 */ 00588 __weak void BSP_CAMERA_LineEventCallback(void) 00589 { 00590 /* NOTE : This function Should not be modified, when the callback is needed, 00591 the HAL_DCMI_LineEventCallback could be implemented in the user file 00592 */ 00593 } 00594 00595 /** 00596 * @brief VSYNC event callback 00597 * @param hdcmi: pointer to the DCMI handle 00598 * @retval None 00599 */ 00600 void HAL_DCMI_VsyncEventCallback(DCMI_HandleTypeDef *hdcmi) 00601 { 00602 BSP_CAMERA_VsyncEventCallback(); 00603 } 00604 00605 /** 00606 * @brief VSYNC Event callback. 00607 * @retval None 00608 */ 00609 __weak void BSP_CAMERA_VsyncEventCallback(void) 00610 { 00611 /* NOTE : This function Should not be modified, when the callback is needed, 00612 the HAL_DCMI_VsyncEventCallback could be implemented in the user file 00613 */ 00614 } 00615 00616 /** 00617 * @brief Frame event callback 00618 * @param hdcmi: pointer to the DCMI handle 00619 * @retval None 00620 */ 00621 void HAL_DCMI_FrameEventCallback(DCMI_HandleTypeDef *hdcmi) 00622 { 00623 BSP_CAMERA_FrameEventCallback(); 00624 } 00625 00626 /** 00627 * @brief Frame Event callback. 00628 * @retval None 00629 */ 00630 __weak void BSP_CAMERA_FrameEventCallback(void) 00631 { 00632 /* NOTE : This function Should not be modified, when the callback is needed, 00633 the HAL_DCMI_FrameEventCallback could be implemented in the user file 00634 */ 00635 } 00636 00637 /** 00638 * @brief Error callback 00639 * @param hdcmi: pointer to the DCMI handle 00640 * @retval None 00641 */ 00642 void HAL_DCMI_ErrorCallback(DCMI_HandleTypeDef *hdcmi) 00643 { 00644 BSP_CAMERA_ErrorCallback(); 00645 } 00646 00647 /** 00648 * @brief Error callback. 00649 * @retval None 00650 */ 00651 __weak void BSP_CAMERA_ErrorCallback(void) 00652 { 00653 /* NOTE : This function Should not be modified, when the callback is needed, 00654 the HAL_DCMI_ErrorCallback could be implemented in the user file 00655 */ 00656 } 00657 00658 /** 00659 * @} 00660 */ 00661 00662 /** 00663 * @} 00664 */ 00665 00666 /** 00667 * @} 00668 */ 00669 00670 /** 00671 * @} 00672 */ 00673 00674 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 18:43:04 by 1.7.2