iio_core: Patches for IIO core kernel standard

Applying patches from Kuan Loon Lay.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2016-06-30 14:54:46 -07:00
parent 634208e3dc
commit e1df8b5bf6
9 changed files with 52 additions and 37 deletions

11
examples/c++/kxcjk1013.cxx Executable file → Normal file
View File

@ -1,6 +1,6 @@
/*
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -22,8 +22,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <iomanip>
#include <unistd.h>
#include <signal.h>
#include "kxcjk1013.hpp"
@ -44,7 +45,8 @@ data_callback(char* data)
{
float x, y, z;
accelerometer->extract3Axis(data, &x, &y, &z);
printf("% .1f % .1f % .1f\n", x, y, z);
cout << fixed << setprecision(1);
cout << x << '\t' << y << '\t' << z << "[m/s^2]" << endl;
}
int
@ -54,7 +56,10 @@ main()
//! [Interesting]
// Instantiate a KXCJK1013 Accelerometer Sensor on iio device 0
accelerometer = new upm::KXCJK1013(0);
// Available scales are 0.009582(2g), 0.019163(4g), and 0.038326(8g)
accelerometer->setScale(0.019163);
// Available sampling frequency are 0.781000, 1.563000, 3.125000, 6.250000, 12.500000, 25, 50,
// 100, 200, 400, 800, and 1600
accelerometer->setSamplingFrequency(25.0);
accelerometer->enable3AxisChannel();
accelerometer->installISR(data_callback, NULL);

View File

@ -1,6 +1,6 @@
/*
* Author: Lay, Kuan Loon <kuan.loon.lay@intel.com>
* Copyright (c) 2015 Intel Corporation.
* Copyright (c) 2016 Intel Corporation.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@ -22,8 +22,9 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <unistd.h>
#include <iostream>
#include <iomanip>
#include <unistd.h>
#include <signal.h>
#include "l3gd20.hpp"
@ -43,8 +44,10 @@ void
data_callback(char* data)
{
float x, y, z;
if (gyroscope->extract3Axis(data, &x, &y, &z))
printf("% .2f % .2f % .2f\n", x, y, z);
if (gyroscope->extract3Axis(data, &x, &y, &z)) {
cout << fixed << setprecision(1);
cout << x << '\t' << y << '\t' << z << "[rad/sec]" << endl;
}
}
int
@ -54,7 +57,9 @@ main()
//! [Interesting]
// Instantiate a L3GD20 Gyroscope Sensor on iio device 3
gyroscope = new upm::L3GD20(3);
// Available scales are 0.000153(250dps), 0.000305(500dps), and 0.001222(2000dps)
gyroscope->setScale(0.001222);
// Available sampling frequency are 95, 190, 380, and 760
gyroscope->setSamplingFrequency(95.0);
gyroscope->enable3AxisChannel();
gyroscope->installISR(data_callback, NULL);