[bsp/stm32/stm32l496-ali-developert] add pm supported (#5391)
* [bsp/stm32/stm32l496-ali-developert] add lptimer config * [bsp/stm32/stm32l496-ali-developert] add pm supported
This commit is contained in:
parent
2babfedd52
commit
2539c7ff85
File diff suppressed because one or more lines are too long
@ -14,21 +14,22 @@ LPUART1.WordLength=UART_WORDLENGTH_8B
|
||||
Mcu.Family=STM32L4
|
||||
Mcu.IP0=ADC1
|
||||
Mcu.IP1=IWDG
|
||||
Mcu.IP10=TIM3
|
||||
Mcu.IP11=TIM15
|
||||
Mcu.IP12=TIM16
|
||||
Mcu.IP13=TIM17
|
||||
Mcu.IP14=USART2
|
||||
Mcu.IP15=USART3
|
||||
Mcu.IP2=LPUART1
|
||||
Mcu.IP3=NVIC
|
||||
Mcu.IP4=RCC
|
||||
Mcu.IP5=RTC
|
||||
Mcu.IP6=SDMMC1
|
||||
Mcu.IP7=SPI1
|
||||
Mcu.IP8=SPI2
|
||||
Mcu.IP9=SYS
|
||||
Mcu.IPNb=16
|
||||
Mcu.IP10=SYS
|
||||
Mcu.IP11=TIM3
|
||||
Mcu.IP12=TIM15
|
||||
Mcu.IP13=TIM16
|
||||
Mcu.IP14=TIM17
|
||||
Mcu.IP15=USART2
|
||||
Mcu.IP16=USART3
|
||||
Mcu.IP2=LPTIM1
|
||||
Mcu.IP3=LPUART1
|
||||
Mcu.IP4=NVIC
|
||||
Mcu.IP5=RCC
|
||||
Mcu.IP6=RTC
|
||||
Mcu.IP7=SDMMC1
|
||||
Mcu.IP8=SPI1
|
||||
Mcu.IP9=SPI2
|
||||
Mcu.IPNb=17
|
||||
Mcu.Name=STM32L496V(E-G)Tx
|
||||
Mcu.Package=LQFP100
|
||||
Mcu.Pin0=PE4
|
||||
@ -55,33 +56,35 @@ Mcu.Pin27=PD2
|
||||
Mcu.Pin28=PD3
|
||||
Mcu.Pin29=VP_IWDG_VS_IWDG
|
||||
Mcu.Pin3=PC14-OSC32_IN (PC14)
|
||||
Mcu.Pin30=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin31=VP_SYS_VS_Systick
|
||||
Mcu.Pin32=VP_TIM15_VS_ClockSourceINT
|
||||
Mcu.Pin33=VP_TIM16_VS_ClockSourceINT
|
||||
Mcu.Pin34=VP_TIM17_VS_ClockSourceINT
|
||||
Mcu.Pin30=VP_LPTIM1_VS_LPTIM_counterModeInternalClock
|
||||
Mcu.Pin31=VP_RTC_VS_RTC_Activate
|
||||
Mcu.Pin32=VP_SYS_VS_Systick
|
||||
Mcu.Pin33=VP_TIM15_VS_ClockSourceINT
|
||||
Mcu.Pin34=VP_TIM16_VS_ClockSourceINT
|
||||
Mcu.Pin35=VP_TIM17_VS_ClockSourceINT
|
||||
Mcu.Pin4=PC15-OSC32_OUT (PC15)
|
||||
Mcu.Pin5=PH0-OSC_IN (PH0)
|
||||
Mcu.Pin6=PH1-OSC_OUT (PH1)
|
||||
Mcu.Pin7=PC1
|
||||
Mcu.Pin8=PC2
|
||||
Mcu.Pin9=PC3
|
||||
Mcu.PinsNb=35
|
||||
Mcu.PinsNb=36
|
||||
Mcu.ThirdPartyNb=0
|
||||
Mcu.UserConstants=
|
||||
Mcu.UserName=STM32L496VGTx
|
||||
MxCube.Version=5.0.1
|
||||
MxDb.Version=DB.5.0.1
|
||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
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
|
||||
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false
|
||||
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
|
||||
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
|
||||
PA13\ (JTMS/SWDIO).Mode=Serial_Wire
|
||||
PA13\ (JTMS/SWDIO).Signal=SYS_JTMS-SWDIO
|
||||
PA14\ (JTCK/SWCLK).Mode=Serial_Wire
|
||||
@ -104,16 +107,16 @@ PA7.Signal=SPI1_MOSI
|
||||
PA9.Locked=true
|
||||
PA9.Mode=Full_Duplex_Master
|
||||
PA9.Signal=SPI2_SCK
|
||||
PB10.Locked=true
|
||||
PB10.GPIOParameters=GPIO_PuPd
|
||||
PB10.GPIO_PuPd=GPIO_PULLUP
|
||||
PB10.Locked=true
|
||||
PB10.Mode=Asynchronous
|
||||
PB10.Signal=LPUART1_RX
|
||||
PB11.GPIOParameters=GPIO_PuPd
|
||||
PB11.GPIO_PuPd=GPIO_PULLUP
|
||||
PB11.Locked=true
|
||||
PB11.Mode=Asynchronous
|
||||
PB11.Signal=LPUART1_TX
|
||||
PB11.GPIOParameters=GPIO_PuPd
|
||||
PB11.GPIO_PuPd=GPIO_PULLUP
|
||||
PC1.Mode=Full_Duplex_Master
|
||||
PC1.Signal=SPI2_MOSI
|
||||
PC10.Mode=SD_4_bits_Wide_bus
|
||||
@ -138,14 +141,6 @@ PC8.Mode=SD_4_bits_Wide_bus
|
||||
PC8.Signal=SDMMC1_D0
|
||||
PC9.Mode=SD_4_bits_Wide_bus
|
||||
PC9.Signal=SDMMC1_D1
|
||||
PCC.Checker=true
|
||||
PCC.Line=STM32L4x6
|
||||
PCC.MCU=STM32L496V(E-G)Tx
|
||||
PCC.PartNumber=STM32L496VGTx
|
||||
PCC.Seq0=0
|
||||
PCC.Series=STM32L4
|
||||
PCC.Temperature=25
|
||||
PCC.Vdd=null
|
||||
PD2.Mode=SD_4_bits_Wide_bus
|
||||
PD2.Signal=SDMMC1_CMD
|
||||
PD3.Locked=true
|
||||
@ -184,6 +179,7 @@ ProjectManager.PreviousToolchain=
|
||||
ProjectManager.ProjectBuild=false
|
||||
ProjectManager.ProjectFileName=CubeMX_Config.ioc
|
||||
ProjectManager.ProjectName=CubeMX_Config
|
||||
ProjectManager.RegisterCallBack=
|
||||
ProjectManager.StackSize=0x400
|
||||
ProjectManager.TargetToolchain=MDK-ARM V5
|
||||
ProjectManager.ToolChainLocation=
|
||||
@ -277,6 +273,8 @@ USART3.IPParameters=VirtualMode-Asynchronous
|
||||
USART3.VirtualMode-Asynchronous=VM_ASYNC
|
||||
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_SYS_VS_Systick.Mode=SysTick
|
||||
|
@ -1,11 +1,11 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file stm32l4xx_hal_conf.h
|
||||
* @brief HAL configuration file.
|
||||
* @brief HAL configuration file.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT(c) 2019 STMicroelectronics</center></h2>
|
||||
* <h2><center>© COPYRIGHT(c) 2021 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@ -30,7 +30,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32L4xx_HAL_CONF_H
|
||||
@ -45,10 +45,10 @@
|
||||
|
||||
/* ########################## Module Selection ############################## */
|
||||
/**
|
||||
* @brief This is the list of modules to be used in the HAL driver
|
||||
* @brief This is the list of modules to be used in the HAL driver
|
||||
*/
|
||||
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_MODULE_ENABLED
|
||||
#define HAL_ADC_MODULE_ENABLED
|
||||
/*#define HAL_CRYP_MODULE_ENABLED */
|
||||
/*#define HAL_CAN_MODULE_ENABLED */
|
||||
@ -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_NAND_MODULE_ENABLED */
|
||||
/*#define HAL_NOR_MODULE_ENABLED */
|
||||
/*#define HAL_OPAMP_MODULE_ENABLED */
|
||||
@ -105,9 +105,9 @@
|
||||
/**
|
||||
* @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSE is used as system clock source, directly or through the PLL).
|
||||
* (when HSE is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSE_VALUE)
|
||||
#if !defined (HSE_VALUE)
|
||||
#define HSE_VALUE ((uint32_t)8000000U) /*!< Value of the External oscillator in Hz */
|
||||
#endif /* HSE_VALUE */
|
||||
|
||||
@ -125,7 +125,7 @@
|
||||
/**
|
||||
* @brief Internal High Speed oscillator (HSI) value.
|
||||
* This value is used by the RCC HAL module to compute the system frequency
|
||||
* (when HSI is used as system clock source, directly or through the PLL).
|
||||
* (when HSI is used as system clock source, directly or through the PLL).
|
||||
*/
|
||||
#if !defined (HSI_VALUE)
|
||||
#define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/
|
||||
@ -138,7 +138,7 @@
|
||||
* When the CRS is not used, the HSI48 RC oscillator runs on it default frequency
|
||||
* which is subject to manufacturing process variations.
|
||||
*/
|
||||
#if !defined (HSI48_VALUE)
|
||||
#if !defined (HSI48_VALUE)
|
||||
#define HSI48_VALUE ((uint32_t)48000000U) /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz.
|
||||
The real value my vary depending on manufacturing process variations.*/
|
||||
#endif /* HSI48_VALUE */
|
||||
@ -146,7 +146,7 @@
|
||||
/**
|
||||
* @brief Internal Low Speed oscillator (LSI) value.
|
||||
*/
|
||||
#if !defined (LSI_VALUE)
|
||||
#if !defined (LSI_VALUE)
|
||||
#define LSI_VALUE ((uint32_t)32000U) /*!< LSI Typical Value in Hz*/
|
||||
#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
|
||||
The real value may vary depending on the variations
|
||||
@ -166,7 +166,7 @@
|
||||
|
||||
/**
|
||||
* @brief External clock source for SAI1 peripheral
|
||||
* This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source
|
||||
* This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source
|
||||
* frequency.
|
||||
*/
|
||||
#if !defined (EXTERNAL_SAI1_CLOCK_VALUE)
|
||||
@ -175,7 +175,7 @@
|
||||
|
||||
/**
|
||||
* @brief External clock source for SAI2 peripheral
|
||||
* This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source
|
||||
* This value is used by the RCC HAL module to compute the SAI1 & SAI2 clock source
|
||||
* frequency.
|
||||
*/
|
||||
#if !defined (EXTERNAL_SAI2_CLOCK_VALUE)
|
||||
@ -188,18 +188,18 @@
|
||||
/* ########################### System Configuration ######################### */
|
||||
/**
|
||||
* @brief This is the HAL system configuration section
|
||||
*/
|
||||
|
||||
#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
|
||||
#define USE_RTOS 0U
|
||||
*/
|
||||
|
||||
#define VDD_VALUE ((uint32_t)3300U) /*!< Value of VDD in mv */
|
||||
#define TICK_INT_PRIORITY ((uint32_t)0U) /*!< tick interrupt priority */
|
||||
#define USE_RTOS 0U
|
||||
#define PREFETCH_ENABLE 0U
|
||||
#define INSTRUCTION_CACHE_ENABLE 1U
|
||||
#define DATA_CACHE_ENABLE 1U
|
||||
|
||||
/* ########################## Assert Selection ############################## */
|
||||
/**
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* @brief Uncomment the line below to expanse the "assert_param" macro in the
|
||||
* HAL drivers code
|
||||
*/
|
||||
/* #define USE_FULL_ASSERT 1U */
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
@ -66,6 +66,8 @@ ADC_HandleTypeDef hadc1;
|
||||
|
||||
IWDG_HandleTypeDef hiwdg;
|
||||
|
||||
LPTIM_HandleTypeDef hlptim1;
|
||||
|
||||
UART_HandleTypeDef hlpuart1;
|
||||
UART_HandleTypeDef huart2;
|
||||
UART_HandleTypeDef huart3;
|
||||
@ -102,6 +104,7 @@ static void MX_IWDG_Init(void);
|
||||
static void MX_TIM3_Init(void);
|
||||
static void MX_ADC1_Init(void);
|
||||
static void MX_SPI2_Init(void);
|
||||
static void MX_LPTIM1_Init(void);
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
@ -152,6 +155,7 @@ int main(void)
|
||||
MX_TIM3_Init();
|
||||
MX_ADC1_Init();
|
||||
MX_SPI2_Init();
|
||||
MX_LPTIM1_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
|
||||
/* USER CODE END 2 */
|
||||
@ -177,11 +181,11 @@ void SystemClock_Config(void)
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
|
||||
|
||||
/**Configure LSE Drive Capability
|
||||
/**Configure LSE Drive Capability
|
||||
*/
|
||||
HAL_PWR_EnableBkUpAccess();
|
||||
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_LSE
|
||||
|RCC_OSCILLATORTYPE_MSI;
|
||||
@ -201,7 +205,7 @@ void SystemClock_Config(void)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|
||||
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
|
||||
@ -216,10 +220,12 @@ void SystemClock_Config(void)
|
||||
}
|
||||
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_USART2
|
||||
|RCC_PERIPHCLK_USART3|RCC_PERIPHCLK_LPUART1
|
||||
|RCC_PERIPHCLK_SDMMC1|RCC_PERIPHCLK_ADC;
|
||||
|RCC_PERIPHCLK_LPTIM1|RCC_PERIPHCLK_SDMMC1
|
||||
|RCC_PERIPHCLK_ADC;
|
||||
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
|
||||
PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;
|
||||
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
|
||||
PeriphClkInit.Lptim1ClockSelection = RCC_LPTIM1CLKSOURCE_PCLK;
|
||||
PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;
|
||||
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
|
||||
PeriphClkInit.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLLSAI1;
|
||||
@ -234,7 +240,7 @@ void SystemClock_Config(void)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/**Configure the main internal regulator output voltage
|
||||
/**Configure the main internal regulator output voltage
|
||||
*/
|
||||
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
|
||||
{
|
||||
@ -260,7 +266,7 @@ static void MX_ADC1_Init(void)
|
||||
/* USER CODE BEGIN ADC1_Init 1 */
|
||||
|
||||
/* USER CODE END ADC1_Init 1 */
|
||||
/**Common config
|
||||
/**Common config
|
||||
*/
|
||||
hadc1.Instance = ADC1;
|
||||
hadc1.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1;
|
||||
@ -281,14 +287,14 @@ static void MX_ADC1_Init(void)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/**Configure the ADC multi-mode
|
||||
/**Configure the ADC multi-mode
|
||||
*/
|
||||
multimode.Mode = ADC_MODE_INDEPENDENT;
|
||||
if (HAL_ADCEx_MultiModeConfigChannel(&hadc1, &multimode) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/**Configure Regular Channel
|
||||
/**Configure Regular Channel
|
||||
*/
|
||||
sConfig.Channel = ADC_CHANNEL_3;
|
||||
sConfig.Rank = ADC_REGULAR_RANK_1;
|
||||
@ -335,6 +341,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 LPUART1 Initialization Function
|
||||
* @param None
|
||||
@ -454,7 +494,7 @@ static void MX_RTC_Init(void)
|
||||
/* USER CODE BEGIN RTC_Init 1 */
|
||||
|
||||
/* USER CODE END RTC_Init 1 */
|
||||
/**Initialize RTC Only
|
||||
/**Initialize RTC Only
|
||||
*/
|
||||
hrtc.Instance = RTC;
|
||||
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
|
||||
@ -800,7 +840,7 @@ void Error_Handler(void)
|
||||
* @retval None
|
||||
*/
|
||||
void assert_failed(char *file, uint32_t line)
|
||||
{
|
||||
{
|
||||
/* USER CODE BEGIN 6 */
|
||||
/* User can add his own implementation to report the file name and line number,
|
||||
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
||||
|
@ -165,6 +165,53 @@ 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 UART MSP Initialization
|
||||
* This function configures the hardware resources used in this example
|
||||
@ -238,7 +285,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
|
||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||
|
@ -76,7 +76,7 @@
|
||||
/* USER CODE END EV */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||
/* Cortex-M4 Processor Interruption and Exception Handlers */
|
||||
/******************************************************************************/
|
||||
/**
|
||||
* @brief This function handles Non maskable interrupt.
|
||||
|
@ -80,3 +80,202 @@ void SystemClock_Config(void)
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef RT_USING_PM
|
||||
|
||||
void SystemClock_MSI_ON(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
|
||||
/* Initializes the CPU, AHB and APB busses clocks */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
|
||||
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
RT_ASSERT(0);
|
||||
}
|
||||
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void SystemClock_MSI_OFF(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
|
||||
RCC_OscInitStruct.HSIState = RCC_MSI_OFF;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; /* No update on PLL */
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void SystemClock_80M(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
|
||||
/**Initializes the CPU, AHB and APB busses clocks */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = 1;
|
||||
RCC_OscInitStruct.PLL.PLLN = 20;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
|
||||
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/**Initializes the CPU, AHB and APB busses clocks
|
||||
*/
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
|
||||
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void SystemClock_Config_fromSTOP(void)
|
||||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
uint32_t pFLatency = 0;
|
||||
|
||||
/* Get the Oscillators & PLL configuration according to the internal RCC registers */
|
||||
HAL_RCC_GetOscConfig(&RCC_OscInitStruct);
|
||||
|
||||
/* Wake up on HSI, re-enable MSI and PLL with MSI as source */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
|
||||
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
|
||||
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;
|
||||
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Get the Clocks configuration according to the internal RCC registers */
|
||||
HAL_RCC_GetClockConfig(&RCC_ClkInitStruct, &pFLatency);
|
||||
|
||||
/* Select PLL as system clock source */
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, pFLatency) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void SystemClock_24M(void)
|
||||
{
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct;
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct;
|
||||
|
||||
/** Initializes the CPU, AHB and APB busses clocks */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = 1;
|
||||
RCC_OscInitStruct.PLL.PLLN = 12;
|
||||
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
|
||||
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
|
||||
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
/** Initializes the CPU, AHB and APB busses clocks */
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
|
||||
| RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
void SystemClock_2M(void)
|
||||
{
|
||||
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||
|
||||
/* MSI is enabled after System reset, update MSI to 2Mhz (RCC_MSIRANGE_5) */
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
|
||||
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
|
||||
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
|
||||
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
Error_Handler();
|
||||
}
|
||||
|
||||
/* Select MSI as system clock source and configure the HCLK, PCLK1 and PCLK2
|
||||
clocks dividers */
|
||||
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK;
|
||||
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
|
||||
{
|
||||
/* Initialization Error */
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures system clock after wake-up from STOP: enable HSI, PLL
|
||||
* and select PLL as system clock source.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void SystemClock_ReConfig(uint8_t mode)
|
||||
{
|
||||
SystemClock_MSI_ON();
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case PM_RUN_MODE_HIGH_SPEED:
|
||||
case PM_RUN_MODE_NORMAL_SPEED:
|
||||
SystemClock_80M();
|
||||
break;
|
||||
case PM_RUN_MODE_MEDIUM_SPEED:
|
||||
SystemClock_24M();
|
||||
break;
|
||||
case PM_RUN_MODE_LOW_SPEED:
|
||||
SystemClock_2M();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// SystemClock_MSI_OFF();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -54,6 +54,17 @@ extern int __bss_end;
|
||||
|
||||
void SystemClock_Config(void);
|
||||
|
||||
#ifdef RT_USING_PM
|
||||
void SystemClock_Config(void);
|
||||
void SystemClock_MSI_ON(void);
|
||||
void SystemClock_MSI_OFF(void);
|
||||
void SystemClock_80M(void);
|
||||
void SystemClock_24M(void);
|
||||
void SystemClock_2M(void);
|
||||
void SystemClock_ReConfig(uint8_t mode);
|
||||
void SystemClock_Config_fromSTOP(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user