Skip to content

Commit d28d13c

Browse files
authored
Merge pull request #7790 from jeromecoutant/PR_LPTICKER_RTC
STM32 LPTICKER : RTC wake up timer is reset before setting a new one
2 parents b373b13 + c8d628b commit d28d13c

File tree

3 files changed

+138
-7
lines changed

3 files changed

+138
-7
lines changed

targets/TARGET_STM/lp_ticker.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ uint32_t lp_ticker_read(void)
263263

264264
void lp_ticker_set_interrupt(timestamp_t timestamp)
265265
{
266+
lp_ticker_disable_interrupt();
266267
rtc_set_wake_up_timer(timestamp);
267268
}
268269

targets/TARGET_STM/rtc_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void rtc_write(time_t t)
270270

271271
#if DEVICE_LPTICKER && !MBED_CONF_TARGET_LPTICKER_LPTIM
272272
/* Need to update LP_continuous_time value before new RTC time */
273-
uint32_t current_lp_time = rtc_read_lp();
273+
rtc_read_lp();
274274

275275
/* LP_last_RTC_time value is updated with the new RTC time */
276276
LP_last_RTC_time = timeStruct.Seconds + timeStruct.Minutes * 60 + timeStruct.Hours * 60 * 60;

targets/targets.json

Lines changed: 136 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@
730730
"public": false,
731731
"extra_labels": ["STM"],
732732
"supported_toolchains": ["ARM", "uARM", "IAR", "GCC_ARM"],
733-
"macros": ["TRANSACTION_QUEUE_SIZE_SPI=2", "LPTICKER_DELAY_TICKS=3"],
733+
"macros": ["TRANSACTION_QUEUE_SIZE_SPI=2"],
734734
"config": {
735735
"lse_available": {
736736
"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",
@@ -874,6 +874,11 @@
874874
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
875875
"value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
876876
"macro_name": "CLOCK_SOURCE"
877+
},
878+
"lpticker_delay_ticks": {
879+
"help": "For targets with low frequency system clock, set lpticker_delay_ticks value to 1",
880+
"value": 1,
881+
"macro_name": "LPTICKER_DELAY_TICKS"
877882
}
878883
},
879884
"detect_code": ["0755"],
@@ -892,6 +897,11 @@
892897
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
893898
"value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
894899
"macro_name": "CLOCK_SOURCE"
900+
},
901+
"lpticker_delay_ticks": {
902+
"help": "For targets with low frequency system clock, set lpticker_delay_ticks value to 1",
903+
"value": 1,
904+
"macro_name": "LPTICKER_DELAY_TICKS"
895905
}
896906
},
897907
"detect_code": ["0730"],
@@ -910,6 +920,11 @@
910920
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
911921
"value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
912922
"macro_name": "CLOCK_SOURCE"
923+
},
924+
"lpticker_delay_ticks": {
925+
"help": "For targets with low frequency system clock, set lpticker_delay_ticks value to 1",
926+
"value": 1,
927+
"macro_name": "LPTICKER_DELAY_TICKS"
913928
}
914929
},
915930
"detect_code": ["0750"],
@@ -1107,6 +1122,11 @@
11071122
"lpticker_lptim": {
11081123
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
11091124
"value": 1
1125+
},
1126+
"lpticker_delay_ticks": {
1127+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1128+
"value": 3,
1129+
"macro_name": "LPTICKER_DELAY_TICKS"
11101130
}
11111131
},
11121132
"detect_code": ["0744"],
@@ -1231,6 +1251,11 @@
12311251
"lpticker_lptim": {
12321252
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
12331253
"value": 1
1254+
},
1255+
"lpticker_delay_ticks": {
1256+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1257+
"value": 3,
1258+
"macro_name": "LPTICKER_DELAY_TICKS"
12341259
}
12351260
},
12361261
"detect_code": ["0743"],
@@ -1253,6 +1278,11 @@
12531278
"lpticker_lptim": {
12541279
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
12551280
"value": 1
1281+
},
1282+
"lpticker_delay_ticks": {
1283+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1284+
"value": 3,
1285+
"macro_name": "LPTICKER_DELAY_TICKS"
12561286
}
12571287
},
12581288
"detect_code": ["0743"],
@@ -1403,12 +1433,17 @@
14031433
"lpticker_lptim": {
14041434
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
14051435
"value": 1
1436+
},
1437+
"lpticker_delay_ticks": {
1438+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1439+
"value": 3,
1440+
"macro_name": "LPTICKER_DELAY_TICKS"
14061441
}
14071442
},
14081443
"macros_add": ["USBHOST_OTHER"],
14091444
"supported_form_factors": ["ARDUINO"],
14101445
"detect_code": ["0816"],
1411-
"device_has_add": ["LPTICKER", "ANALOGOUT", "CAN", "CRC", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
1446+
"device_has_add": ["ANALOGOUT", "CAN", "CRC", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
14121447
"release_versions": ["2", "5"],
14131448
"device_name": "STM32F746ZG",
14141449
"bootloader_supported": true,
@@ -1434,12 +1469,17 @@
14341469
"lpticker_lptim": {
14351470
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
14361471
"value": 1
1472+
},
1473+
"lpticker_delay_ticks": {
1474+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1475+
"value": 3,
1476+
"macro_name": "LPTICKER_DELAY_TICKS"
14371477
}
14381478
},
14391479
"macros_add": ["TRANSACTION_QUEUE_SIZE_SPI=2", "USBHOST_OTHER", "MBEDTLS_CONFIG_HW_SUPPORT"],
14401480
"supported_form_factors": ["ARDUINO"],
14411481
"detect_code": ["0819"],
1442-
"device_has_add": ["LPTICKER", "ANALOGOUT", "CAN", "CRC", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
1482+
"device_has_add": ["ANALOGOUT", "CAN", "CRC", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
14431483
"release_versions": ["2", "5"],
14441484
"device_name": "STM32F756ZG",
14451485
"overrides": {
@@ -1468,12 +1508,17 @@
14681508
"lpticker_lptim": {
14691509
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
14701510
"value": 1
1511+
},
1512+
"lpticker_delay_ticks": {
1513+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1514+
"value": 3,
1515+
"macro_name": "LPTICKER_DELAY_TICKS"
14711516
}
14721517
},
14731518
"supported_form_factors": ["ARDUINO"],
14741519
"macros_add": ["USBHOST_OTHER"],
14751520
"detect_code": ["0818"],
1476-
"device_has_add": ["LPTICKER", "ANALOGOUT", "CAN", "CRC", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
1521+
"device_has_add": ["ANALOGOUT", "CAN", "CRC", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
14771522
"release_versions": ["2", "5"],
14781523
"device_name": "STM32F767ZI",
14791524
"bootloader_supported": true,
@@ -1497,6 +1542,11 @@
14971542
"lpticker_lptim": {
14981543
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
14991544
"value": 1
1545+
},
1546+
"lpticker_delay_ticks": {
1547+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1548+
"value": 3,
1549+
"macro_name": "LPTICKER_DELAY_TICKS"
15001550
}
15011551
},
15021552
"detect_code": ["0780"],
@@ -1520,6 +1570,11 @@
15201570
"lpticker_lptim": {
15211571
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
15221572
"value": 1
1573+
},
1574+
"lpticker_delay_ticks": {
1575+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1576+
"value": 3,
1577+
"macro_name": "LPTICKER_DELAY_TICKS"
15231578
}
15241579
},
15251580
"detect_code": ["0790"],
@@ -1542,6 +1597,11 @@
15421597
"lpticker_lptim": {
15431598
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
15441599
"value": 1
1600+
},
1601+
"lpticker_delay_ticks": {
1602+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1603+
"value": 3,
1604+
"macro_name": "LPTICKER_DELAY_TICKS"
15451605
}
15461606
},
15471607
"detect_code": ["0715"],
@@ -1564,6 +1624,11 @@
15641624
"lpticker_lptim": {
15651625
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
15661626
"value": 1
1627+
},
1628+
"lpticker_delay_ticks": {
1629+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1630+
"value": 3,
1631+
"macro_name": "LPTICKER_DELAY_TICKS"
15671632
}
15681633
},
15691634
"detect_code": ["0760"],
@@ -1581,6 +1646,11 @@
15811646
"help": "Mask value : USE_PLL_HSE_EXTC | USE_PLL_HSE_XTAL (need HW patch) | USE_PLL_HSI",
15821647
"value": "USE_PLL_HSE_EXTC|USE_PLL_HSI",
15831648
"macro_name": "CLOCK_SOURCE"
1649+
},
1650+
"lpticker_delay_ticks": {
1651+
"help": "For targets with low frequency system clock, set lpticker_delay_ticks value to 1",
1652+
"value": 1,
1653+
"macro_name": "LPTICKER_DELAY_TICKS"
15841654
}
15851655
},
15861656
"detect_code": ["0710"],
@@ -1602,6 +1672,11 @@
16021672
"lpticker_lptim": {
16031673
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
16041674
"value": 1
1675+
},
1676+
"lpticker_delay_ticks": {
1677+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1678+
"value": 3,
1679+
"macro_name": "LPTICKER_DELAY_TICKS"
16051680
}
16061681
},
16071682
"detect_code": ["0770"],
@@ -1624,6 +1699,11 @@
16241699
"lpticker_lptim": {
16251700
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
16261701
"value": 1
1702+
},
1703+
"lpticker_delay_ticks": {
1704+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1705+
"value": 3,
1706+
"macro_name": "LPTICKER_DELAY_TICKS"
16271707
}
16281708
},
16291709
"detect_code": ["0779"],
@@ -1667,6 +1747,11 @@
16671747
"lpticker_lptim": {
16681748
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
16691749
"value": 1
1750+
},
1751+
"lpticker_delay_ticks": {
1752+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1753+
"value": 3,
1754+
"macro_name": "LPTICKER_DELAY_TICKS"
16701755
}
16711756
},
16721757
"detect_code": ["0765"],
@@ -1708,6 +1793,11 @@
17081793
"lpticker_lptim": {
17091794
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
17101795
"value": 1
1796+
},
1797+
"lpticker_delay_ticks": {
1798+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
1799+
"value": 3,
1800+
"macro_name": "LPTICKER_DELAY_TICKS"
17111801
}
17121802
},
17131803
"detect_code": ["0827"],
@@ -1915,6 +2005,11 @@
19152005
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
19162006
"value": 1
19172007

2008+
},
2009+
"lpticker_delay_ticks": {
2010+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
2011+
"value": 3,
2012+
"macro_name": "LPTICKER_DELAY_TICKS"
19182013
}
19192014
},
19202015
"overrides": {"lse_available": 0},
@@ -1937,6 +2032,11 @@
19372032
"lpticker_lptim": {
19382033
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
19392034
"value": 1
2035+
},
2036+
"lpticker_delay_ticks": {
2037+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
2038+
"value": 3,
2039+
"macro_name": "LPTICKER_DELAY_TICKS"
19402040
}
19412041
},
19422042
"detect_code": ["0833"],
@@ -1972,11 +2072,16 @@
19722072
"lpticker_lptim": {
19732073
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
19742074
"value": 1
2075+
},
2076+
"lpticker_delay_ticks": {
2077+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
2078+
"value": 3,
2079+
"macro_name": "LPTICKER_DELAY_TICKS"
19752080
}
19762081
},
19772082
"detect_code": ["0815"],
19782083
"macros_add": ["USB_STM_HAL", "USBHOST_OTHER"],
1979-
"device_has_add": ["LPTICKER", "ANALOGOUT", "CAN", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
2084+
"device_has_add": ["ANALOGOUT", "CAN", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
19802085
"release_versions": ["2", "5"],
19812086
"device_name": "STM32F746NG",
19822087
"overrides": {
@@ -2001,11 +2106,16 @@
20012106
"lpticker_lptim": {
20022107
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
20032108
"value": 1
2109+
},
2110+
"lpticker_delay_ticks": {
2111+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
2112+
"value": 3,
2113+
"macro_name": "LPTICKER_DELAY_TICKS"
20042114
}
20052115
},
20062116
"detect_code": ["0817"],
20072117
"macros_add": ["USB_STM_HAL", "USBHOST_OTHER"],
2008-
"device_has_add": ["LPTICKER", "ANALOGOUT", "CAN", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
2118+
"device_has_add": ["ANALOGOUT", "CAN", "EMAC", "SERIAL_ASYNCH", "TRNG", "FLASH"],
20092119
"release_versions": ["2", "5"],
20102120
"device_name": "STM32F769NI",
20112121
"overrides": {
@@ -2025,6 +2135,11 @@
20252135
"lpticker_lptim": {
20262136
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
20272137
"value": 1
2138+
},
2139+
"lpticker_delay_ticks": {
2140+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
2141+
"value": 3,
2142+
"macro_name": "LPTICKER_DELAY_TICKS"
20282143
}
20292144
},
20302145
"supported_form_factors": ["ARDUINO"],
@@ -2048,6 +2163,11 @@
20482163
"lpticker_lptim": {
20492164
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
20502165
"value": 1
2166+
},
2167+
"lpticker_delay_ticks": {
2168+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
2169+
"value": 3,
2170+
"macro_name": "LPTICKER_DELAY_TICKS"
20512171
}
20522172
},
20532173
"detect_code": ["0820"],
@@ -4135,6 +4255,11 @@
41354255
"lpticker_lptim": {
41364256
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
41374257
"value": 1
4258+
},
4259+
"lpticker_delay_ticks": {
4260+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
4261+
"value": 3,
4262+
"macro_name": "LPTICKER_DELAY_TICKS"
41384263
}
41394264
},
41404265
"detect_code": ["0822"],
@@ -4156,6 +4281,11 @@
41564281
"lpticker_lptim": {
41574282
"help": "This target supports LPTIM. Set value 1 to use LPTIM for LPTICKER, or 0 to use RTC wakeup timer",
41584283
"value": 1
4284+
},
4285+
"lpticker_delay_ticks": {
4286+
"help": "In case of lpticker_lptim=1, set lpticker_delay_ticks=3",
4287+
"value": 3,
4288+
"macro_name": "LPTICKER_DELAY_TICKS"
41594289
}
41604290
},
41614291
"detect_code": ["0823"],

0 commit comments

Comments
 (0)