| | |
| | | /* USER CODE BEGIN 0 */ |
| | | |
| | | /* USER CODE END 0 */ |
| | | /** |
| | | |
| | | void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim); |
| | | /** |
| | | * Initializes the Global MSP. |
| | | */ |
| | | void HAL_MspInit(void) |
| | |
| | | /* USER CODE END ADC1_MspInit 0 */ |
| | | /* Peripheral clock enable */ |
| | | __HAL_RCC_ADC1_CLK_ENABLE(); |
| | | |
| | | |
| | | __HAL_RCC_GPIOA_CLK_ENABLE(); |
| | | /**ADC GPIO Configuration |
| | | PA1 ------> ADC_IN1 |
| | | /**ADC GPIO Configuration |
| | | PA1 ------> ADC_IN1 |
| | | */ |
| | | GPIO_InitStruct.Pin = BAT_MEAS_Pin; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
| | |
| | | /* USER CODE END ADC1_MspDeInit 0 */ |
| | | /* Peripheral clock disable */ |
| | | __HAL_RCC_ADC1_CLK_DISABLE(); |
| | | |
| | | /**ADC GPIO Configuration |
| | | PA1 ------> ADC_IN1 |
| | | |
| | | /**ADC GPIO Configuration |
| | | PA1 ------> ADC_IN1 |
| | | */ |
| | | HAL_GPIO_DeInit(BAT_MEAS_GPIO_Port, BAT_MEAS_Pin); |
| | | |
| | |
| | | /* USER CODE END SPI1_MspInit 0 */ |
| | | /* Peripheral clock enable */ |
| | | __HAL_RCC_SPI1_CLK_ENABLE(); |
| | | |
| | | |
| | | __HAL_RCC_GPIOA_CLK_ENABLE(); |
| | | /**SPI1 GPIO Configuration |
| | | /**SPI1 GPIO Configuration |
| | | PA5 ------> SPI1_SCK |
| | | PA6 ------> SPI1_MISO |
| | | PA7 ------> SPI1_MOSI |
| | | PA7 ------> SPI1_MOSI |
| | | */ |
| | | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| | |
| | | /* USER CODE END SPI1_MspDeInit 0 */ |
| | | /* Peripheral clock disable */ |
| | | __HAL_RCC_SPI1_CLK_DISABLE(); |
| | | |
| | | /**SPI1 GPIO Configuration |
| | | |
| | | /**SPI1 GPIO Configuration |
| | | PA5 ------> SPI1_SCK |
| | | PA6 ------> SPI1_MISO |
| | | PA7 ------> SPI1_MOSI |
| | | PA7 ------> SPI1_MOSI |
| | | */ |
| | | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7); |
| | | |
| | | /* USER CODE BEGIN SPI1_MspDeInit 1 */ |
| | | |
| | | /* USER CODE END SPI1_MspDeInit 1 */ |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @brief TIM_Base MSP Initialization |
| | | * This function configures the hardware resources used in this example |
| | | * @param htim_base: TIM_Base handle pointer |
| | | * @retval None |
| | | */ |
| | | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) |
| | | { |
| | | if(htim_base->Instance==TIM2) |
| | | { |
| | | /* USER CODE BEGIN TIM2_MspInit 0 */ |
| | | |
| | | /* USER CODE END TIM2_MspInit 0 */ |
| | | /* Peripheral clock enable */ |
| | | __HAL_RCC_TIM2_CLK_ENABLE(); |
| | | /* USER CODE BEGIN TIM2_MspInit 1 */ |
| | | |
| | | /* USER CODE END TIM2_MspInit 1 */ |
| | | } |
| | | |
| | | } |
| | | |
| | | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim) |
| | | { |
| | | GPIO_InitTypeDef GPIO_InitStruct = {0}; |
| | | if(htim->Instance==TIM2) |
| | | { |
| | | /* USER CODE BEGIN TIM2_MspPostInit 0 */ |
| | | |
| | | /* USER CODE END TIM2_MspPostInit 0 */ |
| | | |
| | | __HAL_RCC_GPIOB_CLK_ENABLE(); |
| | | /**TIM2 GPIO Configuration |
| | | PB10 ------> TIM2_CH3 |
| | | */ |
| | | GPIO_InitStruct.Pin = GPIO_PIN_10; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| | | GPIO_InitStruct.Pull = GPIO_NOPULL; |
| | | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; |
| | | GPIO_InitStruct.Alternate = GPIO_AF2_TIM2; |
| | | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
| | | |
| | | /* USER CODE BEGIN TIM2_MspPostInit 1 */ |
| | | |
| | | /* USER CODE END TIM2_MspPostInit 1 */ |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * @brief TIM_Base MSP De-Initialization |
| | | * This function freeze the hardware resources used in this example |
| | | * @param htim_base: TIM_Base handle pointer |
| | | * @retval None |
| | | */ |
| | | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) |
| | | { |
| | | if(htim_base->Instance==TIM2) |
| | | { |
| | | /* USER CODE BEGIN TIM2_MspDeInit 0 */ |
| | | |
| | | /* USER CODE END TIM2_MspDeInit 0 */ |
| | | /* Peripheral clock disable */ |
| | | __HAL_RCC_TIM2_CLK_DISABLE(); |
| | | /* USER CODE BEGIN TIM2_MspDeInit 1 */ |
| | | |
| | | /* USER CODE END TIM2_MspDeInit 1 */ |
| | | } |
| | | |
| | | } |
| | |
| | | /* USER CODE END USART1_MspInit 0 */ |
| | | /* Peripheral clock enable */ |
| | | __HAL_RCC_USART1_CLK_ENABLE(); |
| | | |
| | | |
| | | __HAL_RCC_GPIOA_CLK_ENABLE(); |
| | | /**USART1 GPIO Configuration |
| | | /**USART1 GPIO Configuration |
| | | PA9 ------> USART1_TX |
| | | PA10 ------> USART1_RX |
| | | PA10 ------> USART1_RX |
| | | */ |
| | | GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10; |
| | | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; |
| | |
| | | /* USER CODE END USART1_MspDeInit 0 */ |
| | | /* Peripheral clock disable */ |
| | | __HAL_RCC_USART1_CLK_DISABLE(); |
| | | |
| | | /**USART1 GPIO Configuration |
| | | |
| | | /**USART1 GPIO Configuration |
| | | PA9 ------> USART1_TX |
| | | PA10 ------> USART1_RX |
| | | PA10 ------> USART1_RX |
| | | */ |
| | | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10); |
| | | |