Без опису

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include "adis16448.h"
  43. int
  44. main(int argc, char **argv)
  45. {
  46. while(true)
  47. {
  48. //! [Interesting]
  49. upm::ADIS16448* imu = new upm::ADIS16448(0,3); //upm::ADIS16448(SPI,RST)
  50. //Read the specified register, scale it, and display it on the screen
  51. std::cout << "XGYRO_OUT:" << imu->gyroScale(imu->regRead(XGYRO_OUT)) << std::endl;
  52. std::cout << "YGYRO_OUT:" << imu->gyroScale(imu->regRead(YGYRO_OUT)) << std::endl;
  53. std::cout << "ZGYRO_OUT:" << imu->gyroScale(imu->regRead(ZGYRO_OUT)) << std::endl;
  54. std::cout << " " << std::endl;
  55. std::cout << "XACCL_OUT:" << imu->accelScale(imu->regRead(XACCL_OUT)) << std::endl;
  56. std::cout << "YACCL_OUT:" << imu->accelScale(imu->regRead(YACCL_OUT)) << std::endl;
  57. std::cout << "ZACCL_OUT:" << imu->accelScale(imu->regRead(ZACCL_OUT)) << std::endl;
  58. std::cout << " " << std::endl;
  59. //! [Interesting]
  60. sleep(1);
  61. }
  62. return (0);
  63. }