Skip to content

Commit 01b2b1b

Browse files
committed
STM32: RTC_LSI macro is replaced by lse_available config
1 parent 354ed44 commit 01b2b1b

File tree

3 files changed

+36
-52
lines changed

3 files changed

+36
-52
lines changed

targets/TARGET_STM/rtc_api.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ void rtc_init(void)
6262
return;
6363
}
6464

65-
#if !RTC_LSI /* => LSE */
66-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSE;
65+
#if MBED_CONF_TARGET_LSE_AVAILABLE
66+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_LSE;
6767
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
6868
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
6969
RCC_OscInitStruct.LSIState = RCC_LSI_OFF;
@@ -80,14 +80,13 @@ void rtc_init(void)
8080
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
8181
error("PeriphClkInitStruct RTC failed with LSE\n");
8282
}
83-
84-
#else /* => RTC_LSI */
83+
#else /* MBED_CONF_TARGET_LSE_AVAILABLE */
8584
// Reset Backup domain
8685
__HAL_RCC_BACKUPRESET_FORCE();
8786
__HAL_RCC_BACKUPRESET_RELEASE();
8887

8988
// Enable LSI clock
90-
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI;
89+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_LSE;
9190
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; // Mandatory, otherwise the PLL is reconfigured!
9291
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
9392
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
@@ -103,7 +102,7 @@ void rtc_init(void)
103102
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) {
104103
error("PeriphClkInitStruct RTC failed with LSI\n");
105104
}
106-
#endif /* !RTC_LSI */
105+
#endif /* MBED_CONF_TARGET_LSE_AVAILABLE */
107106

108107
// Enable RTC
109108
__HAL_RCC_RTC_ENABLE();
@@ -135,7 +134,7 @@ void rtc_init(void)
135134

