stm32duino / STM32RTC

Arduino RTC library for STM32.
127 stars 48 forks source link

implement a One-Second interrupt on stm32 MCUs #57

Closed FRASTM closed 2 years ago

FRASTM commented 2 years ago

This Enhancement is adding a interrupt on each second for the stm32xx MCUs

for the stm32F1 : the RTC One-Second flag interrupt is asserted on each RTC Core 1Hz clock cycle for other MCUS the RTC WakeUP feature is programmed to interrupt each second depending on the stm32 serie, this interrupt channel is a global or a specific one. In the the stm32F0xx serie, other than STM32F071xB, STM32F072xB, STM32F078xx, STM32F091xC, STM32F098xx, STM32F070xB, STM32F030xC do not support the WakeUp capability.

A simple example _RTCSeconds demonstrating the feature with a basic callback function that toggle a bit each second This test is passed on stm32F1 (nucleo f103rb), stm32G4 (nucleo g474re), stm32L4 (nucleo l476rg), stm32WB (nucleo wb55rg), stm32L1 (nucleo l152re), stm32F7 (nucleo 144 f767zi)

This PR is inspired by the https://github.com/stm32duino/STM32RTC/pull/42

Signed-off-by: Francois Ramu francois.ramu@st.com

FRASTM commented 2 years ago

The stm32 MCUs have different name/ position for the wakeUp interrupt to be used as the one-second interrupt ; defining single ONESECOND_IRQn depending on the soc serie

FRASTM commented 2 years ago

The stm32 MCUs have different name/ position for the wakeUp interrupt to be used as the one-second interrupt ; defining single ONESECOND_IRQn depending on the soc serie Adapt for stm32 mcus with "Wakeup auto-reload output clear value" where the HAL_RTCEx_SetWakeUpTimer_IT differs.

FRASTM commented 2 years ago

Note that STM32F030x4/6, STM32F070x6 and STM32F030x8 devices do not have WakeUp feature in their RTC and only one Alarm

FRASTM commented 2 years ago

Ada a #errorwhen a device which does not support the feature, is choosen for the sketch or driver

FRASTM commented 2 years ago

rebase Raise a compilation error on the sketch when the feature is not supported on the MCU

FRASTM commented 2 years ago

The code added for this feature is under #ifdef ONESECOND_IRQn In the attachSecondsIrqCallback, the ONESECOND_IRQn is enabled In the detachSecondsIrqCallback, the except for the stm32F1, the ONESECOND_IRQn is not disabled. becasue it could be used elsewhere. The callback is reset though.

FRASTM commented 2 years ago

updates the README.md