mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
max5487: remove custom exception and use standard ones
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
c878283c44
commit
2e0efd6690
@ -25,18 +25,12 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "max5487.h"
|
||||
|
||||
using namespace upm;
|
||||
|
||||
struct MAX5487Exception : public std::exception {
|
||||
std::string message;
|
||||
MAX5487Exception (std::string msg) : message (msg) { }
|
||||
~MAX5487Exception () throw () { }
|
||||
const char* what() const throw () { return message.c_str(); }
|
||||
};
|
||||
|
||||
MAX5487::MAX5487 (int csn) {
|
||||
mraa_result_t error = MRAA_SUCCESS;
|
||||
m_name = "MAX5487";
|
||||
@ -45,18 +39,21 @@ MAX5487::MAX5487 (int csn) {
|
||||
if (csn != -1) {
|
||||
m_csnPinCtx = mraa_gpio_init (csn);
|
||||
if (m_csnPinCtx == NULL) {
|
||||
throw MAX5487Exception ("GPIO failed to initilize");
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_gpio_init() failed");
|
||||
}
|
||||
|
||||
error = mraa_gpio_dir (m_csnPinCtx, MRAA_GPIO_OUT);
|
||||
if (error != MRAA_SUCCESS) {
|
||||
throw MAX5487Exception ("GPIO failed to initilize");
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_gpio_dir() failed");
|
||||
}
|
||||
}
|
||||
|
||||
m_spi = mraa_spi_init (0);
|
||||
if (m_spi == NULL) {
|
||||
throw MAX5487Exception ("SPI failed to initilize");
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_spi_init() failed");
|
||||
}
|
||||
|
||||
CSOff ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user