mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
at42qt1070: 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
1eb9e7b9dc
commit
b8af35a797
@ -40,15 +40,16 @@ AT42QT1070::AT42QT1070(int bus, uint8_t address)
|
|||||||
|
|
||||||
// setup our i2c link
|
// setup our i2c link
|
||||||
if (!(m_i2c = mraa_i2c_init(bus))) {
|
if (!(m_i2c = mraa_i2c_init(bus))) {
|
||||||
cerr << __FUNCTION__ << ": mraa_i2c_init() failed." << endl;
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_i2c_init() failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t rv;
|
mraa_result_t rv;
|
||||||
|
|
||||||
if ((rv = mraa_i2c_address(m_i2c, m_addr)) != MRAA_SUCCESS) {
|
if ((rv = mraa_i2c_address(m_i2c, m_addr)) != MRAA_SUCCESS) {
|
||||||
cerr << __FUNCTION__ << ": Could not initialize i2c bus. " << endl;
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
mraa_result_print(rv);
|
": mraa_i2c_address() failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +73,8 @@ AT42QT1070::writeByte(uint8_t reg, uint8_t byte)
|
|||||||
mraa_result_t rv = mraa_i2c_write_byte_data(m_i2c, byte, reg);
|
mraa_result_t rv = mraa_i2c_write_byte_data(m_i2c, byte, reg);
|
||||||
|
|
||||||
if (rv != MRAA_SUCCESS) {
|
if (rv != MRAA_SUCCESS) {
|
||||||
cerr << __FUNCTION__ << ": mraa_i2c_write_byte() failed." << endl;
|
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||||
mraa_result_print(rv);
|
": mraa_i2c_write_byte() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +87,8 @@ AT42QT1070::writeWord(uint8_t reg, uint16_t word)
|
|||||||
mraa_result_t rv = mraa_i2c_write_word_data(m_i2c, word, reg);
|
mraa_result_t rv = mraa_i2c_write_word_data(m_i2c, word, reg);
|
||||||
|
|
||||||
if (rv != MRAA_SUCCESS) {
|
if (rv != MRAA_SUCCESS) {
|
||||||
cerr << __FUNCTION__ << ": mraa_i2c_write_word() failed." << endl;
|
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||||
mraa_result_print(rv);
|
": mraa_i2c_write_word() failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user