diff --git a/src/max31855/max31855.cxx b/src/max31855/max31855.cxx index 072b6653..3037aaf3 100644 --- a/src/max31855/max31855.cxx +++ b/src/max31855/max31855.cxx @@ -23,6 +23,8 @@ */ #include +#include +#include #include #include #include @@ -36,7 +38,12 @@ using namespace upm; MAX31855::MAX31855(int bus, int cs) { // initialise chip select as a normal gpio - m_gpio = mraa_gpio_init(cs); + if ( !(m_gpio = mraa_gpio_init(cs)) ) + { + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_gpio_init(cs) failed, invalid pin?"); + return; + } mraa_gpio_dir(m_gpio, MRAA_GPIO_OUT); // initialise the spi bus with a 2Mhz clock