[bsp/stm32] add pm support by cubemx tool

This commit is contained in:
tyustli 2020-03-09 14:08:58 +08:00
parent 9d9432eb93
commit 6304ed3ad5
6 changed files with 145 additions and 64 deletions

View File

@ -13,15 +13,6 @@
static LPTIM_HandleTypeDef LptimHandle;
void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim)
{
if (hlptim->Instance == LPTIM1)
{
/* Peripheral clock enable */
__HAL_RCC_LPTIM1_CLK_ENABLE();
}
}
void LPTIM1_IRQHandler(void)
{
HAL_LPTIM_IRQHandler(&LptimHandle);

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@
******************************************************************************
* @attention
*
* <h2><center>&copy; COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
* <h2><center>&copy; COPYRIGHT(c) 2020 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
@ -69,7 +69,7 @@
#define HAL_IWDG_MODULE_ENABLED
/*#define HAL_LTDC_MODULE_ENABLED */
/*#define HAL_LCD_MODULE_ENABLED */
/*#define HAL_LPTIM_MODULE_ENABLED */
#define HAL_LPTIM_MODULE_ENABLED
/*#define HAL_MMC_MODULE_ENABLED */
/*#define HAL_NAND_MODULE_ENABLED */
/*#define HAL_NOR_MODULE_ENABLED */
@ -77,6 +77,7 @@
/*#define HAL_OSPI_MODULE_ENABLED */
/*#define HAL_OSPI_MODULE_ENABLED */
#define HAL_PCD_MODULE_ENABLED
/*#define HAL_PKA_MODULE_ENABLED */
/*#define HAL_QSPI_MODULE_ENABLED */
#define HAL_QSPI_MODULE_ENABLED
/*#define HAL_RNG_MODULE_ENABLED */
@ -94,6 +95,7 @@
/*#define HAL_USART_MODULE_ENABLED */
/*#define HAL_WWDG_MODULE_ENABLED */
/*#define HAL_EXTI_MODULE_ENABLED */
/*#define HAL_PSSI_MODULE_ENABLED */
#define HAL_GPIO_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
@ -338,6 +340,10 @@
#include "stm32l4xx_hal_ospi.h"
#endif /* HAL_OSPI_MODULE_ENABLED */
#ifdef HAL_PKA_MODULE_ENABLED
#include "stm32l4xx_hal_pka.h"
#endif /* HAL_PWR_MODULE_ENABLED */
#ifdef HAL_PWR_MODULE_ENABLED
#include "stm32l4xx_hal_pwr.h"
#endif /* HAL_PWR_MODULE_ENABLED */
@ -414,6 +420,10 @@
#include "stm32l4xx_hal_gfxmmu.h"
#endif /* HAL_GFXMMU_MODULE_ENABLED */
#ifdef HAL_PSSI_MODULE_ENABLED
#include "stm32l4xx_hal_pssi.h"
#endif /* HAL_PSSI_MODULE_ENABLED */
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
@ -424,7 +434,7 @@
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((char *)__FILE__, __LINE__))
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(char *file, uint32_t line);
#else

View File

@ -11,25 +11,26 @@ KeepUserPlacement=false
Mcu.Family=STM32L4
Mcu.IP0=ADC1
Mcu.IP1=IWDG
Mcu.IP10=SYS
Mcu.IP11=TIM1
Mcu.IP12=TIM2
Mcu.IP13=TIM4
Mcu.IP14=TIM15
Mcu.IP15=TIM16
Mcu.IP16=TIM17
Mcu.IP17=USART1
Mcu.IP18=USART2
Mcu.IP19=USB_OTG_FS
Mcu.IP2=NVIC
Mcu.IP3=QUADSPI
Mcu.IP4=RCC
Mcu.IP5=RTC
Mcu.IP6=SAI1
Mcu.IP7=SPI1
Mcu.IP8=SPI2
Mcu.IP9=SPI3
Mcu.IPNb=20
Mcu.IP10=SPI3
Mcu.IP11=SYS
Mcu.IP12=TIM1
Mcu.IP13=TIM2
Mcu.IP14=TIM4
Mcu.IP15=TIM15
Mcu.IP16=TIM16
Mcu.IP17=TIM17
Mcu.IP18=USART1
Mcu.IP19=USART2
Mcu.IP2=LPTIM1
Mcu.IP20=USB_OTG_FS
Mcu.IP3=NVIC
Mcu.IP4=QUADSPI
Mcu.IP5=RCC
Mcu.IP6=RTC
Mcu.IP7=SAI1
Mcu.IP8=SPI1
Mcu.IP9=SPI2
Mcu.IPNb=21
Mcu.Name=STM32L475V(C-E-G)Tx
Mcu.Package=LQFP100
Mcu.Pin0=PE2
@ -65,30 +66,32 @@ Mcu.Pin35=PB5
Mcu.Pin36=PB7
Mcu.Pin37=PB8
Mcu.Pin38=VP_IWDG_VS_IWDG
Mcu.Pin39=VP_RTC_VS_RTC_Activate
Mcu.Pin39=VP_LPTIM1_VS_LPTIM_counterModeInternalClock
Mcu.Pin4=PE6
Mcu.Pin40=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC
Mcu.Pin41=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC
Mcu.Pin42=VP_SYS_VS_Systick
Mcu.Pin43=VP_TIM1_VS_ClockSourceINT
Mcu.Pin44=VP_TIM2_VS_ClockSourceINT
Mcu.Pin45=VP_TIM4_VS_ClockSourceINT
Mcu.Pin46=VP_TIM15_VS_ClockSourceINT
Mcu.Pin47=VP_TIM16_VS_ClockSourceINT
Mcu.Pin48=VP_TIM17_VS_ClockSourceINT
Mcu.Pin40=VP_RTC_VS_RTC_Activate
Mcu.Pin41=VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC
Mcu.Pin42=VP_SAI1_VP_$IpInstance_SAIB_SAI_BASIC
Mcu.Pin43=VP_SYS_VS_Systick
Mcu.Pin44=VP_TIM1_VS_ClockSourceINT
Mcu.Pin45=VP_TIM2_VS_ClockSourceINT
Mcu.Pin46=VP_TIM4_VS_ClockSourceINT
Mcu.Pin47=VP_TIM15_VS_ClockSourceINT
Mcu.Pin48=VP_TIM16_VS_ClockSourceINT
Mcu.Pin49=VP_TIM17_VS_ClockSourceINT
Mcu.Pin5=PC14-OSC32_IN (PC14)
Mcu.Pin6=PC15-OSC32_OUT (PC15)
Mcu.Pin7=PH0-OSC_IN (PH0)
Mcu.Pin8=PH1-OSC_OUT (PH1)
Mcu.Pin9=PA2
Mcu.PinsNb=49
Mcu.PinsNb=50
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32L475VETx
MxCube.Version=5.3.0
MxDb.Version=DB.5.0.30
MxCube.Version=5.6.0
MxDb.Version=DB.5.0.60
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false
@ -148,14 +151,6 @@ PC14-OSC32_IN\ (PC14).Signal=RCC_OSC32_IN
PC15-OSC32_OUT\ (PC15).Mode=LSE-External-Oscillator
PC15-OSC32_OUT\ (PC15).Signal=RCC_OSC32_OUT
PC5.Signal=ADCx_IN14
PCC.Checker=true
PCC.Line=STM32L4x5
PCC.MCU=STM32L475V(C-E-G)Tx
PCC.PartNumber=STM32L475VETx
PCC.Seq0=0
PCC.Series=STM32L4
PCC.Temperature=25
PCC.Vdd=3.0
PE10.Mode=Single Bank
PE10.Signal=QUADSPI_CLK
PE11.Mode=Single Bank
@ -194,10 +189,10 @@ ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
ProjectManager.CoupleFile=false
ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=false
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32L475VETx
ProjectManager.FirmwarePackage=STM32Cube FW_L4 V1.14.0
ProjectManager.FirmwarePackage=STM32Cube FW_L4 V1.15.1
ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
@ -327,6 +322,8 @@ USB_OTG_FS.IPParameters=VirtualMode
USB_OTG_FS.VirtualMode=Device_Only
VP_IWDG_VS_IWDG.Mode=IWDG_Activate
VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG
VP_LPTIM1_VS_LPTIM_counterModeInternalClock.Mode=Counts__internal_clock_event_00
VP_LPTIM1_VS_LPTIM_counterModeInternalClock.Signal=LPTIM1_VS_LPTIM_counterModeInternalClock
VP_RTC_VS_RTC_Activate.Mode=RTC_Enabled
VP_RTC_VS_RTC_Activate.Signal=RTC_VS_RTC_Activate
VP_SAI1_VP_$IpInstance_SAIA_SAI_BASIC.Mode=SAI_A_BASIC

View File

