mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
adc121c021: throw exception(s) on fatal errors
Signed-off-by: Jon Trulson <jtrulson@ics.com> Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
parent
0566b4f995
commit
b0ac4b5da2
@ -24,6 +24,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "adc121c021.h"
|
||||
|
||||
@ -35,13 +36,23 @@ ADC121C021::ADC121C021(int bus, uint8_t address, float vref)
|
||||
{
|
||||
// setup our i2c link
|
||||
m_i2c = mraa_i2c_init(bus);
|
||||
if ( !(m_i2c = mraa_i2c_init(bus)) )
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_init() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
m_addr = address;
|
||||
|
||||
mraa_result_t ret = mraa_i2c_address(m_i2c, m_addr);
|
||||
|
||||
if (ret != MRAA_SUCCESS)
|
||||
cerr << "ADC121C021: Could not initialize i2c bus. " << endl;
|
||||
if (ret != MRAA_SUCCESS)
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_address() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
m_vref = vref;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user