Skip to content

embassy-stm32: split rtc low-power wakeup and time functions #4191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomhampshire
Copy link

Ref: #4110

The current rtc::Rtc struct combines low-power wakeup management and application-level time access (now(), set_datetime()). This creates an ownership conflict when embassy_stm32::low_power::stop_with_rtc requires exclusive control of the Rtc instance, preventing the application from simultaneously accessing time functions.

Changes to existing API have been minimised.

@tomhampshire
Copy link
Author

Submitted for initial review - I don't yet have the hardware to test if the device is entering low-power states, so this still needs testing

@tomhampshire
Copy link
Author

Example usage. The only change is the update to the configs (RtcConfig is now used as part of the global init) :

let mut config = embassy_stm32::Config::default();
let rtc_config = embassy_stm32::rtc::RtcConfig::default();
config.rtc = Some(rtc_config);
let p = embassy_stm32::init(config);

let rtc = embassy_stm32::rtc::Rtc::new(p.RTC);

@tomhampshire
Copy link
Author

I have made an assumption that, if no RtcConfig is specified, the Rtc isn't configured. The other option is, if no RtcConfig is specified, the default config is used...

@@ -283,6 +286,7 @@ impl Default for Config {
fn default() -> Self {
Self {
rcc: Default::default(),
rtc: None,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dirbaio should we have the default behaviour be this (no RTC setup) or use the RtcConfig defaults?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant