/** ****************************************************************************** * @file dcmi.c * @brief This file provides code for the configuration * of the DCMI instances. ****************************************************************************** * @attention * *

© Copyright (c) 2021 STMicroelectronics. * All rights reserved.

* * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "dcmi.h" /* USER CODE BEGIN 0 */ /* USER CODE END 0 */ DCMI_HandleTypeDef hdcmi; /* DCMI init function */ void MX_DCMI_Init(void) { /* USER CODE BEGIN DCMI_Init 0 */ /* USER CODE END DCMI_Init 0 */ /* USER CODE BEGIN DCMI_Init 1 */ /* USER CODE END DCMI_Init 1 */ hdcmi.Instance = DCMI; hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE; hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_FALLING; hdcmi.Init.VSPolarity = DCMI_VSPOLARITY_LOW; hdcmi.Init.HSPolarity = DCMI_HSPOLARITY_LOW; hdcmi.Init.CaptureRate = DCMI_CR_ALL_FRAME; hdcmi.Init.ExtendedDataMode = DCMI_EXTEND_DATA_8B; hdcmi.Init.JPEGMode = DCMI_JPEG_DISABLE; hdcmi.Init.ByteSelectMode = DCMI_BSM_ALL; hdcmi.Init.ByteSelectStart = DCMI_OEBS_ODD; hdcmi.Init.LineSelectMode = DCMI_LSM_ALL; hdcmi.Init.LineSelectStart = DCMI_OELS_ODD; if (HAL_DCMI_Init(&hdcmi) != HAL_OK) { Error_Handler(); } /* USER CODE BEGIN DCMI_Init 2 */ /* USER CODE END DCMI_Init 2 */ } void HAL_DCMI_MspInit(DCMI_HandleTypeDef* dcmiHandle) { GPIO_InitTypeDef GPIO_InitStruct = {0}; if(dcmiHandle->Instance==DCMI) { /* USER CODE BEGIN DCMI_MspInit 0 */ /* USER CODE END DCMI_MspInit 0 */ /* DCMI clock enable */ __HAL_RCC_DCMI_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOC_CLK_ENABLE(); __HAL_RCC_GPIOA_CLK_ENABLE(); /**DCMI GPIO Configuration PG10 ------> DCMI_D2 PB6 ------> DCMI_D5 PG11 ------> DCMI_D3 PB7 ------> DCMI_VSYNC PE5 ------> DCMI_D6 PE4 ------> DCMI_D4 PE6 ------> DCMI_D7 PC7 ------> DCMI_D1 PC6 ------> DCMI_D0 PA6 ------> DCMI_PIXCLK PA4 ------> DCMI_HSYNC */ GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_6; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_4; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Alternate = GPIO_AF13_DCMI; HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USER CODE BEGIN DCMI_MspInit 1 */ /* USER CODE END DCMI_MspInit 1 */ } } void HAL_DCMI_MspDeInit(DCMI_HandleTypeDef* dcmiHandle) { if(dcmiHandle->Instance==DCMI) { /* USER CODE BEGIN DCMI_MspDeInit 0 */ /* USER CODE END DCMI_MspDeInit 0 */ /* Peripheral clock disable */ __HAL_RCC_DCMI_CLK_DISABLE(); /**DCMI GPIO Configuration PG10 ------> DCMI_D2 PB6 ------> DCMI_D5 PG11 ------> DCMI_D3 PB7 ------> DCMI_VSYNC PE5 ------> DCMI_D6 PE4 ------> DCMI_D4 PE6 ------> DCMI_D7 PC7 ------> DCMI_D1 PC6 ------> DCMI_D0 PA6 ------> DCMI_PIXCLK PA4 ------> DCMI_HSYNC */ HAL_GPIO_DeInit(GPIOG, GPIO_PIN_10|GPIO_PIN_11); HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7); HAL_GPIO_DeInit(GPIOE, GPIO_PIN_5|GPIO_PIN_4|GPIO_PIN_6); HAL_GPIO_DeInit(GPIOC, GPIO_PIN_7|GPIO_PIN_6); HAL_GPIO_DeInit(GPIOA, GPIO_PIN_6|GPIO_PIN_4); /* USER CODE BEGIN DCMI_MspDeInit 1 */ /* USER CODE END DCMI_MspDeInit 1 */ } } /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/