| 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 | #include "ads1260.h"
|
|---|
| 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_GPIOC_CLK_ENABLE();
|
|---|
| 49 | __HAL_RCC_GPIOF_CLK_ENABLE();
|
|---|
| 50 | __HAL_RCC_GPIOA_CLK_ENABLE();
|
|---|
| 51 | __HAL_RCC_GPIOB_CLK_ENABLE();
|
|---|
| 52 | __HAL_RCC_GPIOD_CLK_ENABLE();
|
|---|
| 53 |
|
|---|
| 54 | /*Configure GPIO pin Output Level */
|
|---|
| 55 | HAL_GPIO_WritePin(GPIOC, AUX_EN_Pin|ADC_START_CONV_Pin|ADC_RESET_Pin, GPIO_PIN_RESET);
|
|---|
| 56 |
|
|---|
| 57 | /*Configure GPIO pin Output Level */
|
|---|
| 58 | HAL_GPIO_WritePin(GPIOA, LED_FUNCTION_Pin|LED_ERROR_Pin, GPIO_PIN_RESET);
|
|---|
| 59 |
|
|---|
| 60 | /*Configure GPIO pin Output Level */
|
|---|
| 61 | HAL_GPIO_WritePin(GPIOB, BUZZER_Pin|DISCHARGE_ENABLE_Pin|CHARGE_ENABLE_Pin, GPIO_PIN_RESET);
|
|---|
| 62 |
|
|---|
| 63 | /*Configure GPIO pins : AUX_EN_Pin ADC_START_CONV_Pin ADC_RESET_Pin */
|
|---|
| 64 | GPIO_InitStruct.Pin = AUX_EN_Pin|ADC_START_CONV_Pin|ADC_RESET_Pin;
|
|---|
| 65 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|---|
| 66 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|---|
| 67 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|---|
| 68 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
|---|
| 69 |
|
|---|
| 70 | /*Configure GPIO pins : LED_FUNCTION_Pin LED_ERROR_Pin */
|
|---|
| 71 | GPIO_InitStruct.Pin = LED_FUNCTION_Pin|LED_ERROR_Pin;
|
|---|
| 72 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|---|
| 73 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|---|
| 74 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|---|
| 75 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
|---|
| 76 |
|
|---|
| 77 | /*Configure GPIO pins : BUZZER_Pin DISCHARGE_ENABLE_Pin CHARGE_ENABLE_Pin */
|
|---|
| 78 | GPIO_InitStruct.Pin = BUZZER_Pin|DISCHARGE_ENABLE_Pin|CHARGE_ENABLE_Pin;
|
|---|
| 79 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|---|
| 80 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|---|
| 81 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|---|
| 82 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|---|
| 83 |
|
|---|
| 84 | /*Configure GPIO pin : GPIO_INPUT_BTN_MODE_Pin */
|
|---|
| 85 | GPIO_InitStruct.Pin = GPIO_INPUT_BTN_MODE_Pin;
|
|---|
| 86 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|---|
| 87 | GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|---|
| 88 | HAL_GPIO_Init(GPIO_INPUT_BTN_MODE_GPIO_Port, &GPIO_InitStruct);
|
|---|
| 89 |
|
|---|
| 90 | /*Configure GPIO pin : ADC_DATA_READY_Pin */
|
|---|
| 91 | GPIO_InitStruct.Pin = ADC_DATA_READY_Pin;
|
|---|
| 92 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
|---|
| 93 | GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|---|
| 94 | HAL_GPIO_Init(ADC_DATA_READY_GPIO_Port, &GPIO_InitStruct);
|
|---|
| 95 |
|
|---|
| 96 | /*Configure GPIO pin : FAULT_INT_Pin */
|
|---|
| 97 | GPIO_InitStruct.Pin = FAULT_INT_Pin;
|
|---|
| 98 | GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
|---|
| 99 | GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|---|
| 100 | HAL_GPIO_Init(FAULT_INT_GPIO_Port, &GPIO_InitStruct);
|
|---|
| 101 |
|
|---|
| 102 | /*Configure GPIO pin : COM_POWERPRO_RES_Pin */
|
|---|
| 103 | GPIO_InitStruct.Pin = COM_POWERPRO_RES_Pin;
|
|---|
| 104 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
|---|
| 105 | GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|---|
| 106 | HAL_GPIO_Init(COM_POWERPRO_RES_GPIO_Port, &GPIO_InitStruct);
|
|---|
| 107 |
|
|---|
| 108 | /* EXTI interrupt init*/
|
|---|
| 109 | HAL_NVIC_SetPriority(EXTI2_IRQn, 0, 0);
|
|---|
| 110 | HAL_NVIC_EnableIRQ(EXTI2_IRQn);
|
|---|
| 111 |
|
|---|
| 112 | HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
|
|---|
| 113 | HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
|
|---|
| 114 |
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | /* USER CODE BEGIN 2 */
|
|---|
| 118 |
|
|---|
| 119 | /* USER CODE END 2 */
|
|---|