source: trunk/firmware_v2/Core/Src/gpio.c

Last change on this file was 17, checked in by f.jahn, 10 days ago
File size: 3.8 KB
Line 
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*/
42void 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(GPIOB, GPIO_OUTPUT_RELAIS_SET_Pin|GPIO_OUTPUT_RELAIS_RESET_Pin|GPIO_OUTPUT_BUZZER_Pin, GPIO_PIN_RESET);
57
58  /*Configure GPIO pins : GPIO_INPUT_MODE_B3_Pin GPIO_INPUT_BTN_ON_Pin GPIO_INPUT_BTN_OFF_Pin GPIO_INPUT_FAULT_Pin
59                           GPIO_INPUT_MODE_B0_Pin GPIO_INPUT_MODE_B1_Pin GPIO_INPUT_MODE_B2_Pin */
60  GPIO_InitStruct.Pin = GPIO_INPUT_MODE_B3_Pin|GPIO_INPUT_BTN_ON_Pin|GPIO_INPUT_BTN_OFF_Pin|GPIO_INPUT_FAULT_Pin
61                          |GPIO_INPUT_MODE_B0_Pin|GPIO_INPUT_MODE_B1_Pin|GPIO_INPUT_MODE_B2_Pin;
62  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
63  GPIO_InitStruct.Pull = GPIO_PULLUP;
64  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
65
66  /*Configure GPIO pins : GPIO_OUTPUT_LED_ON_Pin GPIO_OUTPUT_LED_ERROR_Pin */
67  GPIO_InitStruct.Pin = GPIO_OUTPUT_LED_ON_Pin|GPIO_OUTPUT_LED_ERROR_Pin;
68  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
69  GPIO_InitStruct.Pull = GPIO_NOPULL;
70  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
71  HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
72
73  /*Configure GPIO pins : GPIO_INPUT_LVP_Pin GPIO_INPUT_OVP_Pin */
74  GPIO_InitStruct.Pin = GPIO_INPUT_LVP_Pin|GPIO_INPUT_OVP_Pin;
75  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
76  GPIO_InitStruct.Pull = GPIO_PULLUP;
77  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
78
79  /*Configure GPIO pin : GPIO_INPUT_BMS_Pin */
80  GPIO_InitStruct.Pin = GPIO_INPUT_BMS_Pin;
81  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
82  GPIO_InitStruct.Pull = GPIO_NOPULL;
83  HAL_GPIO_Init(GPIO_INPUT_BMS_GPIO_Port, &GPIO_InitStruct);
84
85  /*Configure GPIO pins : R1_Pin R2_Pin */
86  GPIO_InitStruct.Pin = R1_Pin|R2_Pin;
87  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
88  GPIO_InitStruct.Pull = GPIO_NOPULL;
89  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
90
91  /*Configure GPIO pins : GPIO_OUTPUT_RELAIS_SET_Pin GPIO_OUTPUT_RELAIS_RESET_Pin GPIO_OUTPUT_BUZZER_Pin */
92  GPIO_InitStruct.Pin = GPIO_OUTPUT_RELAIS_SET_Pin|GPIO_OUTPUT_RELAIS_RESET_Pin|GPIO_OUTPUT_BUZZER_Pin;
93  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
94  GPIO_InitStruct.Pull = GPIO_NOPULL;
95  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
96  HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
97
98}
99
100/* USER CODE BEGIN 2 */
101
102/* USER CODE END 2 */
Note: See TracBrowser for help on using the repository browser.