Skip to content
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

Add RawRepresentable conformance to the generated Read and Write structs #70

Open
fumoboy007 opened this issue Jan 14, 2024 · 0 comments
Labels
mmio Related to the MMIO library

Comments

@fumoboy007
Copy link

(I originally proposed this change here.)


The raw value of the register can be read/written to by accessing the .raw.storage property like so:

cr1.modify { cr1 in
  cr1.raw.storage |= (1 & CR1.RST.bitMask) << CR1.RST.bitOffset
}

This seems similar to the rawValue property of the RawRepresentable protocol. Instead of .raw.storage, perhaps the generated Read/Write structs could conform to RawRepresentable. It probably doesn’t make a functional difference but it might reduce the ramp-up time for developers who are new to the package.

cr1.modify { cr1 in
  cr1.rawValue |= (1 & CR1.RST.bitMask) << CR1.RST.bitOffset
}

(There was a concern about the optionality of the init(rawValue:) initializer; however, a non-optional initializer can satisfy an optional initializer protocol requirement.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mmio Related to the MMIO library
Projects
None yet
Development

No branches or pull requests

2 participants