@ -66,6 +66,8 @@ ADC_HandleTypeDef hadc1;
IWDG_HandleTypeDef hiwdg;
LPTIM_HandleTypeDef hlptim1;
QSPI_HandleTypeDef hqspi;
RTC_HandleTypeDef hrtc;
@ -114,6 +116,7 @@ static void MX_SAI1_Init(void);
static void MX_SPI3_Init(void);
static void MX_TIM2_Init(void);
static void MX_USB_OTG_FS_PCD_Init(void);
static void MX_LPTIM1_Init(void);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
@ -134,7 +137,6 @@ int main(void)
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
@ -170,6 +172,7 @@ int main(void)
MX_SPI3_Init();
MX_TIM2_Init();
MX_USB_OTG_FS_PCD_Init();
MX_LPTIM1_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
@ -233,10 +236,12 @@ void SystemClock_Config(void)
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_USART1
|RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_SAI1
|RCC_PERIPHCLK_USB|RCC_PERIPHCLK_ADC;
|RCC_PERIPHCLK_USART2|RCC_PERIPHCLK_LPTIM1
|RCC_PERIPHCLK_SAI1|RCC_PERIPHCLK_USB
|RCC_PERIPHCLK_ADC;
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
PeriphClkInit.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_PCLK;
PeriphClkInit.Sai1ClockSelection = RCC_SAI1CLKSOURCE_PLLSAI1;
PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
@ -291,6 +296,7 @@ static void MX_ADC1_Init(void)
hadc1.Init.ContinuousConvMode = DISABLE;
hadc1.Init.NbrOfConversion = 1;
hadc1.Init.DiscontinuousConvMode = DISABLE;
hadc1.Init.NbrOfDiscConversion = 1;
hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
hadc1.Init.DMAContinuousRequests = DISABLE;
@ -354,6 +360,40 @@ static void MX_IWDG_Init(void)
}
/**
* @brief LPTIM1 Initialization Function
* @param None
* @retval None
*/
static void MX_LPTIM1_Init(void)
{
/* USER CODE BEGIN LPTIM1_Init 0 */
/* USER CODE END LPTIM1_Init 0 */
/* USER CODE BEGIN LPTIM1_Init 1 */
/* USER CODE END LPTIM1_Init 1 */
hlptim1.Instance = LPTIM1;
hlptim1.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC;
hlptim1.Init.Clock.Prescaler = LPTIM_PRESCALER_DIV1;
hlptim1.Init.Trigger.Source = LPTIM_TRIGSOURCE_SOFTWARE;
hlptim1.Init.OutputPolarity = LPTIM_OUTPUTPOLARITY_HIGH;
hlptim1.Init.UpdateMode = LPTIM_UPDATE_IMMEDIATE;
hlptim1.Init.CounterSource = LPTIM_COUNTERSOURCE_INTERNAL;
hlptim1.Init.Input1Source = LPTIM_INPUT1SOURCE_GPIO;
hlptim1.Init.Input2Source = LPTIM_INPUT2SOURCE_GPIO;
if (HAL_LPTIM_Init(&hlptim1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN LPTIM1_Init 2 */
/* USER CODE END LPTIM1_Init 2 */
}
/**
* @brief QUADSPI Initialization Function
* @param None
@ -1055,7 +1095,7 @@ void Error_Handler(void)
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(char *file, uint32_t line)
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,

View File

@ -160,6 +160,50 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
}
/**
* @brief LPTIM MSP Initialization
* This function configures the hardware resources used in this example
* @param hlptim: LPTIM handle pointer
* @retval None
*/
void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* hlptim)
{
if(hlptim->Instance==LPTIM1)
{
/* USER CODE BEGIN LPTIM1_MspInit 0 */
/* USER CODE END LPTIM1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_LPTIM1_CLK_ENABLE();
/* USER CODE BEGIN LPTIM1_MspInit 1 */
/* USER CODE END LPTIM1_MspInit 1 */
}
}
/**
* @brief LPTIM MSP De-Initialization
* This function freeze the hardware resources used in this example
* @param hlptim: LPTIM handle pointer
* @retval None
*/
void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef* hlptim)
{
if(hlptim->Instance==LPTIM1)
{
/* USER CODE BEGIN LPTIM1_MspDeInit 0 */
/* USER CODE END LPTIM1_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_LPTIM1_CLK_DISABLE();
/* USER CODE BEGIN LPTIM1_MspDeInit 1 */
/* USER CODE END LPTIM1_MspDeInit 1 */
}
}
/**
* @brief QSPI MSP Initialization
* This function configures the hardware resources used in this example
@ -922,7 +966,6 @@ void HAL_SAI_MspInit(SAI_HandleTypeDef* hsai)
void HAL_SAI_MspDeInit(SAI_HandleTypeDef* hsai)
{
/* SAI1 */
if(hsai->Instance==SAI1_Block_A)
{