197 lines
7.2 KiB
C
197 lines
7.2 KiB
C
/* USER CODE BEGIN Header */
|
|
/**
|
|
******************************************************************************
|
|
* @file gpio.c
|
|
* @brief This file provides code for the configuration
|
|
* of all used GPIO pins.
|
|
******************************************************************************
|
|
* @attention
|
|
*
|
|
* Copyright (c) 2022 STMicroelectronics.
|
|
* All rights reserved.
|
|
*
|
|
* This software is licensed under terms that can be found in the LICENSE file
|
|
* in the root directory of this software component.
|
|
* If no LICENSE file comes with this software, it is provided AS-IS.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "gpio.h"
|
|
|
|
/* USER CODE BEGIN 0 */
|
|
|
|
/* USER CODE END 0 */
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Configure GPIO */
|
|
/*----------------------------------------------------------------------------*/
|
|
/* USER CODE BEGIN 1 */
|
|
|
|
/* USER CODE END 1 */
|
|
|
|
/** Configure pins as
|
|
* Analog
|
|
* Input
|
|
* Output
|
|
* EVENT_OUT
|
|
* EXTI
|
|
*/
|
|
void MX_GPIO_Init(void)
|
|
{
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
/* GPIO Ports Clock Enable */
|
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
|
__HAL_RCC_GPIOC_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(GPIOE, FSMC_A15_Pin|FSMC_A11_Pin|FSMC_A12_Pin|FSMC_A13_Pin
|
|
|FSMC_A14_Pin|FSMC_D4_Pin|FSMC_D5_Pin|FSMC_D6_Pin
|
|
|FSMC_D7_Pin|FSMC_A0_Pin|FSMC_A1_Pin|FSMC_A2_Pin
|
|
|FSMC_A3_Pin|FSMC_A4_Pin, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(SPI_ENC_CS_GPIO_Port, SPI_ENC_CS_Pin, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOD, FSMC_A5_Pin|FSMC_A6_Pin|FSMC_A7_Pin|FSMC_A8_Pin
|
|
|FSMC_A9_Pin|FSMC_A10_Pin|FSMC_D0_Pin|FSMC_D2_Pin
|
|
|FSMC_D3_Pin|FSMC_NOE_Pin|FSMC_NWE_Pin|FSMC_NE1_Pin, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(FSMC_D1_GPIO_Port, FSMC_D1_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_8|GND2_SW_Pin|GND1_SW_Pin, GPIO_PIN_RESET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(GPIOA, FPGA_CRESET_Pin|SPI_FPGA_CS_Pin, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
HAL_GPIO_WritePin(EEM_POWER_SW_GPIO_Port, EEM_POWER_SW_Pin, GPIO_PIN_SET);
|
|
|
|
/*Configure GPIO pins : PEPin PEPin PEPin PEPin
|
|
PEPin PEPin PEPin PEPin
|
|
PEPin PEPin PEPin PEPin
|
|
PEPin PEPin */
|
|
GPIO_InitStruct.Pin = FSMC_A15_Pin|FSMC_A11_Pin|FSMC_A12_Pin|FSMC_A13_Pin
|
|
|FSMC_A14_Pin|FSMC_D4_Pin|FSMC_D5_Pin|FSMC_D6_Pin
|
|
|FSMC_D7_Pin|FSMC_A0_Pin|FSMC_A1_Pin|FSMC_A2_Pin
|
|
|FSMC_A3_Pin|FSMC_A4_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
GPIO_InitStruct.Pin = SPI_ENC_CS_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
HAL_GPIO_Init(SPI_ENC_CS_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
GPIO_InitStruct.Pin = LED_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(LED_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PCPin PCPin PCPin PCPin
|
|
PCPin */
|
|
GPIO_InitStruct.Pin = KEY_Pin|SW4_Pin|SW5_Pin|SW1_Pin
|
|
|SW2_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
GPIO_InitStruct.Pin = EEM_POWER_FAULT_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
HAL_GPIO_Init(EEM_POWER_FAULT_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
GPIO_InitStruct.Pin = SW3_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
HAL_GPIO_Init(SW3_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PDPin PDPin PDPin PDPin
|
|
PDPin PDPin PDPin PDPin
|
|
PDPin PDPin PDPin PDPin */
|
|
GPIO_InitStruct.Pin = FSMC_A5_Pin|FSMC_A6_Pin|FSMC_A7_Pin|FSMC_A8_Pin
|
|
|FSMC_A9_Pin|FSMC_A10_Pin|FSMC_D0_Pin|FSMC_D2_Pin
|
|
|FSMC_D3_Pin|FSMC_NOE_Pin|FSMC_NWE_Pin|FSMC_NE1_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
GPIO_InitStruct.Pin = FSMC_D1_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(FSMC_D1_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PA8 PAPin PAPin */
|
|
GPIO_InitStruct.Pin = GPIO_PIN_8|GND2_SW_Pin|GND1_SW_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 : PtPin */
|
|
GPIO_InitStruct.Pin = FPGA_CDONE_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
HAL_GPIO_Init(FPGA_CDONE_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
GPIO_InitStruct.Pin = FPGA_CRESET_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
HAL_GPIO_Init(FPGA_CRESET_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
GPIO_InitStruct.Pin = SPI_FPGA_CS_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
|
HAL_GPIO_Init(SPI_FPGA_CS_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pins : PDPin PDPin */
|
|
GPIO_InitStruct.Pin = FSMC_CLK_Pin|FSMC_NWAIT_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
GPIO_InitStruct.Pin = EEM_POWER_SW_Pin;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(EEM_POWER_SW_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
/* EXTI interrupt init*/
|
|
HAL_NVIC_SetPriority(EXTI2_IRQn, 0, 0);
|
|
HAL_NVIC_EnableIRQ(EXTI2_IRQn);
|
|
|
|
}
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
/* USER CODE END 2 */
|