Skip to content

Commit 9b7890d

Browse files
committed
add a seconds interrupt feature for the stm32 MCUs
A callback function is attached for this interrupt The same callback is referenced whatever the device (stm32F1 or other stm32 soc) Signed-off-by: Francois Ramu <francois.ramu@st.com>
1 parent fac8ab6 commit 9b7890d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/STM32RTC.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,27 @@ void STM32RTC::detachInterrupt(void)
249249
detachAlarmCallback();
250250
}
251251

252+
#ifdef ONESECOND_IRQn
253+
/**
254+
* @brief attach a callback to the RTC Seconds interrupt.
255+
* @param callback: pointer to the callback
256+
* @retval None
257+
*/
258+
void STM32RTC::attachSecondsInterrupt(voidFuncPtr callback)
259+
{
260+
attachSecondsIrqCallback(callback);
261+
}
262+
263+
/**
264+
* @brief detach the RTC Seconds callback.
265+
* @retval None
266+
*/
267+
void STM32RTC::detachSecondsInterrupt(void)
268+
{
269+
detachSecondsIrqCallback();
270+
}
271+
272+
#endif /* ONESECOND_IRQn */
252273
// Kept for compatibility. Use STM32LowPower library.
253274
void STM32RTC::standbyMode(void)
254275
{

src/STM32RTC.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ class STM32RTC {
125125
void attachInterrupt(voidFuncPtr callback, void *data = nullptr);
126126
void detachInterrupt(void);
127127

128+
#ifdef ONESECOND_IRQn
129+
// Other mcu than stm32F1 will use the WakeUp feature to interrupt each second.
130+
void attachSecondsInterrupt(voidFuncPtr callback);
131+
void detachSecondsInterrupt(void);
132+
133+
#endif /* ONESECOND_IRQn */
128134
// Kept for compatibility: use STM32LowPower library.
129135
void standbyMode();
130136

0 commit comments

Comments
 (0)