-
Notifications
You must be signed in to change notification settings - Fork 1.2k
WIP - Added backup sram #4663
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
base: main
Are you sure you want to change the base?
WIP - Added backup sram #4663
Conversation
nice! a few tips:
|
Thanks! Something like this? embassy-rs/stm32-data#671
Fair enough :) |
// Enable backup regulator for peristent battery backed sram | ||
#[cfg(rcc_h5)] | ||
crate::pac::PWR.bdcr().modify(|w| w.set_bren(self.backup_ram_retention)); | ||
|
||
#[cfg(rcc_h5)] | ||
if self.backup_ram_retention == Retention::PRESERVED { | ||
// Wait for backup regulator voltage to stabilize | ||
while !crate::pac::PWR.bdsr().read().brrdy() {} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want this in this file or should it be in backup_sram.rs?
Also, related question, I think it would be nice to let the user know if the retention was already enabled(SRAM contains data since last run) or if not. I think that would probably be easier if this was done as part of backup_sram::init()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think it would be nice to let the user know if the retention was already enabled
Done using WAS_BKPSRAM_ALREADY_POWERED_BY_BATTERY
8d23b09
to
5f8ee70
Compare
|
||
if has_bkpsram { | ||
singletons.push("BKPSRAM".to_string()); | ||
cfgs.declare("backup_sram"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I doing this wrong? The #[cfg(backup_sram)]
in embassy-stm32/src/lib.rs does not seem to activate even if I remove the if has_bkpsram
check here.
I will try to test in the near future. In the mean time, what do you think of this now? |
I do not have any experience with the structure of embassy-stm32, its build script, linker script etc. Hopefully at the very least this can serve as something to discuss around for how to actually solve something like this :)
With that said, here is the beginning of my attempt at adding support for the battery backed sram available for several of the stm32 families.