|
|
|
/* 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
|
|
|
|
PG14 ------> ETH_TXD1
|
|
|
|
PB8 ------> I2C1_SCL
|
|
|
|
PA15 ------> S_TIM2_CH1_ETR
|
|
|
|
PG13 ------> ETH_TXD0
|
|
|
|
PB9 ------> I2C1_SDA
|
|
|
|
PG11 ------> ETH_TX_EN
|
|
|
|
PI1 ------> SPI2_SCK
|
|
|
|
PI0 ------> S_TIM5_CH4
|
|
|
|
PH4 ------> I2C2_SCL
|
|
|
|
PH5 ------> I2C2_SDA
|
|
|
|
PF7 ------> ADC3_IN5
|
|
|
|
PF6 ------> ADC3_IN4
|
|
|
|
PF10 ------> ADC3_IN8
|
|
|
|
PF9 ------> ADC3_IN7
|
|
|
|
PF8 ------> ADC3_IN6
|
|
|
|
PC1 ------> ETH_MDC
|
|
|
|
PA1 ------> ETH_REF_CLK
|
|
|
|
PA0/WKUP ------> ADCx_IN0
|
|
|
|
PC4 ------> ETH_RXD0
|
|
|
|
PA2 ------> ETH_MDIO
|
|
|
|
PC5 ------> ETH_RXD1
|
|
|
|
PH6 ------> S_TIM12_CH1
|
|
|
|
PA7 ------> ETH_CRS_DV
|
|
|
|
PB14 ------> SPI2_MISO
|
|
|
|
PB15 ------> SPI2_MOSI
|
|
|
|
*/
|
|
|
|
void MX_GPIO_Init(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
|
|
|
|
|
|
/* GPIO Ports Clock Enable */
|
|
|
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOG_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOJ_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOK_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOI_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOF_CLK_ENABLE();
|
|
|
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
|
|
|
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
|
|
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET);
|
|
|
|
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
|
|
HAL_GPIO_WritePin(GPIOI, ARDUINO_D7_Pin|ARDUINO_D8_Pin, GPIO_PIN_RESET);
|
|
|
|
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
|
|
HAL_GPIO_WritePin(LCD_BL_CTRL_GPIO_Port, LCD_BL_CTRL_Pin, GPIO_PIN_SET);
|
|
|
|
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
|
|
HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET);
|
|
|
|
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
|
|
HAL_GPIO_WritePin(DCMI_PWR_EN_GPIO_Port, DCMI_PWR_EN_Pin, GPIO_PIN_RESET);
|
|
|
|
|
|
|
|
/*Configure GPIO pin Output Level */
|
|
|
|
HAL_GPIO_WritePin(GPIOG, ARDUINO_D4_Pin|ARDUINO_D2_Pin|EXT_RST_Pin, GPIO_PIN_RESET);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = OTG_HS_OverCurrent_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(OTG_HS_OverCurrent_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = USER_BTN_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
|
|
HAL_GPIO_Init(USER_BTN_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PGPin PGPin PGPin */
|
|
|
|
GPIO_InitStruct.Pin = RMII_TXD1_Pin|RMII_TXD0_Pin|RMII_TX_EN_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
|
|
|
|
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PBPin PBPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_SCL_D15_Pin|ARDUINO_SDA_D14_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;
|
|
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_PWM_D9_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
|
|
|
|
HAL_GPIO_Init(ARDUINO_PWM_D9_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = OTG_FS_VBUS_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(OTG_FS_VBUS_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = Audio_INT_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_EVT_RISING;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
HAL_GPIO_Init(OTG_FS_PowerSwitchOn_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PIPin PIPin PIPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_D7_Pin|ARDUINO_D8_Pin|LCD_DISP_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = SD_CARD_N_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(SD_CARD_N_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = LCD_BL_CTRL_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
HAL_GPIO_Init(LCD_BL_CTRL_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = OTG_FS_OverCurrent_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PHPin PHPin */
|
|
|
|
GPIO_InitStruct.Pin = TP3_Pin|NC2_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_SCK_D13_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
|
|
|
HAL_GPIO_Init(ARDUINO_SCK_D13_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = DCMI_PWR_EN_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
HAL_GPIO_Init(DCMI_PWR_EN_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_PWM_CS_D5_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
|
|
|
|
HAL_GPIO_Init(ARDUINO_PWM_CS_D5_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = LCD_INT_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
|
|
|
HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PH4 PH5 */
|
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF4_I2C2;
|
|
|
|
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PGPin PGPin PGPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_D4_Pin|ARDUINO_D2_Pin|EXT_RST_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PGPin PGPin PGPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_PWM_D3_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
HAL_GPIO_Init(ARDUINO_PWM_D3_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PFPin PFPin PFPin PFPin
|
|
|
|
PFPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_A4_Pin|ARDUINO_A5_Pin|ARDUINO_A1_Pin|ARDUINO_A2_Pin
|
|
|
|
|ARDUINO_A3_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PCPin PCPin PCPin */
|
|
|
|
GPIO_InitStruct.Pin = RMII_MDC_Pin|RMII_RXD0_Pin|RMII_RXD1_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
|
|
|
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = RMII_RXER_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(RMII_RXER_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PAPin PAPin PAPin */
|
|
|
|
GPIO_InitStruct.Pin = RMII_REF_CLK_Pin|RMII_MDIO_Pin|RMII_CRS_DV_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
|
|
|
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_A0_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
HAL_GPIO_Init(ARDUINO_A0_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pin : PtPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_PWM_D6_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF9_TIM12;
|
|
|
|
HAL_GPIO_Init(ARDUINO_PWM_D6_GPIO_Port, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
/*Configure GPIO pins : PBPin PBPin */
|
|
|
|
GPIO_InitStruct.Pin = ARDUINO_MISO_D12_Pin|ARDUINO_MOSI_PWM_D11_Pin;
|
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
|
|
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
|
|
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* USER CODE BEGIN 2 */
|
|
|
|
|
|
|
|
/* USER CODE END 2 */
|