Skip to content

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

@fumoboy007

Description

@fumoboy007

(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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    mmioRelated to the MMIO library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions