| 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) 2025 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 | */
|
|---|
| 42 | void MX_GPIO_Init(void)
|
|---|
| 43 | {
|
|---|
| 44 |
|
|---|
| 45 | GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|---|
| 46 |
|
|---|
| 47 | /* GPIO Ports Clock Enable */
|
|---|
| 48 | __HAL_RCC_GPIOB_CLK_ENABLE();
|
|---|
| 49 | __HAL_RCC_GPIOC_CLK_ENABLE();
|
|---|
| 50 | __HAL_RCC_GPIOA_CLK_ENABLE();
|
|---|
| 51 |
|
|---|
| 52 | /*Configure GPIO pin Output Level */
|
|---|
| 53 | HAL_GPIO_WritePin(GPIOC, GPIO_OUTPUT_LED_ON_Pin|GPIO_OUTPUT_LED_ERROR_Pin, GPIO_PIN_RESET);
|
|---|
| 54 |
|
|---|
| 55 | /*Configure GPIO pin Output Level */
|
|---|
| 56 | HAL_GPIO_WritePin(GPIO_OUTPUT_10V_EN_GPIO_Port, GPIO_OUTPUT_10V_EN_Pin, GPIO_PIN_RESET);
|
|---|
| 57 |
|
|---|
| 58 | /*Configure GPIO pin Output Level */
|
|---|
| 59 | HAL_GPIO_WritePin(GPIOB, GPIO_OUTPUT_RELAIS_SET_Pin|GPIO_OUTPUT_RELAIS_RESET_Pin|GPIO_OUTPUT_BUZZER_Pin, GPIO_PIN_RESET);
|
|---|
| 60 |
|
|---|
| 61 | /*Configure GPIO pins : GPIO_INPUT_MODE_B3_Pin GPIO_INPUT_BTN_ON_Pin GPIO_INPUT_BTN_OFF_Pin GPIO_INPUT_FAULT_Pin
|
|---|
| 62 | GPIO_INPUT_MODE_B0_Pin GPIO_INPUT_MODE_B1_Pin GPIO_INPUT_MODE_B2_Pin */
|
|---|
| 63 | GPIO_InitStruct.Pin = GPIO_INPUT_MODE_B3_Pin|GPIO_INPUT_BTN_ON_Pin|GPIO_INPUT_BTN_OFF_Pin|GPIO_INPUT_FAULT_Pin
|
|---|
| 64 | |GPIO_INPUT_MODE_B0_Pin|GPIO_INPUT_MODE_B1_Pin|GPIO_INPUT_MODE_B2_Pin;
|
|---|
| 65 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|---|
| 66 | GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|---|
| 67 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|---|
| 68 |
|
|---|
| 69 | /*Configure GPIO pins : GPIO_OUTPUT_LED_ON_Pin GPIO_OUTPUT_LED_ERROR_Pin */
|
|---|
| 70 | GPIO_InitStruct.Pin = GPIO_OUTPUT_LED_ON_Pin|GPIO_OUTPUT_LED_ERROR_Pin;
|
|---|
| 71 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|---|
| 72 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|---|
| 73 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|---|
| 74 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|---|
| 75 |
|
|---|
| 76 | /*Configure GPIO pins : GPIO_INPUT_LVP_Pin GPIO_INPUT_OVP_Pin */
|
|---|
| 77 | GPIO_InitStruct.Pin = GPIO_INPUT_LVP_Pin|GPIO_INPUT_OVP_Pin;
|
|---|
| 78 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|---|
| 79 | GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|---|
| 80 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|---|
| 81 |
|
|---|
| 82 | /*Configure GPIO pin : GPIO_OUTPUT_10V_EN_Pin */
|
|---|
| 83 | GPIO_InitStruct.Pin = GPIO_OUTPUT_10V_EN_Pin;
|
|---|
| 84 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|---|
| 85 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|---|
| 86 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|---|
| 87 | HAL_GPIO_Init(GPIO_OUTPUT_10V_EN_GPIO_Port, &GPIO_InitStruct);
|
|---|
| 88 |
|
|---|
| 89 | /*Configure GPIO pin : GPIO_INPUT_BMS_Pin */
|
|---|
| 90 | GPIO_InitStruct.Pin = GPIO_INPUT_BMS_Pin;
|
|---|
| 91 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|---|
| 92 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|---|
| 93 | HAL_GPIO_Init(GPIO_INPUT_BMS_GPIO_Port, &GPIO_InitStruct);
|
|---|
| 94 |
|
|---|
| 95 | /*Configure GPIO pins : R1_Pin R2_Pin */
|
|---|
| 96 | GPIO_InitStruct.Pin = R1_Pin|R2_Pin;
|
|---|
| 97 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|---|
| 98 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|---|
| 99 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|---|
| 100 |
|
|---|
| 101 | /*Configure GPIO pins : GPIO_OUTPUT_RELAIS_SET_Pin GPIO_OUTPUT_RELAIS_RESET_Pin GPIO_OUTPUT_BUZZER_Pin */
|
|---|
| 102 | GPIO_InitStruct.Pin = GPIO_OUTPUT_RELAIS_SET_Pin|GPIO_OUTPUT_RELAIS_RESET_Pin|GPIO_OUTPUT_BUZZER_Pin;
|
|---|
| 103 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|---|
| 104 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|---|
| 105 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|---|
| 106 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|---|
| 107 |
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | /* USER CODE BEGIN 2 */
|
|---|
| 111 |
|
|---|
| 112 | /* USER CODE END 2 */
|
|---|