Skip to content

Commit 78840f3

Browse files
committed
refactor: update STM32RTC interrupt callbacks and examples
Signed-off-by: Aymane Bahssain <aymane.bahssain@st.com>
1 parent eda2e0e commit 78840f3

5 files changed

Lines changed: 41 additions & 11 deletions

File tree

CMakeLists.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# v3.21 implemented semantic changes regarding $<TARGET_OBJECTS:...>
2+
# See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects
3+
cmake_minimum_required(VERSION 3.21)
4+
5+
add_library(STM32RTC INTERFACE)
6+
add_library(STM32RTC_usage INTERFACE)
7+
8+
target_include_directories(STM32RTC_usage INTERFACE
9+
src
10+
)
11+
12+
13+
target_link_libraries(STM32RTC_usage INTERFACE
14+
base_config
15+
)
16+
17+
target_link_libraries(STM32RTC INTERFACE STM32RTC_usage)
18+
19+
20+
21+
add_library(STM32RTC_bin OBJECT EXCLUDE_FROM_ALL
22+
src/rtc.c
23+
src/STM32RTC.cpp
24+
)
25+
target_link_libraries(STM32RTC_bin PUBLIC STM32RTC_usage)
26+
27+
target_link_libraries(STM32RTC INTERFACE
28+
STM32RTC_bin
29+
$<TARGET_OBJECTS:STM32RTC_bin>
30+
)
31+

examples/RTCReset/RTCReset.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static STM32RTC::AM_PM period = STM32RTC::AM;
5656
#define USER_BTN PA0
5757
#endif
5858

59-
static uint8_t conv2d(const char* p) {
59+
uint8_t conv2d(const char* p) {
6060
uint8_t v = 0;
6161
if ('0' <= *p && *p <= '9')
6262
v = *p - '0';

examples/RTC_Seconds/RTC_Seconds.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void loop()
100100
Serial.printf("%02d %02d %02d\n", hrs, mn, sec);
101101
}
102102
#if defined(LED_BUILTIN)
103-
digitalWrite(pin, toggling);
103+
digitalWrite(pin, (PinStatus)toggling);
104104
#endif /* LED_BUILTIN */
105105
delay(1000);
106106
}

src/STM32RTC.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ void STM32RTC::disableAlarm(Alarm name)
303303
* ALARM_A or ALARM_B if exists
304304
* @retval None
305305
*/
306-
void STM32RTC::attachInterrupt(voidFuncPtr callback, Alarm name)
306+
void STM32RTC::attachInterrupt(voidFuncPtrParam callback, Alarm name)
307307
{
308308
attachInterrupt(callback, nullptr, name);
309309
}
@@ -316,7 +316,7 @@ void STM32RTC::attachInterrupt(voidFuncPtr callback, Alarm name)
316316
* ALARM_A or ALARM_B if exists
317317
* @retval None
318318
*/
319-
void STM32RTC::attachInterrupt(voidFuncPtr callback, void *data, Alarm name)
319+
void STM32RTC::attachInterrupt(voidFuncPtrParam callback, void *data, Alarm name)
320320
{
321321
attachAlarmCallback(callback, data, static_cast<alarm_t>(name));
322322
}
@@ -338,7 +338,7 @@ void STM32RTC::detachInterrupt(Alarm name)
338338
* @param callback: pointer to the callback
339339
* @retval None
340340
*/
341-
void STM32RTC::attachSecondsInterrupt(voidFuncPtr callback)
341+
void STM32RTC::attachSecondsInterrupt(voidFuncPtrParam callback)
342342
{
343343
attachSecondsIrqCallback(callback);
344344
}
@@ -361,7 +361,7 @@ void STM32RTC::detachSecondsInterrupt(void)
361361
* @param callback: pointer to the callback
362362
* @retval None
363363
*/
364-
void STM32RTC::attachSubSecondsUnderflowInterrupt(voidFuncPtr callback)
364+
void STM32RTC::attachSubSecondsUnderflowInterrupt(voidFuncPtrParam callback)
365365
{
366366
attachSubSecondsUnderflowIrqCallback(callback);
367367
}

src/STM32RTC.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
|(STM32_RTC_VERSION_PATCH << 8U )\
6767
|(STM32_RTC_VERSION_EXTRA))
6868

69-
typedef void(*voidFuncPtr)(void *);
7069

7170
#if defined(RCC_RTC_WDG_BLEWKUP_CLKSOURCE_HSI64M_DIV2048) || defined(RCC_RTC_WDG_SUBG_LPAWUR_LCD_LCSC_CLKSOURCE_DIV512)
7271
#define IS_CLOCK_SOURCE(SRC) (((SRC) == STM32RTC::LSI_CLOCK) || ((SRC) == STM32RTC::LSE_CLOCK) ||\
@@ -158,19 +157,19 @@ class STM32RTC {
158157
void enableAlarm(Alarm_Match match, Alarm name = ALARM_A);
159158
void disableAlarm(Alarm name = ALARM_A);
160159

161-
void attachInterrupt(voidFuncPtr callback, Alarm name);
162-
void attachInterrupt(voidFuncPtr callback, void *data = nullptr, Alarm name = ALARM_A);
160+
void attachInterrupt(voidFuncPtrParam callback, Alarm name);
161+
void attachInterrupt(voidFuncPtrParam callback, void *data = nullptr, Alarm name = ALARM_A);
163162
void detachInterrupt(Alarm name = ALARM_A);
164163

165164
#ifdef ONESECOND_IRQn
166165
// Other mcu than stm32F1 will use the WakeUp feature to interrupt each second.
167-
void attachSecondsInterrupt(voidFuncPtr callback);
166+
void attachSecondsInterrupt(voidFuncPtrParam callback);
168167
void detachSecondsInterrupt(void);
169168

170169
#endif /* ONESECOND_IRQn */
171170
#ifdef STM32WLxx
172171
// STM32WLxx has a dedicated IRQ
173-
void attachSubSecondsUnderflowInterrupt(voidFuncPtr callback);
172+
void attachSubSecondsUnderflowInterrupt(voidFuncPtrParam callback);
174173
void detachSubSecondsUnderflowInterrupt(void);
175174
#endif /* STM32WLxx */
176175
// Kept for compatibility: use STM32LowPower library.

0 commit comments

Comments
 (0)