-
Notifications
You must be signed in to change notification settings - Fork 229
add regmap package to facilitate heapless driver development #768
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
By transactional API I mean approach something more similar to how DBs handle actions, see BboltDB's Tx method on DB type. It really is a rather complex way of approaching this and would likely not be required for 99% of drivers, so I'd rather leave it to a future conversation. This current API is the most basic level of abstraction. We can add a dynamic buffer: type Dev struct {
buf []byte
}
func (d *Dev) tx(data []byte) error {
d.buf[0] = cmd
n := copy(d.buf[1:], data)
return d.bus.Tx(d.buf[:n+1], nil) // ...
} |
Merging this since it provides no external API change but could be leveraged by driver developers immediately. No risk, only benefit :) |
This PR was merged against |
@ysoldak @aykevl @deadprogram
Discussion in #766 made me consider adding this logic which is common to many 8 bit address width drivers. The name comes from "Register Mapped"
I've added only the functions which have a trivial heapless solution. The trivial implementation for WriteDataSPI and WriteDataI2C would require copy+additional buffer provided so I avoided it for now to see if we can think of a solution that maybe does not require the copy, i.e: transactional API.