136135
void rtc_free(void)
137136
{
138-
#if RTC_LSI
137+
#if !MBED_CONF_TARGET_LSE_AVAILABLE
139138
// Enable Power clock
140139
__HAL_RCC_PWR_CLK_ENABLE();
141140

targets/TARGET_STM/rtc_api_hal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
extern "C" {
4141
#endif
4242

43-
#if RTC_LSI
44-
#define RTC_CLOCK LSI_VALUE
45-
#else
43+
#if MBED_CONF_TARGET_LSE_AVAILABLE
4644
#define RTC_CLOCK LSE_VALUE
45+
#else
46+
#define RTC_CLOCK LSI_VALUE
4747
#endif
4848

4949
/** Read the subsecond register.

targets/targets.json

Lines changed: 27 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,12 @@
706706
"extra_labels": ["STM"],
707707
"supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"],
708708
"macros": ["TRANSACTION_QUEUE_SIZE_SPI=2"],
709+
"config": {
710+
"lse_available": {
711+
"help": "Define if a Low Speed External xtal (LSE) is available on the board (0 = No, 1 = Yes). If Yes, the LSE will be used to clock the RTC, LPUART, ... otherwise the Low Speed Internal clock (LSI) will be used",
712+
"value": "1"
713+
}
714+
},
709715
"device_has": ["ANALOGIN", "I2C", "I2CSLAVE", "I2C_ASYNCH", "INTERRUPTIN", "PORTIN", "PORTINOUT", "PORTOUT", "PWMOUT", "RTC", "SERIAL", "SLEEP", "SPI", "SPISLAVE", "SPI_ASYNCH", "STDIO_MESSAGES"]
710716
},
711717
"LPC54114": {
@@ -772,14 +778,10 @@
772778
"help": "Mask value : USE_PLL_HSE_EXTC (need HW patch) | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
773779
"value": "USE_PLL_HSI",
774780
"macro_name": "CLOCK_SOURCE"
775-
},
776-
"rtc_lsi": {
777-
"help": "Use internal low speed clock (default clock is LSE)",
778-
"value": "1",
779-
"macro_name": "RTC_LSI"
780-
}
781+
}
781782
},
782783
"detect_code": ["0791"],
784+
"overrides": {"lse_available": 0},
783785
"macros_add": ["CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""],
784786
"device_has_add": ["SERIAL_FC"],
785787
"default_lib": "small",
@@ -797,14 +799,10 @@
797799
"help": "Mask value : USE_PLL_HSE_EXTC (need HW patch) | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
798800
"value": "USE_PLL_HSI",
799801
"macro_name": "CLOCK_SOURCE"
800-
},
801-
"rtc_lsi": {
802-
"help": "Use internal low speed clock (default clock is LSE)",
803-
"value": "1",
804-
"macro_name": "RTC_LSI"
805-
}
802+
}
806803
},
807804
"detect_code": ["0785"],
805+
"overrides": {"lse_available": 0},
808806
"macros_add": ["CMSIS_VECTAB_VIRTUAL", "CMSIS_VECTAB_VIRTUAL_HEADER_FILE=\"cmsis_nvic.h\""],
809807
"device_has_add": ["CAN", "SERIAL_FC"],
810808
"default_lib": "small",
@@ -939,13 +937,9 @@
939937
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
940938
"value": "USE_PLL_HSI",
941939
"macro_name": "CLOCK_SOURCE"
942-
},
943-
"rtc_lsi": {
944-
"help": "Use internal low speed clock (default clock is LSE)",
945-
"value": "1",
946-
"macro_name": "RTC_LSI"
947-
}
940+
}
948941
},
942+
"overrides": {"lse_available": 0},
949943
"detect_code": ["0775"],
950944
"default_lib": "small",
951945
"device_has_add": ["ANALOGOUT", "CAN", "LOWPOWERTIMER", "SERIAL_FC"],
@@ -1493,7 +1487,7 @@
14931487
"inherits": ["FAMILY_STM32"],
14941488
"core": "Cortex-M4F",
14951489
"extra_labels_add": ["STM32F3", "STM32F303", "STM32F303xC", "STM32F303VC"],
1496-
"macros_add": ["RTC_LSI=1"],
1490+
"overrides": {"lse_available": 0},
14971491
"supported_toolchains": ["GCC_ARM"],
14981492
"device_has_add": ["ANALOGOUT", "CAN", "LOWPOWERTIMER", "SERIAL_FC"],
14991493
"device_name": "STM32F303VC"
@@ -1507,13 +1501,9 @@
15071501
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
15081502
"value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
15091503
"macro_name": "CLOCK_SOURCE"
1510-
},
1511-
"rtc_lsi": {
1512-
"help": "Use internal low speed clock (default clock is LSE)",
1513-
"value": "1",
1514-
"macro_name": "RTC_LSI"
1515-
}
1504+
}
15161505
},
1506+
"overrides": {"lse_available": 0},
15171507
"detect_code": ["0810"],
15181508
"device_has_add": ["ANALOGOUT", "LOWPOWERTIMER", "SERIAL_ASYNCH", "SERIAL_FC"],
15191509
"default_lib": "small",
@@ -1525,7 +1515,8 @@
15251515
"core": "Cortex-M4F",
15261516
"extra_labels_add": ["STM32F4", "STM32F407", "STM32F407xG", "STM32F407VG"],
15271517
"supported_toolchains": ["ARM", "uARM", "GCC_ARM"],
1528-
"macros_add": ["RTC_LSI=1", "USB_STM_HAL"],
1518+
"macros_add": ["USB_STM_HAL"],
1519+
"overrides": {"lse_available": 0},
15291520
"device_has_add": ["ANALOGOUT"],
15301521
"device_name": "STM32F407VG"
15311522
},
@@ -1543,13 +1534,9 @@
15431534
"help": "As 48 Mhz clock is configured for USB, SYSCLK has to be reduced from 180 to 168 MHz (set 0 for the max SYSCLK value)",
15441535
"value": "1",
15451536
"macro_name": "CLOCK_SOURCE_USB"
1546-
},
1547-
"rtc_lsi": {
1548-
"help": "Use internal low speed clock (default clock is LSE)",
1549-
"value": "1",
1550-
"macro_name": "RTC_LSI"
1551-
}
1537+
}
15521538
},
1539+
"overrides": {"lse_available": 0},
15531540
"macros_add": ["USB_STM_HAL", "USBHOST_OTHER"],
15541541
"device_has_add": ["ANALOGOUT", "CAN", "SERIAL_ASYNCH", "SERIAL_FC", "TRNG", "FLASH"],
15551542
"release_versions": ["2", "5"],
@@ -1583,13 +1570,9 @@
15831570
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
15841571
"value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
15851572
"macro_name": "CLOCK_SOURCE"
1586-
},
1587-
"rtc_lsi": {
1588-
"help": "Use internal low speed clock (default clock is LSE)",
1589-
"value": "1",
1590-
"macro_name": "RTC_LSI"
1591-
}
1573+
}
15921574
},
1575+
"overrides": {"lse_available": 0},
15931576
"device_has_add": ["ANALOGOUT", "LOWPOWERTIMER", "SERIAL_FC", "FLASH"],
15941577
"default_lib": "small",
15951578
"release_versions": ["2"],
@@ -1728,7 +1711,8 @@
17281711
"macro_name": "MODEM_ON_BOARD_UART"
17291712
}
17301713
},
1731-
"macros_add": ["HSE_VALUE=26000000", "VECT_TAB_OFFSET=0x08010000", "RTC_LSI=1"],
1714+
"overrides": {"lse_available": 0},
1715+
"macros_add": ["HSE_VALUE=26000000", "VECT_TAB_OFFSET=0x08010000"],
17321716
"post_binary_hook": {
17331717
"function": "MTSCode.combine_bins_mts_dragonfly",
17341718
"toolchains": ["GCC_ARM", "ARM_STD", "ARM_MICRO", "IAR"]
@@ -1764,7 +1748,7 @@
17641748
"core": "Cortex-M3",
17651749
"default_toolchain": "uARM",
17661750
"extra_labels_add": ["STM32L1", "STM32L152RC"],
1767-
"macros": ["RTC_LSI=1"],
1751+
"overrides": {"lse_available": 0},
17681752
"detect_code": ["4100"],
17691753
"device_has_add": ["ANALOGOUT"],
17701754
"default_lib": "small",
@@ -1848,7 +1832,8 @@
18481832
"macro_name": "MODEM_ON_BOARD_UART"
18491833
}
18501834
},
1851-
"macros_add": ["MBEDTLS_CONFIG_HW_SUPPORT", "RTC_LSI=1", "HSE_VALUE=12000000", "GNSSBAUD=9600"],
1835+
"macros_add": ["MBEDTLS_CONFIG_HW_SUPPORT", "HSE_VALUE=12000000", "GNSSBAUD=9600"],
1836+
"overrides": {"lse_available": 0},
18521837
"device_has_add": ["ANALOGOUT", "SERIAL_FC", "TRNG", "FLASH"],
18531838
"features": ["LWIP"],
18541839
"public": false,
@@ -1869,7 +1854,7 @@
18691854
"default_toolchain": "uARM",
18701855
"program_cycle_s": 1.5,
18711856
"extra_labels_add": ["STM32L1", "STM32L151RC"],
1872-
"macros": ["RTC_LSI=1"],
1857+
"overrides": {"lse_available": 0},
18731858
"supported_toolchains": ["ARM", "uARM", "GCC_ARM"],
18741859
"device_has_add": ["ANALOGOUT"],
18751860
"default_lib": "small",

0 commit comments

Comments
 (0)