mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 01:10:22 +03:00
itg3200: 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
0af62a6992
commit
52274d8b10
@ -23,6 +23,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <stdexcept>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "itg3200.h"
|
#include "itg3200.h"
|
||||||
@ -64,7 +66,14 @@ using namespace upm;
|
|||||||
|
|
||||||
Itg3200::Itg3200(int bus) : m_i2c(bus)
|
Itg3200::Itg3200(int bus) : m_i2c(bus)
|
||||||
{
|
{
|
||||||
//reset chip
|
//init bus and reset chip
|
||||||
|
if ( !(m_i2c = mraa_i2c_init(bus)) )
|
||||||
|
{
|
||||||
|
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||||
|
": mraa_i2c_init() failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_i2c.address(ITG3200_I2C_ADDR);
|
m_i2c.address(ITG3200_I2C_ADDR);
|
||||||
m_buffer[0] = ITG3200_PWR_MGM;
|
m_buffer[0] = ITG3200_PWR_MGM;
|
||||||
m_buffer[1] = ITG3200_RESET;
|
m_buffer[1] = ITG3200_RESET;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user