Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32: LSE DRIVE feature update #13939

Merged
merged 1 commit into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32F0/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "stm32f0xx_ll_tim.h"
#include "stm32f0xx_ll_pwr.h"
#include "stm32f0xx_ll_crc.h"
#include "stm32f0xx_ll_rcc.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32F3/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include "stm32f3xx_ll_pwr.h"
#include "stm32f3xx_ll_adc.h"
#include "stm32f3xx_ll_rtc.h"
#include "stm32f3xx_ll_rcc.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32F4/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "stm32f4xx_ll_pwr.h"
#include "stm32f4xx_ll_adc.h"
#include "stm32f4xx_ll_rtc.h"
#include "stm32f4xx_ll_rcc.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32F7/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "stm32f7xx_ll_adc.h"
#include "stm32f7xx_ll_rtc.h"
#include "stm32f7xx_ll_pwr.h"
#include "stm32f7xx_ll_rcc.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32G4/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "stm32g4xx_ll_tim.h"
#include "stm32g4xx_ll_pwr.h"
#include "stm32g4xx_ll_rtc.h"
#include "stm32g4xx_ll_rcc.h"

#ifdef __cplusplus
extern "C" {
Expand Down
2 changes: 1 addition & 1 deletion targets/TARGET_STM/TARGET_STM32H7/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
#include "stm32h7xx_ll_usart.h"
#include "stm32h7xx_ll_rtc.h"
#include "stm32h7xx_ll_tim.h"
#include "stm32h7xx_ll_rcc.h"
#if defined(DUAL_CORE)
#include "stm32h7xx_ll_hsem.h"
#include "stm32h7xx_ll_rcc.h"
#include "stm32h7xx_ll_cortex.h"
#endif /* CONFIG_STM32H7_DUAL_CORE */
#include "stm32h7xx_ll_pwr.h"
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32L0/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "stm32l0xx_ll_usart.h"
#include "stm32l0xx_ll_tim.h"
#include "stm32l0xx_ll_pwr.h"
#include "stm32l0xx_ll_rcc.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32L4/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "stm32l4xx_ll_tim.h"
#include "stm32l4xx_ll_rtc.h"
#include "stm32l4xx_ll_pwr.h"
#include "stm32l4xx_ll_rcc.h"

#ifdef __cplusplus
extern "C" {
Expand Down
1 change: 1 addition & 0 deletions targets/TARGET_STM/TARGET_STM32L5/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "stm32l5xx_ll_tim.h"
#include "stm32l5xx_ll_rtc.h"
#include "stm32l5xx_ll_pwr.h"
#include "stm32l5xx_ll_rcc.h"

#ifdef __cplusplus
extern "C" {
Expand Down
29 changes: 11 additions & 18 deletions targets/TARGET_STM/mbed_overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extern void SetSysClock(void);
# if defined(MBED_CONF_TARGET_LSE_DRIVE_LOAD_LEVEL)
# define LSE_DRIVE_LOAD_LEVEL MBED_CONF_TARGET_LSE_DRIVE_LOAD_LEVEL
# else
# if defined(RCC_LSE_HIGHDRIVE_MODE)
# if defined(RCC_LSE_HIGHDRIVE_MODE) // STM32F4
# define LSE_DRIVE_LOAD_LEVEL RCC_LSE_LOWPOWER_MODE
# else
# define LSE_DRIVE_LOAD_LEVEL RCC_LSEDRIVE_LOW
Expand Down Expand Up @@ -70,17 +70,6 @@ extern void SetSysClock(void);
*/

static void LSEDriveConfig(void) {
// this config can be changed only when LSE is stopped
// LSE could be enabled before a reset and will remain running, disable first
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
error("LSEDriveConfig : failed to disable LSE\n");
}

// set LSE drive level. Exception only for F4_g2 series
HAL_PWR_EnableBkUpAccess();
#if defined(__HAL_RCC_LSEDRIVE_CONFIG)
__HAL_RCC_LSEDRIVE_CONFIG(LSE_DRIVE_LOAD_LEVEL);
Expand Down Expand Up @@ -180,9 +169,10 @@ void mbed_sdk_init()
/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
#if defined(LSE_CONFIG_AVAILABLE)
// LSE maybe used later, but crystal load drive setting is necessary before
// enabling LSE
LSEDriveConfig();
// LSE oscillator drive capability set before LSE is started
if (!LL_RCC_LSE_IsReady()) {
LSEDriveConfig();
}
#endif
SetSysClock();
SystemCoreClockUpdate();
Expand All @@ -199,16 +189,19 @@ void mbed_sdk_init()
/* wait until CPU2 wakes up from stop mode */
while (LL_RCC_D2CK_IsReady() == 0);
#endif /* CORE_M4 */

#else /* Single core */
// Update the SystemCoreClock variable.
SystemCoreClockUpdate();
HAL_Init();

/* Configure the System clock source, PLL Multiplier and Divider factors,
AHB/APBx prescalers and Flash settings */
#if defined(LSE_CONFIG_AVAILABLE)
LSEDriveConfig();
// LSE oscillator drive capability set before LSE is started
if (!LL_RCC_LSE_IsReady()) {
LSEDriveConfig();
}
#endif

SetSysClock();
SystemCoreClockUpdate();
#endif /* DUAL_CORE */
Expand Down
30 changes: 10 additions & 20 deletions targets/targets.json
Original file line number Diff line number Diff line change
Expand Up @@ -1201,8 +1201,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"macros_add": [
Expand Down Expand Up @@ -1415,8 +1414,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"device_has_add": [
Expand Down Expand Up @@ -2178,8 +2176,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"overrides": {
Expand Down Expand Up @@ -2426,8 +2423,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"extra_labels_add": [
Expand Down Expand Up @@ -2534,8 +2530,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"extra_labels_add": [
Expand Down Expand Up @@ -2702,8 +2697,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"components_add": [
Expand Down Expand Up @@ -2970,8 +2964,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"macros_add": [
Expand Down Expand Up @@ -3208,8 +3201,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"macros_add": [
Expand Down Expand Up @@ -3744,8 +3736,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"overrides": {
Expand Down Expand Up @@ -3848,8 +3839,7 @@
},
"lse_drive_load_level": {
"help": "HSE drive load level RCC_LSEDRIVE_LOW | RCC_LSEDRIVE_MEDIUMLOW | RCC_LSEDRIVE_MEDIUMHIGH | RCC_LSEDRIVE_HIGH",
"value": "RCC_LSEDRIVE_LOW",
"macro_name": "TARGET_LSE_DRIVE_LOAD_LEVEL"
"value": "RCC_LSEDRIVE_LOW"
}
},
"macros_add": [
Expand Down