Hello,
I need as straightforward an explanation as possible concerning what to expect re: the ADS1015 protocol. In particular when reading from and writing to the conversion and/or threshold registers.
A little context, I believe I am comprehending the pointer register aspect of it easy enough.
What I am struggling a bit with (pardon the pun) is: word-to-byte-endianness of the 16-bit config, conversion, and threshold registers. Additionally, do I still need to take a twos complement?
So if I have something like this, forgiving the shorthand. It's also later than it needs to be where I am, but I need/want to get this addressed ASAP. Assuming I have already written to the pointer register as part of a ADS1015 transaction:
#include <linux/swab.h>
u16 config_;
//...setup the config...
i2c_write_word_swapped(addr_, __swab16(config));
And to read:
__s32 status;
u16 value_ = 0;
//Would be better to do error checking, but I just need the basic guidance right now...
if ((status = i2c_read_word_swapped(addr_)) >= 0)
value_ = static_cast<u16>(status);
value_ = __swab16(value_);
Something like this?
I found some kernel code as well which might shed some light on it as well.
Regards,
Michael Powell