-
Notifications
You must be signed in to change notification settings - Fork 184
Write support for the Backup Data Register (BKP_DR, DR1, DR2, ...) #83
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
Comments
@mjepronk To enable access to specific registers you might want to add methods to https://github.com/stm32-rs/stm32f1xx-hal/blob/master/src/backup_domain.rs. |
Any ideas on how that should look like? Something like: let mut backup_domain = rcc.bkp.constrain(device.BKP, &mut rcc.apb1, &mut pwr);
let _ = backup_domain.dr1.read().bits();
backup_domain.dr1.write(|w| w.bits(42)); Or more something higher level? According to RM0008 there are 42 16-bit registers, so with the simple design we would add 42 methods to the |
I think I would prefer something more high level, perhaps |
I agree with @TheZoq2 either a function to set this block of registers with a function taking an index or potentially we could also think about an accessor yielding access to the whole block of data registers. |
I think giving the whole block of data registers might be difficult as we can't give out access to |
@TheZoq2 No, I just meant the data registers. |
I've collected backup data registers into 2 arrays. But they really are not arrays, because numbering starts from 1 and from 11. |
BKP will be:
|
OK, I've updated the PR again. I've checked-out your 'bkp' branch of the |
It's strange. Code looks good (except you should assert or |
Not all chips support second region. f100xx does not. Maybe yours same? I'm not sure where to see this. |
I'll add the You're right, from RM0008:
I have a blue/black pill (STM32F103C8T6), so mine has only the first 10 2-byte data registers... Should we handle this in the library? (i.e. error when using >DR10 on low- or medium-density devices) |
Maybe it makes sense to split read/write fns. And add density features to toml. |
* Adds support for reading and writing to the Backup Data Register (#83). * Removed `unsafe` blocks. * Added feature gate for high backup registers.
This is merged, thank you @therealprof, @TheZoq2, @burrbull! |
Currently, we can read from the Backup Data Register (for example DR1) using:
However, this will not be possible after calling
rcc.bkp.constrain
, because this function takes ownership ofdevice.BKP
:Writing to the BKP_DR register should normally be only possible after enabling the power and backup interface clocks and setting the DBP bit the Power Control Register (page 81 of the RM0008 reference manual), i.e. calling
rcc.bkp.constrain
.I'm not really sure how to fix this. I'm not familiar with
svd2rust
or any lower level code. I'm willing to help but I would for sure need some pointers...The text was updated successfully, but these errors were encountered: