We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
It is often the case that interfacing with things like GPIO, spin locks, clocks etc have lists of registers that all share a given type.
Definitions often have a starting offset, stride between each indexable register, and a count of those registers.
This could be achieved without needing a macro to know what the type is by just allowing construction via an encapsulating type:
public struct RegisterList<Value> where Value: RegisterValue { let unsafeAddress: UInt let startOffset: UInt let stride: UInt let count: Int public init(unsafeAddress: UInt, startOffset: UInt, stride: UInt, count: Int) { self.unsafeAddress = unsafeAddress self.startOffset = startOffset self.stride = stride self.count = count } public subscript(index: Int) -> Register<Value> { precondition(index >= 0 && index < count) let addr = unsafeAddress + UInt(index) * stride + startOffset return Register(unsafeAddress: addr) } }
The text was updated successfully, but these errors were encountered:
This is absolutely something we should support; at the register bank level I think this should be as simple as making the following code compile:
@RegisterArray(offset:stride:count:) var gpio: RegisterArray<GPIO>
Sorry, something went wrong.
WIP on register-array
register-array
5c59b5e
No branches or pull requests
It is often the case that interfacing with things like GPIO, spin locks, clocks etc have lists of registers that all share a given type.
Definitions often have a starting offset, stride between each indexable register, and a count of those registers.
This could be achieved without needing a macro to know what the type is by just allowing construction via an encapsulating type:
The text was updated successfully, but these errors were encountered: