2014-06-11 13:21:58 +00:00
|
|
|
/*
|
|
|
|
* Author: Yevgeniy Kiveisha <yevgeniy.kiveisha@intel.com>
|
|
|
|
* Copyright (c) 2014 Intel Corporation.
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2014-06-11 13:21:58 +00:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2014-06-11 13:21:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <signal.h>
|
2017-08-30 15:00:29 -07:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "mma7455.hpp"
|
|
|
|
#include "upm_utilities.h"
|
2014-06-11 13:21:58 +00:00
|
|
|
|
|
|
|
int doWork = 0;
|
|
|
|
|
|
|
|
void
|
|
|
|
sig_handler(int signo)
|
|
|
|
{
|
|
|
|
printf("got signal\n");
|
|
|
|
if (signo == SIGINT) {
|
|
|
|
printf("exiting application\n");
|
|
|
|
doWork = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2017-08-30 15:00:29 -07:00
|
|
|
main(int argc, char** argv)
|
2014-06-11 13:21:58 +00:00
|
|
|
{
|
|
|
|
//! [Interesting]
|
2017-08-30 15:00:29 -07:00
|
|
|
upm::MMA7455 sensor(0, ADDR);
|
|
|
|
|
2014-06-11 13:21:58 +00:00
|
|
|
short x, y, z;
|
|
|
|
while (!doWork) {
|
2017-08-30 15:00:29 -07:00
|
|
|
sensor.readData(&x, &y, &z);
|
2014-06-11 13:21:58 +00:00
|
|
|
std::cout << "Accelerometer X(" << x << ") Y(" << y << ") Z(" << z << ")" << std::endl;
|
2017-08-30 15:00:29 -07:00
|
|
|
upm_delay_us(100000);
|
2014-06-11 13:21:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! [Interesting]
|
|
|
|
|
|
|
|
std::cout << "exiting application" << std::endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|