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