| 1 | /* USER CODE BEGIN Header */ |
|---|
| 2 | /** |
|---|
| 3 | ****************************************************************************** |
|---|
| 4 | * @file gpio.c |
|---|
| 5 | * @brief This file provides code for the configuration |
|---|
| 6 | * of all used GPIO pins. |
|---|
| 7 | ****************************************************************************** |
|---|
| 8 | * @attention |
|---|
| 9 | * |
|---|
| 10 | * Copyright (c) 2024 STMicroelectronics. |
|---|
| 11 | * All rights reserved. |
|---|
| 12 | * |
|---|
| 13 | * This software is licensed under terms that can be found in the LICENSE file |
|---|
| 14 | * in the root directory of this software component. |
|---|
| 15 | * If no LICENSE file comes with this software, it is provided AS-IS. |
|---|
| 16 | * |
|---|
| 17 | ****************************************************************************** |
|---|
| 18 | */ |
|---|
| 19 | /* USER CODE END Header */ |
|---|
| 20 | |
|---|
| 21 | /* Includes ------------------------------------------------------------------*/ |
|---|
| 22 | #include "gpio.h" |
|---|
| 23 | |
|---|
| 24 | /* USER CODE BEGIN 0 */ |
|---|
| 25 | |
|---|
| 26 | /* USER CODE END 0 */ |
|---|
| 27 | |
|---|
| 28 | /*----------------------------------------------------------------------------*/ |
|---|
| 29 | /* Configure GPIO */ |
|---|
| 30 | /*----------------------------------------------------------------------------*/ |
|---|
| 31 | /* USER CODE BEGIN 1 */ |
|---|
| 32 | |
|---|
| 33 | /* USER CODE END 1 */ |
|---|
| 34 | |
|---|
| 35 | /** Configure pins as |
|---|
| 36 | * Analog |
|---|
| 37 | * Input |
|---|
| 38 | * Output |
|---|
| 39 | * EVENT_OUT |
|---|
| 40 | * EXTI |
|---|
| 41 | * Free pins are configured automatically as Analog (this feature is enabled through |
|---|
| 42 | * the Code Generation settings) |
|---|
| 43 | */ |
|---|
| 44 | void MX_GPIO_Init(void) |
|---|
| 45 | { |
|---|
| 46 | |
|---|
| 47 | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
|---|
| 48 | |
|---|
| 49 | /* GPIO Ports Clock Enable */ |
|---|
| 50 | __HAL_RCC_GPIOE_CLK_ENABLE(); |
|---|
| 51 | __HAL_RCC_GPIOC_CLK_ENABLE(); |
|---|
| 52 | __HAL_RCC_GPIOF_CLK_ENABLE(); |
|---|
| 53 | __HAL_RCC_GPIOH_CLK_ENABLE(); |
|---|
| 54 | __HAL_RCC_GPIOA_CLK_ENABLE(); |
|---|
| 55 | __HAL_RCC_GPIOB_CLK_ENABLE(); |
|---|
| 56 | __HAL_RCC_GPIOG_CLK_ENABLE(); |
|---|
| 57 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
|---|
| 58 | |
|---|
| 59 | /*Configure GPIO pin Output Level */ |
|---|
| 60 | HAL_GPIO_WritePin(GPIOE, TX1_LED_Pin|POWER_15V_EN_Pin|RST_DISPLAY_Pin, GPIO_PIN_RESET); |
|---|
| 61 | |
|---|
| 62 | /*Configure GPIO pin Output Level */ |
|---|
| 63 | HAL_GPIO_WritePin(GPIOB, U_BAT_SCALE_SWITCH_Pin|ETH_SPI_RST_Pin, GPIO_PIN_RESET); |
|---|
| 64 | |
|---|
| 65 | /*Configure GPIO pin Output Level */ |
|---|
| 66 | HAL_GPIO_WritePin(POWER_4V_EN_GPIO_Port, POWER_4V_EN_Pin, GPIO_PIN_RESET); |
|---|
| 67 | |
|---|
| 68 | /*Configure GPIO pin Output Level */ |
|---|
| 69 | HAL_GPIO_WritePin(GPIOG, POWER_5V_EN_Pin|POWER_10V_EN_Pin|ERROR_LED_Pin|CHARGE_LED_Pin |
|---|
| 70 | |RX2_LED_Pin|RX1_LED_Pin|TX2_LED_Pin|BUZZER_Pin, GPIO_PIN_RESET); |
|---|
| 71 | |
|---|
| 72 | /*Configure GPIO pin Output Level */ |
|---|
| 73 | HAL_GPIO_WritePin(GPIOD, GSM_PWR_Pin|OUTPUT_ON_LED_Pin, GPIO_PIN_RESET); |
|---|
| 74 | |
|---|
| 75 | /*Configure GPIO pin Output Level */ |
|---|
| 76 | HAL_GPIO_WritePin(ONEWIRE_TEMP_BUS_GPIO_Port, ONEWIRE_TEMP_BUS_Pin, GPIO_PIN_RESET); |
|---|
| 77 | |
|---|
| 78 | /*Configure GPIO pin Output Level */ |
|---|
| 79 | HAL_GPIO_WritePin(ETH_SPI_PWR_GPIO_Port, ETH_SPI_PWR_Pin, GPIO_PIN_SET); |
|---|
| 80 | |
|---|
| 81 | /*Configure GPIO pin Output Level */ |
|---|
| 82 | HAL_GPIO_WritePin(ETH_SPI_NSS_GPIO_Port, ETH_SPI_NSS_Pin, GPIO_PIN_SET); |
|---|
| 83 | |
|---|
| 84 | /*Configure GPIO pins : PE4 PE5 PE10 PE0 |
|---|
| 85 | PE1 */ |
|---|
| 86 | GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_10|GPIO_PIN_0 |
|---|
| 87 | |GPIO_PIN_1; |
|---|
| 88 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
|---|
| 89 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 90 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); |
|---|
| 91 | |
|---|
| 92 | /*Configure GPIO pins : TX1_LED_Pin POWER_15V_EN_Pin RST_DISPLAY_Pin */ |
|---|
| 93 | GPIO_InitStruct.Pin = TX1_LED_Pin|POWER_15V_EN_Pin|RST_DISPLAY_Pin; |
|---|
| 94 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
|---|
| 95 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 96 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|---|
| 97 | HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); |
|---|
| 98 | |
|---|
| 99 | /*Configure GPIO pins : PC13 PC1 PC2 PC3 */ |
|---|
| 100 | GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3; |
|---|
| 101 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
|---|
| 102 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 103 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
|---|
| 104 | |
|---|
| 105 | /*Configure GPIO pins : PF2 PF3 PF4 PF5 |
|---|
| 106 | PF6 PF7 PF8 PF9 |
|---|
| 107 | PF10 PF11 PF12 PF13 |
|---|
| 108 | PF14 */ |
|---|
| 109 | GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 |
|---|
| 110 | |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9 |
|---|
| 111 | |GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13 |
|---|
| 112 | |GPIO_PIN_14; |
|---|
| 113 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
|---|
| 114 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 115 | HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); |
|---|
| 116 | |
|---|
| 117 | /*Configure GPIO pins : PA0 PA1 PA2 PA3 |
|---|
| 118 | PA9 PA10 PA11 PA12 */ |
|---|
| 119 | GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 |
|---|
| 120 | |GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12; |
|---|
| 121 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
|---|
| 122 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 123 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
|---|
| 124 | |
|---|
| 125 | /*Configure GPIO pins : U_BAT_SCALE_SWITCH_Pin ETH_SPI_NSS_Pin ETH_SPI_RST_Pin */ |
|---|
| 126 | GPIO_InitStruct.Pin = U_BAT_SCALE_SWITCH_Pin|ETH_SPI_NSS_Pin|ETH_SPI_RST_Pin; |
|---|
| 127 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
|---|
| 128 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 129 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|---|
| 130 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
|---|
| 131 | |
|---|
| 132 | /*Configure GPIO pin : POWER_4V_EN_Pin */ |
|---|
| 133 | GPIO_InitStruct.Pin = POWER_4V_EN_Pin; |
|---|
| 134 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
|---|
| 135 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 136 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|---|
| 137 | HAL_GPIO_Init(POWER_4V_EN_GPIO_Port, &GPIO_InitStruct); |
|---|
| 138 | |
|---|
| 139 | /*Configure GPIO pins : POWER_5V_EN_Pin POWER_10V_EN_Pin ERROR_LED_Pin CHARGE_LED_Pin |
|---|
| 140 | RX2_LED_Pin RX1_LED_Pin TX2_LED_Pin BUZZER_Pin */ |
|---|
| 141 | GPIO_InitStruct.Pin = POWER_5V_EN_Pin|POWER_10V_EN_Pin|ERROR_LED_Pin|CHARGE_LED_Pin |
|---|
| 142 | |RX2_LED_Pin|RX1_LED_Pin|TX2_LED_Pin|BUZZER_Pin; |
|---|
| 143 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
|---|
| 144 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 145 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|---|
| 146 | HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); |
|---|
| 147 | |
|---|
| 148 | /*Configure GPIO pins : PB11 PB12 PB13 PB3 |
|---|
| 149 | PB5 */ |
|---|
| 150 | GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_3 |
|---|
| 151 | |GPIO_PIN_5; |
|---|
| 152 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
|---|
| 153 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 154 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
|---|
| 155 | |
|---|
| 156 | /*Configure GPIO pins : GSM_PWR_Pin ETH_SPI_PWR_Pin OUTPUT_ON_LED_Pin */ |
|---|
| 157 | GPIO_InitStruct.Pin = GSM_PWR_Pin|ETH_SPI_PWR_Pin|OUTPUT_ON_LED_Pin; |
|---|
| 158 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
|---|
| 159 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 160 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|---|
| 161 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); |
|---|
| 162 | |
|---|
| 163 | /*Configure GPIO pin : GSM_STATUS_Pin */ |
|---|
| 164 | GPIO_InitStruct.Pin = GSM_STATUS_Pin; |
|---|
| 165 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
|---|
| 166 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 167 | HAL_GPIO_Init(GSM_STATUS_GPIO_Port, &GPIO_InitStruct); |
|---|
| 168 | |
|---|
| 169 | /*Configure GPIO pins : PD14 PD15 */ |
|---|
| 170 | GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; |
|---|
| 171 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
|---|
| 172 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 173 | HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); |
|---|
| 174 | |
|---|
| 175 | /*Configure GPIO pins : PG2 PG3 PG4 PG5 |
|---|
| 176 | PG6 PG7 PG8 */ |
|---|
| 177 | GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 |
|---|
| 178 | |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8; |
|---|
| 179 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
|---|
| 180 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 181 | HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); |
|---|
| 182 | |
|---|
| 183 | /*Configure GPIO pin : SD_DETECT_Pin */ |
|---|
| 184 | GPIO_InitStruct.Pin = SD_DETECT_Pin; |
|---|
| 185 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
|---|
| 186 | GPIO_InitStruct.Pull = GPIO_PULLUP; |
|---|
| 187 | HAL_GPIO_Init(SD_DETECT_GPIO_Port, &GPIO_InitStruct); |
|---|
| 188 | |
|---|
| 189 | /*Configure GPIO pin : ONEWIRE_TEMP_BUS_Pin */ |
|---|
| 190 | GPIO_InitStruct.Pin = ONEWIRE_TEMP_BUS_Pin; |
|---|
| 191 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; |
|---|
| 192 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 193 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
|---|
| 194 | HAL_GPIO_Init(ONEWIRE_TEMP_BUS_GPIO_Port, &GPIO_InitStruct); |
|---|
| 195 | |
|---|
| 196 | /*Configure GPIO pin : ETH_SPI_INT_Pin */ |
|---|
| 197 | GPIO_InitStruct.Pin = ETH_SPI_INT_Pin; |
|---|
| 198 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; |
|---|
| 199 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
|---|
| 200 | HAL_GPIO_Init(ETH_SPI_INT_GPIO_Port, &GPIO_InitStruct); |
|---|
| 201 | |
|---|
| 202 | /* EXTI interrupt init*/ |
|---|
| 203 | HAL_NVIC_SetPriority(EXTI9_5_IRQn, 5, 0); |
|---|
| 204 | HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); |
|---|
| 205 | |
|---|
| 206 | } |
|---|
| 207 | |
|---|
| 208 | /* USER CODE BEGIN 2 */ |
|---|
| 209 | |
|---|
| 210 | /* USER CODE END 2 */ |
|---|