From f5577c005e744fc0df7d13870339d73f4037067e Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Fri, 16 Nov 2018 14:32:32 +0100 Subject: [PATCH] STM32 RTC : skip rtc_write if possible --- targets/TARGET_STM/rtc_api.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/targets/TARGET_STM/rtc_api.c b/targets/TARGET_STM/rtc_api.c index 798ce29bb1..a4c45a9cdf 100644 --- a/targets/TARGET_STM/rtc_api.c +++ b/targets/TARGET_STM/rtc_api.c @@ -217,6 +217,11 @@ void rtc_write(time_t t) RTC_DateTypeDef dateStruct = {0}; RTC_TimeTypeDef timeStruct = {0}; + /* if the requested time is the current time, no need to continue */ + if (t == rtc_read()) { + return; + } + core_util_critical_section_enter(); RtcHandle.Instance = RTC;