robtillaart,
I like the idea of providing more diagnostic information. I included functions to get more info and in addition I wrote a "printInfo" routine.
I am not sure how helpful the messages are. Any suggestions?
The program prints these five items.
Last return status: <return status for last request, Success or Failure>
Transfer request size:
Bytes transfered:
Previous State:
Current State:
Here are some example messages:
After transfer(addRW, buf, 7) when no slave responds to a read request:
Last return status: Failure
Transfer request size: 7
Bytes transfered: 0
Previous State: 0X48, SLA+R has been transmitted and NACK received.
Curent State: 0X48, SLA+R has been transmitted and NACK received.
A transferContinue() call when the previous call ended with a stop condition:
Last return status: Failure
Transfer request size: 7
Bytes transfered: 0
Previous State: 0XF8, Stop condition.
Curent State: 0XF8, Stop condition.
A transferContinue() call when the previous call ended with a repeated start:
Last return status: Failure
Transfer request size: 7
Bytes transfered: 0
Previous State: 0X10, A Repeated START has been transmitted.
Curent State: 0X10, A Repeated START has been transmitted.
Here are example messages after successful transfer calls:
Last return status: Success
Transfer request size: 1
Bytes transfered: 1
Previous State: 0X28, Data byte has been transmitted and ACK received.
Curent State: 0X10, A Repeated START has been transmitted.
Last return status: Success
Transfer request size: 7
Bytes transfered: 7
Previous State: 0X58, Data byte has been received and NACK transmitted.
Curent State: 0XF8, Stop condition.