List of changes in no particular order.
twsi_transfer and twsi_intr are now protected with the mutex to
ensure a consistent view of the state.
msleep is paired with wakeup.
All wakeup calls are consolidtaed.
The control register is written exactly once in response to hardware events.
The hardware executes a next stage of I2C protocol when the interrupt flag is cleared,
so it is much easier to reason about what happens when with a single write to
the control register.
Improved diagnostic messages and code formatting.
Support for diagnostic messages is always compiled in
with the actual printing controlled via a sysctl (disabled by default).
I2C is not super-fast protocols, so having a bunch of extra condition checks
should not hurt the performance.
Also, debug messages in register access functions require a higher debug level
as their information is mostly redundant.
Support for more transfer combinations and types.
Examples:
- zero length transfers (start-address-stop),
- a write message with NO_STOP followed by another write message,
- a read message with NO_STOP flag followed by a write message (with implied repeated start)
Somewhat better code structure to handle conditions like end of message,
end of all messages.
Detect and handle more unexpected conditions.
Always send STOP when any error (or unexpected condition) is detected.
Ensure that TWSI_CONTROL_ACK is always correctly or cleared depending on
how many octets we expect to receive.
Add KASSERT-s to ensure that the code correctly follows octet counts and
never tries to write or read beyond message data buffers.