mirror of
https://github.com/eclipse/upm.git
synced 2025-07-02 09:51:14 +03:00
This is a combination of 2 commits.
aio: mraa_aio_read (v1.0.0) can now return -1, treat that in sensors using it Adds alot of exceptions if the aio read goes wrong Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com> Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:

committed by
Noel Eck

parent
f6816797bb
commit
e51c5f3018
@ -79,12 +79,20 @@ mraa_result_t ADC121C021::writeWord(uint8_t reg, uint16_t word)
|
||||
|
||||
uint8_t ADC121C021::readByte(uint8_t reg)
|
||||
{
|
||||
return mraa_i2c_read_byte_data(m_i2c, reg);
|
||||
int val = mraa_i2c_read_byte_data(m_i2c, reg);
|
||||
if (val != -1) {
|
||||
return (uint8_t) val;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint16_t ADC121C021::readWord(uint8_t reg)
|
||||
{
|
||||
uint16_t val = mraa_i2c_read_word_data(m_i2c, reg);
|
||||
int x = mraa_i2c_read_word_data(m_i2c, reg);
|
||||
if (x == -1) {
|
||||
return 0;
|
||||
}
|
||||
uint16_t val = (uint16_t) x;
|
||||
uint8_t b1;
|
||||
|
||||
// The value returned is in the wrong byte order, so we need to swap them
|
||||
|
Reference in New Issue
Block a user