-
Notifications
You must be signed in to change notification settings - Fork 156
Add support for Access::WriteOnce
registers
#264
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
Conversation
Currently doesn't enforce the write-once nature of the registers, but treats them as write-only.
How is this WriteOnce property enforced? |
} else if fields.iter().all(|f| f.access == Some(Access::WriteOnly)) { | ||
} else if fields.iter().all(|f| f.access == Some(Access::WriteOnce)) { | ||
Access::WriteOnce | ||
} else if fields.iter().all(|f| f.access == Some(Access::WriteOnly) || f.access == Some(Access::WriteOnce)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this second f.access == Some(Access::WriteOnce)
comparison is redundant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This checks that all the fields are either WriteOnly
or WriteOnce
, instead of only WriteOnly
. A register that has both WriteOnly
and WriteOnce
fields is still WriteOnly
and not ReadWrite
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A register that has both
WriteOnly
andWriteOnce
fields is stillWriteOnly
and notReadWrite
.
Yes, but any register with both WriteOnly
and WriteOnce
will be processed by first WriteOnce
if
statement. The next if
statement will process just WriteOnly
registers. Or not?
It isn't, and I couldn't come up with a good way to enforce it on a type level :( |
Maybe |
bors try |
tryBuild failed |
322: Once r=therealprof a=burrbull r? @therealprof #264 was taken as base.  Co-authored-by: Hugo van der Wijst <[email protected]> Co-authored-by: Andrey Zgarbul <[email protected]>
Currently doesn't enforce the write-once nature of the registers, but
treats them as write-only.