Skip to content

Commit e7a4558

Browse files
bors[bot]burrbull
andauthored
Merge #632
632: doc examples for write r=Emilgardis a=burrbull Related #478 Co-authored-by: Andrey Zgarbul <[email protected]>
2 parents ce233c4 + 3ffef74 commit e7a4558

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313
- Add new feature `feature_group` which will generate cfg attribute for
1414
every group name when it is on
1515
- Sort fields by offset before process
16-
- advanced comments
16+
- Updated docs for `write` / `modify`
1717

1818
## [v0.24.1] - 2022-07-04
1919

src/generate/generic.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ impl<REG: Resettable + Writable> Reg<REG> {
9999
/// .field3().variant(VARIANT)
100100
/// );
101101
/// ```
102+
/// or an alternative way of saying the same:
103+
/// ```ignore
104+
/// periph.reg.write(|w| {
105+
/// w.field1().bits(newfield1bits);
106+
/// w.field2().set_bit();
107+
/// w.field3().variant(VARIANT)
108+
/// });
109+
/// ```
102110
/// In the latter case, other fields will be set to their reset value.
103111
#[inline(always)]
104112
pub fn write<F>(&self, f: F)
@@ -154,6 +162,14 @@ impl<REG: Readable + Writable> Reg<REG> {
154162
/// .field3().variant(VARIANT)
155163
/// );
156164
/// ```
165+
/// or an alternative way of saying the same:
166+
/// ```ignore
167+
/// periph.reg.modify(|_, w| {
168+
/// w.field1().bits(newfield1bits);
169+
/// w.field2().set_bit();
170+
/// w.field3().variant(VARIANT)
171+
/// });
172+
/// ```
157173
/// Other fields will have the value they had before the call to `modify`.
158174
#[inline(always)]
159175
pub fn modify<F>(&self, f: F)

0 commit comments

Comments
 (0)