From 809b882d4725f519b2bf0cd2d468e258ccc808aa Mon Sep 17 00:00:00 2001 From: Aymane Bahssain Date: Wed, 28 Jan 2026 11:26:08 +0100 Subject: [PATCH 1/6] refactor: update STM32RTC interrupt callbacks for ArduinoCore-API integration Signed-off-by: Aymane Bahssain --- src/STM32RTC.cpp | 8 ++++---- src/STM32RTC.h | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/STM32RTC.cpp b/src/STM32RTC.cpp index 2e27064..05edd58 100644 --- a/src/STM32RTC.cpp +++ b/src/STM32RTC.cpp @@ -303,7 +303,7 @@ void STM32RTC::disableAlarm(Alarm name) * ALARM_A or ALARM_B if exists * @retval None */ -void STM32RTC::attachInterrupt(voidFuncPtr callback, Alarm name) +void STM32RTC::attachInterrupt(voidFuncPtrParam callback, Alarm name) { attachInterrupt(callback, nullptr, name); } @@ -316,7 +316,7 @@ void STM32RTC::attachInterrupt(voidFuncPtr callback, Alarm name) * ALARM_A or ALARM_B if exists * @retval None */ -void STM32RTC::attachInterrupt(voidFuncPtr callback, void *data, Alarm name) +void STM32RTC::attachInterrupt(voidFuncPtrParam callback, void *data, Alarm name) { attachAlarmCallback(callback, data, static_cast(name)); } @@ -338,7 +338,7 @@ void STM32RTC::detachInterrupt(Alarm name) * @param callback: pointer to the callback * @retval None */ -void STM32RTC::attachSecondsInterrupt(voidFuncPtr callback) +void STM32RTC::attachSecondsInterrupt(voidFuncPtrParam callback) { attachSecondsIrqCallback(callback); } @@ -361,7 +361,7 @@ void STM32RTC::detachSecondsInterrupt(void) * @param callback: pointer to the callback * @retval None */ -void STM32RTC::attachSubSecondsUnderflowInterrupt(voidFuncPtr callback) +void STM32RTC::attachSubSecondsUnderflowInterrupt(voidFuncPtrParam callback) { attachSubSecondsUnderflowIrqCallback(callback); } diff --git a/src/STM32RTC.h b/src/STM32RTC.h index 421af56..e9df1fa 100644 --- a/src/STM32RTC.h +++ b/src/STM32RTC.h @@ -66,7 +66,6 @@ |(STM32_RTC_VERSION_PATCH << 8U )\ |(STM32_RTC_VERSION_EXTRA)) -typedef void(*voidFuncPtr)(void *); #if defined(RCC_RTC_WDG_BLEWKUP_CLKSOURCE_HSI64M_DIV2048) || defined(RCC_RTC_WDG_SUBG_LPAWUR_LCD_LCSC_CLKSOURCE_DIV512) #define IS_CLOCK_SOURCE(SRC) (((SRC) == STM32RTC::LSI_CLOCK) || ((SRC) == STM32RTC::LSE_CLOCK) ||\ @@ -158,19 +157,19 @@ class STM32RTC { void enableAlarm(Alarm_Match match, Alarm name = ALARM_A); void disableAlarm(Alarm name = ALARM_A); - void attachInterrupt(voidFuncPtr callback, Alarm name); - void attachInterrupt(voidFuncPtr callback, void *data = nullptr, Alarm name = ALARM_A); + void attachInterrupt(voidFuncPtrParam callback, Alarm name); + void attachInterrupt(voidFuncPtrParam callback, void *data = nullptr, Alarm name = ALARM_A); void detachInterrupt(Alarm name = ALARM_A); #ifdef ONESECOND_IRQn // Other mcu than stm32F1 will use the WakeUp feature to interrupt each second. - void attachSecondsInterrupt(voidFuncPtr callback); + void attachSecondsInterrupt(voidFuncPtrParam callback); void detachSecondsInterrupt(void); #endif /* ONESECOND_IRQn */ #ifdef STM32WLxx // STM32WLxx has a dedicated IRQ - void attachSubSecondsUnderflowInterrupt(voidFuncPtr callback); + void attachSubSecondsUnderflowInterrupt(voidFuncPtrParam callback); void detachSubSecondsUnderflowInterrupt(void); #endif /* STM32WLxx */ // Kept for compatibility: use STM32LowPower library. From bb0f555843b8cb476db729c3296ca2336931986a Mon Sep 17 00:00:00 2001 From: Aymane Bahssain Date: Thu, 29 Jan 2026 10:46:55 +0100 Subject: [PATCH 2/6] fix: adapt RTC examples for ArduinoCore-API integration Signed-off-by: Aymane Bahssain --- examples/RTC_Seconds/RTC_Seconds.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/RTC_Seconds/RTC_Seconds.ino b/examples/RTC_Seconds/RTC_Seconds.ino index 90517cc..c5fbe2d 100644 --- a/examples/RTC_Seconds/RTC_Seconds.ino +++ b/examples/RTC_Seconds/RTC_Seconds.ino @@ -46,7 +46,7 @@ const byte day = 25; const byte month = 11; const byte year = 21; -bool toggling = false; // changed each second by the CallBack function +PinStatus toggling = LOW; // changed each second by the CallBack function static STM32RTC::Hour_Format hourFormat = STM32RTC::HOUR_24; static STM32RTC::AM_PM period = STM32RTC::AM; @@ -109,5 +109,5 @@ void loop() void rtc_SecondsCB(void *data) { UNUSED(data); - toggling = !toggling; + toggling = (toggling == LOW) ? HIGH : LOW; } From 664059ef7a6a0121d769f73157669109df0706ea Mon Sep 17 00:00:00 2001 From: Aymane Bahssain Date: Thu, 29 Jan 2026 10:47:06 +0100 Subject: [PATCH 3/6] chore: add CMake support Signed-off-by: Aymane Bahssain --- CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..f4dd79e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,31 @@ +# v3.21 implemented semantic changes regarding $ +# See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects +cmake_minimum_required(VERSION 3.21) + +add_library(STM32RTC INTERFACE) +add_library(STM32RTC_usage INTERFACE) + +target_include_directories(STM32RTC_usage INTERFACE + src +) + + +target_link_libraries(STM32RTC_usage INTERFACE + base_config +) + +target_link_libraries(STM32RTC INTERFACE STM32RTC_usage) + + + +add_library(STM32RTC_bin OBJECT EXCLUDE_FROM_ALL + src/rtc.c + src/STM32RTC.cpp +) +target_link_libraries(STM32RTC_bin PUBLIC STM32RTC_usage) + +target_link_libraries(STM32RTC INTERFACE + STM32RTC_bin + $ +) + From 1f89f407781c2cf3b8fadd31f15cb5bd5ed3959a Mon Sep 17 00:00:00 2001 From: Aymane Bahssain Date: Wed, 28 Jan 2026 11:31:00 +0100 Subject: [PATCH 4/6] ci: ensure submodules are checked out during CI workflow Signed-off-by: Aymane Bahssain --- .github/workflows/Continuous-Integration.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/Continuous-Integration.yml b/.github/workflows/Continuous-Integration.yml index abee14e..b13c72c 100644 --- a/.github/workflows/Continuous-Integration.yml +++ b/.github/workflows/Continuous-Integration.yml @@ -22,6 +22,8 @@ jobs: # First of all, clone the repo using the checkout action. - name: Checkout uses: actions/checkout@main + with: + submodules: true - name: Compilation id: Compile From a1bb85ca7161280b5d23a66c8fa666c3ece92f74 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 23 Apr 2026 16:23:36 +0200 Subject: [PATCH 5/6] chore: ensure stm32 core version is higher than 2.12.0 Signed-off-by: Frederic Pillon --- src/STM32RTC.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/STM32RTC.h b/src/STM32RTC.h index e9df1fa..d3d9755 100644 --- a/src/STM32RTC.h +++ b/src/STM32RTC.h @@ -38,7 +38,7 @@ #define __STM32_RTC_H #include "Arduino.h" -#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION < 0x02000000) +#if defined(STM32_CORE_VERSION) && (STM32_CORE_VERSION <= 0x020C0000) #error "This library is not compatible with core version used. Please update the core." #endif #include "rtc.h" From 1e1b16c25dc7dd5bdf6d8d3714657b7ca15977f1 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Thu, 23 Apr 2026 16:23:58 +0200 Subject: [PATCH 6/6] chore: bump STM32_RTC_VERSION to 2.0.0 Signed-off-by: Frederic Pillon --- README.md | 5 ++++- library.json | 2 +- library.properties | 2 +- src/STM32RTC.h | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bbcc584..b4eb45f 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,10 @@ A RTC library for STM32. ## Requirement -* [Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32) version >= 1.3.0 + * Library version 1.x.x: + * [Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32) version >= 1.3.0 + * Library version 2.x.x: + * [Arduino_Core_STM32](https://github.com/stm32duino/Arduino_Core_STM32) version 3.x.x # API diff --git a/library.json b/library.json index 4f3fc5d..230bd66 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/stm32duino/STM32RTC" }, - "version": "1.9.0", + "version": "2.0.0", "frameworks": "arduino", "platforms": "ststm32", "build": { diff --git a/library.properties b/library.properties index ffb84b4..b71a03e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=STM32duino RTC -version=1.9.0 +version=2.0.0 author=STMicroelectronics maintainer=stm32duino sentence=Allows to use the RTC functionalities of STM32 based boards. diff --git a/src/STM32RTC.h b/src/STM32RTC.h index d3d9755..d6ae77c 100644 --- a/src/STM32RTC.h +++ b/src/STM32RTC.h @@ -51,8 +51,8 @@ /** * @brief STM32 RTC library version number */ -#define STM32_RTC_VERSION_MAJOR (0x01U) /*!< [31:24] major version */ -#define STM32_RTC_VERSION_MINOR (0x04U) /*!< [23:16] minor version */ +#define STM32_RTC_VERSION_MAJOR (0x02U) /*!< [31:24] major version */ +#define STM32_RTC_VERSION_MINOR (0x00U) /*!< [23:16] minor version */ #define STM32_RTC_VERSION_PATCH (0x00U) /*!< [15:8] patch version */ /* * Extra label for development: