configure LPTIM4 for BSP_POWER
This commit is contained in:
109
Core/Src/lptim.c
Normal file
109
Core/Src/lptim.c
Normal file
@@ -0,0 +1,109 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file lptim.c
|
||||
* @brief This file provides code for the configuration
|
||||
* of the LPTIM instances.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2024 STMicroelectronics.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software is licensed under terms that can be found in the LICENSE file
|
||||
* in the root directory of this software component.
|
||||
* If no LICENSE file comes with this software, it is provided AS-IS.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "lptim.h"
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
|
||||
/* USER CODE END 0 */
|
||||
|
||||
LPTIM_HandleTypeDef hlptim4;
|
||||
|
||||
/* LPTIM4 init function */
|
||||
void MX_LPTIM4_Init(void)
|
||||
{
|
||||
|
||||
/* USER CODE BEGIN LPTIM4_Init 0 */
|
||||
|
||||
/* USER CODE END LPTIM4_Init 0 */
|
||||
|
||||
/* USER CODE BEGIN LPTIM4_Init 1 */
|
||||
|
||||
/* USER CODE END LPTIM4_Init 1 */
|
||||
hlptim4.Instance = LPTIM4;
|
||||
hlptim4.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC;
|
||||
hlptim4.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV2;
|
||||
hlptim4.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE;
|
||||
hlptim4.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH;
|
||||
hlptim4.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE;
|
||||
hlptim4.Init.CounterSource = LPTIM_COUNTERSOURCE_INTERNAL;
|
||||
if (HAL_LPTIM_Init(&hlptim4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/* USER CODE BEGIN LPTIM4_Init 2 */
|
||||
|
||||
/* USER CODE END LPTIM4_Init 2 */
|
||||
|
||||
}
|
||||
|
||||
void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* lptimHandle)
|
||||
{
|
||||
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0};
|
||||
if(lptimHandle->Instance==LPTIM4)
|
||||
{
|
||||
/* USER CODE BEGIN LPTIM4_MspInit 0 */
|
||||
|
||||
/* USER CODE END LPTIM4_MspInit 0 */
|
||||
|
||||
/** Initializes the peripherals clock
|
||||
*/
|
||||
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LPTIM4;
|
||||
PeriphClkInitStruct.Lptim345ClockSelection = RCC_LPTIM345CLKSOURCE_LSI;
|
||||
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* LPTIM4 clock enable */
|
||||
__HAL_RCC_LPTIM4_CLK_ENABLE();
|
||||
|
||||
/* LPTIM4 interrupt Init */
|
||||
HAL_NVIC_SetPriority(LPTIM4_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(LPTIM4_IRQn);
|
||||
/* USER CODE BEGIN LPTIM4_MspInit 1 */
|
||||
|
||||
/* USER CODE END LPTIM4_MspInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef* lptimHandle)
|
||||
{
|
||||
|
||||
if(lptimHandle->Instance==LPTIM4)
|
||||
{
|
||||
/* USER CODE BEGIN LPTIM4_MspDeInit 0 */
|
||||
|
||||
/* USER CODE END LPTIM4_MspDeInit 0 */
|
||||
/* Peripheral clock disable */
|
||||
__HAL_RCC_LPTIM4_CLK_DISABLE();
|
||||
|
||||
/* LPTIM4 interrupt Deinit */
|
||||
HAL_NVIC_DisableIRQ(LPTIM4_IRQn);
|
||||
/* USER CODE BEGIN LPTIM4_MspDeInit 1 */
|
||||
|
||||
/* USER CODE END LPTIM4_MspDeInit 1 */
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
/* USER CODE END 1 */
|
||||
Reference in New Issue
Block a user