From fbbc0de6fb576536e9b63a0c20452a64f1eb111c Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Wed, 9 Sep 2015 12:06:39 -0600 Subject: [PATCH] ttp223: throw exception(s) on fatal errors Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- src/ttp223/ttp223.cxx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ttp223/ttp223.cxx b/src/ttp223/ttp223.cxx index a5928f18..307f6d3a 100644 --- a/src/ttp223/ttp223.cxx +++ b/src/ttp223/ttp223.cxx @@ -22,14 +22,21 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include +#include + #include "ttp223.h" using namespace upm; TTP223::TTP223(unsigned int pin) { // initialize gpio input - mraa_init(); - m_gpio = mraa_gpio_init(pin); + if ( !(m_gpio = mraa_gpio_init(pin)) ) + { + throw std::invalid_argument(std::string(__FUNCTION__) + + ": mraa_gpio_init() failed, invalid pin?"); + return; + } mraa_gpio_dir(m_gpio, MRAA_GPIO_IN); m_name = "ttp223"; }