we really need set_retries() high during init for nearly all i2c
devices, and as many are written against the generic device class
moving it to the Device class makes this a lot easier. It is a NOP on
SPI.
this allows a bus connection and device type tuple to be identifed as
a 24 bit number for use in user visible device IDs. Every bus
connection has a unique device ID.
Replace the previous not-implemented interface with a set of new methods
that can be resonably implemented:
- register_periodic_callback() now receives a functor returning bool
to easily allow "oneshot" timers
- adjust_periodic_callback() allows the caller to change the timer
for a specific handle. This way drivers like MS5611 can adjust the
timer depending on its state machine: the time to sample
temperature is smaller than the time to get a pressure sample
- add unregister_callback(): since we have an opaque pointer, we
can't tell the user to just delete it in order to unregister the
callback
Many of our SPI and I2C sensors define the protocol of setting the most
significant bit of the register address in order to perform a read operation.
Thus, enable the use of a "read flag" that is ORed with the register's address.
Since this is an abstraction for general devices, it's a good idea to have zero
as the default value for that flag.
While at it, add documentation to read_registers().