Skip to content

Commit 9e9ea56

Browse files
bors[bot]burrbull
andauthored
Merge #605
605: read action r=Emilgardis a=burrbull r? `@Emilgardis` Co-authored-by: Andrey Zgarbul <[email protected]>
2 parents f0b4e55 + 8668f55 commit 9e9ea56

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
- Use generic `FieldWriter`, `FieldReader`, `BitWriter`, `BitReader`
1111
- Disable two clippy warnings in `array_proxy.rs`
12+
- Add comments in docs about `readAction`
1213

1314
## [v0.23.1] - 2022-04-29
1415

src/generate/register.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::svd::{
2-
Access, BitRange, DeriveFrom, EnumeratedValues, Field, Peripheral, Register,
2+
Access, BitRange, DeriveFrom, EnumeratedValues, Field, Peripheral, ReadAction, Register,
33
RegisterProperties, Usage, WriteConstraint,
44
};
55
use cast::u64;
@@ -217,6 +217,18 @@ pub fn render(
217217
)
218218
.as_str();
219219
}
220+
221+
if can_read {
222+
if let Some(action) = register.read_action {
223+
doc += match action {
224+
ReadAction::Clear => "\n\nThe register is **cleared** (set to zero) following a read operation.",
225+
ReadAction::Set => "\n\nThe register is **set** (set to ones) following a read operation.",
226+
ReadAction::Modify => "\n\nThe register is **modified** in some way after a read operation.",
227+
ReadAction::ModifyExternal => "\n\nOne or more dependent resources other than the current register are immediately affected by a read operation.",
228+
};
229+
}
230+
}
231+
220232
let alias_doc = format!(
221233
"{} register accessor: an alias for `Reg<{}>`",
222234
name, name_uc_spec,
@@ -379,7 +391,7 @@ pub fn fields(
379391
};
380392

381393
if can_read {
382-
let readerdoc = if let Some((_, _, _, _, suffixes_str)) = &field_dim {
394+
let mut readerdoc = if let Some((_, _, _, _, suffixes_str)) = &field_dim {
383395
format!(
384396
"Fields `{}` reader - {}",
385397
util::replace_suffix(&f.name, suffixes_str),
@@ -388,6 +400,14 @@ pub fn fields(
388400
} else {
389401
format!("Field `{}` reader - {}", f.name, description)
390402
};
403+
if let Some(action) = f.read_action {
404+
readerdoc += match action {
405+
ReadAction::Clear => "\n\nThe field is **cleared** (set to zero) following a read operation.",
406+
ReadAction::Set => "\n\nThe field is **set** (set to ones) following a read operation.",
407+
ReadAction::Modify => "\n\nThe field is **modified** in some way after a read operation.",
408+
ReadAction::ModifyExternal => "\n\nOne or more dependent resources other than the current field are immediately affected by a read operation.",
409+
};
410+
}
391411

392412
let name_pc_r = Ident::new(&(name_pc.clone() + "_R"), span);
393413

0 commit comments

Comments
 (0)