kopia lustrzana https://github.com/alpov/SatCam
611 wiersze
18 KiB
C
611 wiersze
18 KiB
C
/**
|
|
******************************************************************************
|
|
* File Name : main.c
|
|
* Description : Main program body
|
|
******************************************************************************
|
|
*
|
|
* COPYRIGHT(c) 2019 STMicroelectronics
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
* are permitted provided that the following conditions are met:
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
* this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
* and/or other materials provided with the distribution.
|
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software
|
|
* without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "main.h"
|
|
#include "stm32f4xx_hal.h"
|
|
|
|
/* USER CODE BEGIN Includes */
|
|
#include "cube.h"
|
|
#include "eeprom.h"
|
|
|
|
/* USER CODE END Includes */
|
|
|
|
/* Private variables ---------------------------------------------------------*/
|
|
ADC_HandleTypeDef hadc1;
|
|
|
|
CRC_HandleTypeDef hcrc;
|
|
|
|
DAC_HandleTypeDef hdac;
|
|
DMA_HandleTypeDef hdma_dac2;
|
|
|
|
DCMI_HandleTypeDef hdcmi;
|
|
DMA_HandleTypeDef hdma_dcmi;
|
|
|
|
I2C_HandleTypeDef hi2c2;
|
|
|
|
IWDG_HandleTypeDef hiwdg;
|
|
|
|
TIM_HandleTypeDef htim6;
|
|
|
|
UART_HandleTypeDef huart2;
|
|
DMA_HandleTypeDef hdma_usart2_rx;
|
|
|
|
/* USER CODE BEGIN PV */
|
|
/* Private variables ---------------------------------------------------------*/
|
|
|
|
/* USER CODE END PV */
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
void SystemClock_Config(void);
|
|
void Error_Handler(void);
|
|
static void MX_GPIO_Init(void);
|
|
static void MX_DMA_Init(void);
|
|
static void MX_ADC1_Init(void);
|
|
static void MX_CRC_Init(void);
|
|
static void MX_DAC_Init(void);
|
|
static void MX_DCMI_Init(void);
|
|
static void MX_I2C2_Init(void);
|
|
static void MX_IWDG_Init(void);
|
|
static void MX_TIM6_Init(void);
|
|
static void MX_USART2_UART_Init(void);
|
|
|
|
/* USER CODE BEGIN PFP */
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
/* USER CODE END PFP */
|
|
|
|
/* USER CODE BEGIN 0 */
|
|
|
|
void enable_turbo(bool en)
|
|
{
|
|
RCC_OscInitTypeDef RCC_OscInitStruct;
|
|
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
|
|
|
if (en) {
|
|
/* enable HSE and PLL */
|
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
|
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
|
RCC_OscInitStruct.PLL.PLLM = 8;
|
|
RCC_OscInitStruct.PLL.PLLN = 160;
|
|
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
|
|
RCC_OscInitStruct.PLL.PLLQ = 2;
|
|
RCC_OscInitStruct.PLL.PLLR = 7;
|
|
HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
|
|
|
/* SYSCLK=80MHz, AHB=HCLK=80MHz, APB1=PCLK1=10MHz, APB2=PCLK2=10MHz, 2WS, prefetch enabled */
|
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV8;
|
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV8;
|
|
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
|
|
__HAL_FLASH_PREFETCH_BUFFER_ENABLE();
|
|
|
|
/* reconfigure dependent timers, clocks, rates */
|
|
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
|
|
huart2.Instance->BRR = UART_BRR_SAMPLING16(HAL_RCC_GetPCLK1Freq(), huart2.Init.BaudRate);
|
|
htim6.Instance->PSC = (20-1);
|
|
hi2c2.Instance->CR1 |= I2C_CR1_SWRST; // cycle SCCB master reset
|
|
hi2c2.Instance->CR1 &= ~I2C_CR1_SWRST;
|
|
MX_I2C2_Init();
|
|
eeprom_set_freq(HAL_RCC_GetHCLKFreq());
|
|
}
|
|
else {
|
|
/* SYSCLK=8MHz, AHB=HCLK=4MHz, APB1=PCLK1=4MHz, APB2=PCLK2=4MHz, 0WS, prefetch disabled */
|
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
|
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
|
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
|
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
|
|
__HAL_FLASH_PREFETCH_BUFFER_DISABLE();
|
|
|
|
/* reconfigure dependent timers, clocks, rates */
|
|
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
|
|
huart2.Instance->BRR = UART_BRR_SAMPLING16(HAL_RCC_GetPCLK1Freq(), huart2.Init.BaudRate);
|
|
htim6.Instance->PSC = (4-1);
|
|
HAL_I2C_DeInit(&hi2c2);
|
|
eeprom_set_freq(HAL_RCC_GetHCLKFreq());
|
|
|
|
/* keep HSE, disable PLL */
|
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_OFF;
|
|
HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
|
}
|
|
}
|
|
|
|
|
|
void HAL_Delay(__IO uint32_t Delay)
|
|
{
|
|
uint32_t tickstart = 0;
|
|
tickstart = HAL_GetTick();
|
|
while ((HAL_GetTick() - tickstart) < Delay) {
|
|
/* enter SLEEP mode for next 1ms at most */
|
|
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
|
|
}
|
|
}
|
|
|
|
|
|
/* USER CODE END 0 */
|
|
|
|
int main(void)
|
|
{
|
|
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE END 1 */
|
|
|
|
/* MCU Configuration----------------------------------------------------------*/
|
|
|
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
|
HAL_Init();
|
|
|
|
/* Configure the system clock */
|
|
SystemClock_Config();
|
|
|
|
/* Initialize all configured peripherals */
|
|
MX_GPIO_Init();
|
|
MX_DMA_Init();
|
|
MX_ADC1_Init();
|
|
MX_CRC_Init();
|
|
MX_DAC_Init();
|
|
MX_DCMI_Init();
|
|
MX_I2C2_Init();
|
|
MX_IWDG_Init();
|
|
MX_TIM6_Init();
|
|
MX_USART2_UART_Init();
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
enable_turbo(false);
|
|
main_satcam();
|
|
|
|
/* USER CODE END 2 */
|
|
|
|
/* Infinite loop */
|
|
/* USER CODE BEGIN WHILE */
|
|
while (1)
|
|
{
|
|
/* USER CODE END WHILE */
|
|
|
|
/* USER CODE BEGIN 3 */
|
|
|
|
}
|
|
/* USER CODE END 3 */
|
|
|
|
}
|
|
|
|
/** System Clock Configuration
|
|
*/
|
|
void SystemClock_Config(void)
|
|
{
|
|
|
|
RCC_OscInitTypeDef RCC_OscInitStruct;
|
|
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
|
|
|
/**Configure the main internal regulator output voltage
|
|
*/
|
|
__HAL_RCC_PWR_CLK_ENABLE();
|
|
|
|
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);
|
|
|
|
/**Initializes the CPU, AHB and APB busses clocks
|
|
*/
|
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
|
|
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
|
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
|
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
|
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
/**Initializes the CPU, AHB and APB busses clocks
|
|
*/
|
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
|
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
|
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
|
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
|
|
|
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
/**Configure the Systick interrupt time
|
|
*/
|
|
HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
|
|
|
|
/**Configure the Systick
|
|
*/
|
|
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
|
|
|
|
/* SysTick_IRQn interrupt configuration */
|
|
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
|
|
}
|
|
|
|
/* ADC1 init function */
|
|
static void MX_ADC1_Init(void)
|
|
{
|
|
|
|
ADC_ChannelConfTypeDef sConfig;
|
|
|
|
/**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
|
|
*/
|
|
hadc1.Instance = ADC1;
|
|
hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
|
|
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
|
|
hadc1.Init.ScanConvMode = DISABLE;
|
|
hadc1.Init.ContinuousConvMode = ENABLE;
|
|
hadc1.Init.DiscontinuousConvMode = DISABLE;
|
|
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
|
|
hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
|
|
hadc1.Init.NbrOfConversion = 1;
|
|
hadc1.Init.DMAContinuousRequests = DISABLE;
|
|
hadc1.Init.EOCSelection = ADC_EOC_SEQ_CONV;
|
|
if (HAL_ADC_Init(&hadc1) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
/**Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
|
|
*/
|
|
sConfig.Channel = ADC_CHANNEL_0;
|
|
sConfig.Rank = 1;
|
|
sConfig.SamplingTime = ADC_SAMPLETIME_144CYCLES;
|
|
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
}
|
|
|
|
/* CRC init function */
|
|
static void MX_CRC_Init(void)
|
|
{
|
|
|
|
hcrc.Instance = CRC;
|
|
if (HAL_CRC_Init(&hcrc) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
}
|
|
|
|
/* DAC init function */
|
|
static void MX_DAC_Init(void)
|
|
{
|
|
|
|
DAC_ChannelConfTypeDef sConfig;
|
|
|
|
/**DAC Initialization
|
|
*/
|
|
hdac.Instance = DAC;
|
|
if (HAL_DAC_Init(&hdac) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
/**DAC channel OUT2 config
|
|
*/
|
|
sConfig.DAC_Trigger = DAC_TRIGGER_T6_TRGO;
|
|
sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
|
|
if (HAL_DAC_ConfigChannel(&hdac, &sConfig, DAC_CHANNEL_2) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
}
|
|
|
|
/* DCMI init function */
|
|
static void MX_DCMI_Init(void)
|
|
{
|
|
|
|
hdcmi.Instance = DCMI;
|
|
hdcmi.Init.SynchroMode = DCMI_SYNCHRO_HARDWARE;
|
|
hdcmi.Init.PCKPolarity = DCMI_PCKPOLARITY_RISING;
|
|
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_ENABLE;
|
|
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();
|
|
}
|
|
|
|
}
|
|
|
|
/* I2C2 init function */
|
|
static void MX_I2C2_Init(void)
|
|
{
|
|
|
|
hi2c2.Instance = I2C2;
|
|
hi2c2.Init.ClockSpeed = 100000;
|
|
hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;
|
|
hi2c2.Init.OwnAddress1 = 0;
|
|
hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
|
|
hi2c2.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
|
|
hi2c2.Init.OwnAddress2 = 0;
|
|
hi2c2.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
|
|
hi2c2.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
|
|
if (HAL_I2C_Init(&hi2c2) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
}
|
|
|
|
/* IWDG init function */
|
|
static void MX_IWDG_Init(void)
|
|
{
|
|
|
|
hiwdg.Instance = IWDG;
|
|
hiwdg.Init.Prescaler = IWDG_PRESCALER_32;
|
|
hiwdg.Init.Reload = 2000;
|
|
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
}
|
|
|
|
/* TIM6 init function */
|
|
static void MX_TIM6_Init(void)
|
|
{
|
|
|
|
TIM_MasterConfigTypeDef sMasterConfig;
|
|
|
|
htim6.Instance = TIM6;
|
|
htim6.Init.Prescaler = 19;
|
|
htim6.Init.CounterMode = TIM_COUNTERMODE_UP;
|
|
htim6.Init.Period = 49;
|
|
if (HAL_TIM_Base_Init(&htim6) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_UPDATE;
|
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim6, &sMasterConfig) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
}
|
|
|
|
/* USART2 init function */
|
|
static void MX_USART2_UART_Init(void)
|
|
{
|
|
|
|
huart2.Instance = USART2;
|
|
huart2.Init.BaudRate = 9600;
|
|
huart2.Init.WordLength = UART_WORDLENGTH_8B;
|
|
huart2.Init.StopBits = UART_STOPBITS_1;
|
|
huart2.Init.Parity = UART_PARITY_NONE;
|
|
huart2.Init.Mode = UART_MODE_TX_RX;
|
|
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
|
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
|
|
if (HAL_UART_Init(&huart2) != HAL_OK)
|
|
{
|
|
Error_Handler();
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Enable DMA controller clock
|
|
*/
|
|
static void MX_DMA_Init(void)
|
|
{
|
|
/* DMA controller clock enable */
|
|
__HAL_RCC_DMA1_CLK_ENABLE();
|
|
__HAL_RCC_DMA2_CLK_ENABLE();
|
|
|
|
/* DMA interrupt init */
|
|
/* DMA1_Stream5_IRQn interrupt configuration */
|
|
HAL_NVIC_SetPriority(DMA1_Stream5_IRQn, 2, 0);
|
|
HAL_NVIC_EnableIRQ(DMA1_Stream5_IRQn);
|
|
/* DMA1_Stream6_IRQn interrupt configuration */
|
|
HAL_NVIC_SetPriority(DMA1_Stream6_IRQn, 1, 0);
|
|
HAL_NVIC_EnableIRQ(DMA1_Stream6_IRQn);
|
|
/* DMA2_Stream1_IRQn interrupt configuration */
|
|
HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 1, 0);
|
|
HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
|
|
|
|
}
|
|
|
|
/** Configure pins as
|
|
* Analog
|
|
* Input
|
|
* Output
|
|
* EVENT_OUT
|
|
* EXTI
|
|
* Free pins are configured automatically as Analog (this feature is enabled through
|
|
* the Code Generation settings)
|
|
*/
|
|
static void MX_GPIO_Init(void)
|
|
{
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct;
|
|
|
|
/* GPIO Ports Clock Enable */
|
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOC, EEP_SDA_Pin|EEP_SCL_Pin|GPIO_PTT_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOB, LED_R_Pin|LED_G_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOA, XCLK_Pin|CAM_RST_Pin|CAM_ENB_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pins : EEP_SDA_Pin EEP_SCL_Pin */
|
|
GPIO_InitStruct.Pin = EEP_SDA_Pin|EEP_SCL_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PC15 PC0 PC1 PC2
|
|
PC3 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_15|GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2
|
|
|GPIO_PIN_3;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : GPIO_START_Pin */
|
|
GPIO_InitStruct.Pin = GPIO_START_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIO_START_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PA7 PA9 PA10 PA12 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_12;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : GPIO_PTT_Pin */
|
|
GPIO_InitStruct.Pin = GPIO_PTT_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIO_PTT_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : GPIO_M0_Pin GPIO_M1_Pin */
|
|
GPIO_InitStruct.Pin = GPIO_M0_Pin|GPIO_M1_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : LED_R_Pin LED_G_Pin */
|
|
GPIO_InitStruct.Pin = LED_R_Pin|LED_G_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PB2 PB12 PB13 PB14
|
|
PB15 PB4 PB5 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14
|
|
|GPIO_PIN_15|GPIO_PIN_4|GPIO_PIN_5;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : XCLK_Pin */
|
|
GPIO_InitStruct.Pin = XCLK_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
HAL_GPIO_Init(XCLK_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : CAM_RST_Pin CAM_ENB_Pin */
|
|
GPIO_InitStruct.Pin = CAM_RST_Pin|CAM_ENB_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PD2 */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_2;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
|
|
|
}
|
|
|
|
/* USER CODE BEGIN 4 */
|
|
|
|
/* USER CODE END 4 */
|
|
|
|
/**
|
|
* @brief This function is executed in case of error occurrence.
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
void Error_Handler(void)
|
|
{
|
|
/* USER CODE BEGIN Error_Handler */
|
|
|
|
// just return - try to recover and continue
|
|
|
|
/* USER CODE END Error_Handler */
|
|
}
|
|
|
|
#ifdef USE_FULL_ASSERT
|
|
|
|
/**
|
|
* @brief Reports the name of the source file and the source line number
|
|
* where the assert_param error has occurred.
|
|
* @param file: pointer to the source file name
|
|
* @param line: assert_param error line source number
|
|
* @retval None
|
|
*/
|
|
void assert_failed(uint8_t* file, uint32_t line)
|
|
{
|
|
/* USER CODE BEGIN 6 */
|
|
/* User can add his own implementation to report the file name and line number,
|
|
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
|
/* USER CODE END 6 */
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/**
|
|
* @}
|
|
*/
|
|
|
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|