-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
163: Read action r=Emilgardis a=burrbull depends on #162 Co-authored-by: Andrey Zgarbul <zgarbul.andrey@gmail.com>
- Loading branch information
Showing
20 changed files
with
146 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use super::{Element, Encode, EncodeError, XMLNode}; | ||
|
||
impl Encode for crate::svd::ReadAction { | ||
type Error = EncodeError; | ||
|
||
fn encode(&self) -> Result<Element, EncodeError> { | ||
let mut elem = Element::new("readAction"); | ||
elem.children.push(XMLNode::Text(self.as_str().to_string())); | ||
Ok(elem) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use super::*; | ||
|
||
use crate::svd::ReadAction; | ||
impl Parse for ReadAction { | ||
type Object = Self; | ||
type Error = SVDErrorAt; | ||
type Config = Config; | ||
|
||
fn parse(tree: &Node, _config: &Self::Config) -> Result<Self, Self::Error> { | ||
let text = tree.get_text()?; | ||
|
||
Self::parse_str(text).ok_or_else(|| SVDError::InvalidReadAction(text.into()).at(tree.id())) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/// Specifies the side effect following a read operation | ||
#[cfg_attr( | ||
feature = "serde", | ||
derive(serde::Deserialize, serde::Serialize), | ||
serde(rename_all = "camelCase") | ||
)] | ||
#[derive(Clone, Copy, Debug, PartialEq)] | ||
pub enum ReadAction { | ||
/// The register/field is cleared (set to zero) following a read operation | ||
Clear, | ||
|
||
/// The register/field is set (set to ones) following a read operation | ||
Set, | ||
|
||
/// The register/field is modified in some way after a read operation | ||
Modify, | ||
|
||
/// One or more dependent resources other than the current register/field are immediately affected by a read operation | ||
ModifyExternal, | ||
} | ||
|
||
impl Default for ReadAction { | ||
fn default() -> Self { | ||
Self::Modify | ||
} | ||
} | ||
|
||
impl ReadAction { | ||
/// Parse a string into an [`ReadAction`] value, returning [`Option::None`] if the string is not valid. | ||
pub fn parse_str(s: &str) -> Option<Self> { | ||
use self::ReadAction::*; | ||
match s { | ||
"clear" => Some(Clear), | ||
"set" => Some(Set), | ||
"modify" => Some(Modify), | ||
"modifyExternal" => Some(ModifyExternal), | ||
_ => None, | ||
} | ||
} | ||
|
||
/// Convert this [`ReadAction`] into a static string. | ||
pub const fn as_str(self) -> &'static str { | ||
match self { | ||
Self::Clear => "clear", | ||
Self::Set => "set", | ||
Self::Modify => "modify", | ||
Self::ModifyExternal => "modifyExternal", | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters