mirror of
https://github.com/eclipse/upm.git
synced 2025-06-10 07:10:22 +03:00
max44000: 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
d0d89b579d
commit
ab20e34c59
@ -23,6 +23,8 @@
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -36,9 +38,17 @@ MAX44000::MAX44000 (int bus, int devAddr) : m_i2cMaxControlCtx(bus) {
|
||||
m_maxControlAddr = devAddr;
|
||||
m_bus = bus;
|
||||
|
||||
if ( !(m_i2cMaxControlCtx = mraa_i2c_init(m_bus)) )
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_init() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
mraa::Result ret = m_i2cMaxControlCtx.address(m_maxControlAddr);
|
||||
if (ret != mraa::SUCCESS) {
|
||||
fprintf(stderr, "Messed up i2c bus\n");
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_i2c_address() failed");
|
||||
}
|
||||
|
||||
// i2cWriteReg (MCR, 0x2C);
|
||||
|
Loading…
x
Reference in New Issue
Block a user