1////////////////////////////////////////////////////////////////////////////////////// 2// The MIT License (MIT) 3// 4// Submit Date: 03/09/2015 5// Author: Juan Jose Chong <juanjchong@gmail.com> 6// Copyright (c) 2015 Juan Jose Chong 7// 8////////////////////////////////////////////////////////////////////////////////////// 9// adis16448.cxx 10////////////////////////////////////////////////////////////////////////////////////// 11// 12// This example code runs on an Intel Edison and uses mraa to acquire data 13// from an ADIS16448. This data is then scaled and printed onto the terminal. 14// 15// This software has been tested to connect to an ADIS16448 through a level shifter 16// such as the TI TXB0104. The SPI lines (DIN, DOUT, SCLK, /CS) are all wired through 17// the level shifter and the ADIS16448 is also being powered by the Intel Edison. 18// 19// Permission is hereby granted, free of charge, to any person obtaining 20// a copy of this software and associated documentation files (the 21// "Software"), to deal in the Software without restriction, including 22// without limitation the rights to use, copy, modify, merge, publish, 23// distribute, sublicense, and/or sell copies of the Software, and to 24// permit persons to whom the Software is furnished to do so, subject to 25// the following conditions: 26// 27// The above copyright notice and this permission notice shall be 28// included in all copies or substantial portions of the Software. 29// 30// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 31// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 32// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 33// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 34// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 35// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 36// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 37// 38////////////////////////////////////////////////////////////////////////////////////// 39#include <unistd.h> 40#include <iostream> 41#include <signal.h> 42 43#include "adis16448.h" 44 45int 46main(int argc, char **argv) 47{ 48 while(true) 49 { 50 //! [Interesting] 51 upm::ADIS16448* imu = new upm::ADIS16448(0,3); //upm::ADIS16448(SPI,RST) 52 53 //Read the specified register, scale it, and display it on the screen 54 std::cout << "XGYRO_OUT:" << imu->gyroScale(imu->regRead(XGYRO_OUT)) << std::endl; 55 std::cout << "YGYRO_OUT:" << imu->gyroScale(imu->regRead(YGYRO_OUT)) << std::endl; 56 std::cout << "ZGYRO_OUT:" << imu->gyroScale(imu->regRead(ZGYRO_OUT)) << std::endl; 57 std::cout << " " << std::endl; 58 std::cout << "XACCL_OUT:" << imu->accelScale(imu->regRead(XACCL_OUT)) << std::endl; 59 std::cout << "YACCL_OUT:" << imu->accelScale(imu->regRead(YACCL_OUT)) << std::endl; 60 std::cout << "ZACCL_OUT:" << imu->accelScale(imu->regRead(ZACCL_OUT)) << std::endl; 61 std::cout << " " << std::endl; 62 //! [Interesting] 63 sleep(1); 64 } 65 return (0); 66} 67