rust-embedded / rust-embedded/svd2rust
Implement the ability to work with `W` outside of `write`
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 857
- Forks
- 164
- PR merge metrics
- No merged PRs in 30d
Description
I want for example instead of this
use stm32f1::stm32f103 as pac;
let periph = pac::Peripherals::take().unwrap();
let usart1 = periph.USART1;
// ...
usart1.cr1.write(|w| {
w.ue().enabled();
w.m().m9();
w.pce().enabled();
w.ps().even();
w.te().enabled();
w.tcie().enabled();
w.re().disabled(); // <- First write
w
});
// ...
usart1.cr1.write(|w| {
w.ue().enabled();
w.m().m9();
w.pce().enabled();
w.ps().even();
w.te().enabled();
w.tcie().enabled();
w.re().enabled(); // <- Modified
w
});
// ...
usart1.cr1.write(|w| {
w.ue().enabled();
w.m().m9();
w.pce().enabled();
w.ps().even();
w.te().enabled();
w.tcie().enabled();
w.re().disabled(); // <- Modified
w
});
to do so
use stm32f1::stm32f103 as pac;
let periph = pac::Peripherals::take().unwrap();
let usart1 = periph.USART1;
// ...
const USART_BASE_CFG: pac::usart1::cr1::W = pac::usart1::cr1::INITIAL_VALUE
.ue().enabled()
.m().m9()
.pce().enabled()
.ps().even()
.te().enabled()
.tcie().enabled()
.re().disabled();
// ...
usart1.cr1.write(USART_BASE_CFG);
// ...
usart1.cr1.write(USART_BASE_CFG.re().enabled());
// ...
usart1.cr1.write(USART_BASE_CFG.re().disabled());
Or for example like this
let mut w = pac::usart1::cr1::INITIAL_VALUE;
w = w
.ue().enabled()
.m().m9()
.pce().enabled()
.ps().even()
.te().enabled()
.tcie().enabled()
.re().disabled();
usart1.cr1.write(w);
Is it possible to change svd2rust to allow this?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue provides Rust examples of the desired register API, but names no file, test, or generator entry point. Trace the generated register writer API and its generator, then determine how reusable W values should behave outside write. Done means the examples can compile and the register behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100