add regmap package to facilitate heapless driver development#768
add regmap package to facilitate heapless driver development#768
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.