Skip to content

read action #605

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

Merged
merged 1 commit into from
May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

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

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

Expand Down
24 changes: 22 additions & 2 deletions src/generate/register.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::svd::{
Access, BitRange, DeriveFrom, EnumeratedValues, Field, Peripheral, Register,
Access, BitRange, DeriveFrom, EnumeratedValues, Field, Peripheral, ReadAction, Register,
RegisterProperties, Usage, WriteConstraint,
};
use cast::u64;
Expand Down Expand Up @@ -217,6 +217,18 @@ pub fn render(
)
.as_str();
}

if can_read {
if let Some(action) = register.read_action {
doc += match action {
ReadAction::Clear => "\n\nThe register is **cleared** (set to zero) following a read operation.",
ReadAction::Set => "\n\nThe register is **set** (set to ones) following a read operation.",
ReadAction::Modify => "\n\nThe register is **modified** in some way after a read operation.",
ReadAction::ModifyExternal => "\n\nOne or more dependent resources other than the current register are immediately affected by a read operation.",
};
}
}

let alias_doc = format!(
"{} register accessor: an alias for `Reg<{}>`",
name, name_uc_spec,
Expand Down Expand Up @@ -379,7 +391,7 @@ pub fn fields(
};

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

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

Expand Down