tdse-tp4_01-adc

FIUBA - Electrónica - Taller de Sistemas Embebidos - Trabajo Práctico N°: 4 - ADC
Index Commits Files Refs README
Core/Src/stm32f1xx_hal_msp.c (5551B)
   1 /* USER CODE BEGIN Header */
   2 /**
   3   ******************************************************************************
   4   * @file         stm32f1xx_hal_msp.c
   5   * @brief        This file provides code for the MSP Initialization
   6   *               and de-Initialization codes.
   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 "main.h"
  23 /* USER CODE BEGIN Includes */
  24 
  25 /* USER CODE END Includes */
  26 
  27 /* Private typedef -----------------------------------------------------------*/
  28 /* USER CODE BEGIN TD */
  29 
  30 /* USER CODE END TD */
  31 
  32 /* Private define ------------------------------------------------------------*/
  33 /* USER CODE BEGIN Define */
  34 
  35 /* USER CODE END Define */
  36 
  37 /* Private macro -------------------------------------------------------------*/
  38 /* USER CODE BEGIN Macro */
  39 
  40 /* USER CODE END Macro */
  41 
  42 /* Private variables ---------------------------------------------------------*/
  43 /* USER CODE BEGIN PV */
  44 
  45 /* USER CODE END PV */
  46 
  47 /* Private function prototypes -----------------------------------------------*/
  48 /* USER CODE BEGIN PFP */
  49 
  50 /* USER CODE END PFP */
  51 
  52 /* External functions --------------------------------------------------------*/
  53 /* USER CODE BEGIN ExternalFunctions */
  54 
  55 /* USER CODE END ExternalFunctions */
  56 
  57 /* USER CODE BEGIN 0 */
  58 
  59 /* USER CODE END 0 */
  60 /**
  61   * Initializes the Global MSP.
  62   */
  63 void HAL_MspInit(void)
  64 {
  65 
  66   /* USER CODE BEGIN MspInit 0 */
  67 
  68   /* USER CODE END MspInit 0 */
  69 
  70   __HAL_RCC_AFIO_CLK_ENABLE();
  71   __HAL_RCC_PWR_CLK_ENABLE();
  72 
  73   /* System interrupt init*/
  74 
  75   /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
  76   */
  77   __HAL_AFIO_REMAP_SWJ_NOJTAG();
  78 
  79   /* USER CODE BEGIN MspInit 1 */
  80 
  81   /* USER CODE END MspInit 1 */
  82 }
  83 
  84 /**
  85   * @brief ADC MSP Initialization
  86   * This function configures the hardware resources used in this example
  87   * @param hadc: ADC handle pointer
  88   * @retval None
  89   */
  90 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
  91 {
  92   GPIO_InitTypeDef GPIO_InitStruct = {0};
  93   if(hadc->Instance==ADC1)
  94   {
  95     /* USER CODE BEGIN ADC1_MspInit 0 */
  96 
  97     /* USER CODE END ADC1_MspInit 0 */
  98     /* Peripheral clock enable */
  99     __HAL_RCC_ADC1_CLK_ENABLE();
 100 
 101     __HAL_RCC_GPIOA_CLK_ENABLE();
 102     /**ADC1 GPIO Configuration
 103     PA0-WKUP     ------> ADC1_IN0
 104     */
 105     GPIO_InitStruct.Pin = GPIO_PIN_0;
 106     GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
 107     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 108 
 109     /* ADC1 interrupt Init */
 110     HAL_NVIC_SetPriority(ADC1_2_IRQn, 0, 0);
 111     HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
 112     /* USER CODE BEGIN ADC1_MspInit 1 */
 113 
 114     /* USER CODE END ADC1_MspInit 1 */
 115 
 116   }
 117 
 118 }
 119 
 120 /**
 121   * @brief ADC MSP De-Initialization
 122   * This function freeze the hardware resources used in this example
 123   * @param hadc: ADC handle pointer
 124   * @retval None
 125   */
 126 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
 127 {
 128   if(hadc->Instance==ADC1)
 129   {
 130     /* USER CODE BEGIN ADC1_MspDeInit 0 */
 131 
 132     /* USER CODE END ADC1_MspDeInit 0 */
 133     /* Peripheral clock disable */
 134     __HAL_RCC_ADC1_CLK_DISABLE();
 135 
 136     /**ADC1 GPIO Configuration
 137     PA0-WKUP     ------> ADC1_IN0
 138     */
 139     HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0);
 140 
 141     /* ADC1 interrupt DeInit */
 142     HAL_NVIC_DisableIRQ(ADC1_2_IRQn);
 143     /* USER CODE BEGIN ADC1_MspDeInit 1 */
 144 
 145     /* USER CODE END ADC1_MspDeInit 1 */
 146   }
 147 
 148 }
 149 
 150 /**
 151   * @brief UART MSP Initialization
 152   * This function configures the hardware resources used in this example
 153   * @param huart: UART handle pointer
 154   * @retval None
 155   */
 156 void HAL_UART_MspInit(UART_HandleTypeDef* huart)
 157 {
 158   GPIO_InitTypeDef GPIO_InitStruct = {0};
 159   if(huart->Instance==USART2)
 160   {
 161     /* USER CODE BEGIN USART2_MspInit 0 */
 162 
 163     /* USER CODE END USART2_MspInit 0 */
 164     /* Peripheral clock enable */
 165     __HAL_RCC_USART2_CLK_ENABLE();
 166 
 167     __HAL_RCC_GPIOA_CLK_ENABLE();
 168     /**USART2 GPIO Configuration
 169     PA2     ------> USART2_TX
 170     PA3     ------> USART2_RX
 171     */
 172     GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin;
 173     GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
 174     GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
 175     HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 176 
 177     /* USER CODE BEGIN USART2_MspInit 1 */
 178 
 179     /* USER CODE END USART2_MspInit 1 */
 180 
 181   }
 182 
 183 }
 184 
 185 /**
 186   * @brief UART MSP De-Initialization
 187   * This function freeze the hardware resources used in this example
 188   * @param huart: UART handle pointer
 189   * @retval None
 190   */
 191 void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
 192 {
 193   if(huart->Instance==USART2)
 194   {
 195     /* USER CODE BEGIN USART2_MspDeInit 0 */
 196 
 197     /* USER CODE END USART2_MspDeInit 0 */
 198     /* Peripheral clock disable */
 199     __HAL_RCC_USART2_CLK_DISABLE();
 200 
 201     /**USART2 GPIO Configuration
 202     PA2     ------> USART2_TX
 203     PA3     ------> USART2_RX
 204     */
 205     HAL_GPIO_DeInit(GPIOA, USART_TX_Pin|USART_RX_Pin);
 206 
 207     /* USER CODE BEGIN USART2_MspDeInit 1 */
 208 
 209     /* USER CODE END USART2_MspDeInit 1 */
 210   }
 211 
 212 }
 213 
 214 /* USER CODE BEGIN 1 */
 215 
 216 /* USER CODE END 1 */