kxtj3: A few last-minute changes to the kxtj3 src

* Removed trailing whitespace
    * Fixed a few spelling errors
    * Switched to upm_delay_us for C source

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck 2018-06-21 10:33:38 -07:00
parent 186bbfab76
commit 3e84b74bdf
7 changed files with 60 additions and 59 deletions

View File

@ -26,22 +26,22 @@ public class KXTJ3_Example {
public static void main(String[] args) throws InterruptedException {
upm_kxtj3.KXTJ3 kxtj3 = new upm_kxtj3.KXTJ3();
upm_kxtj3.KXTJ3 kxtj3 = new upm_kxtj3.KXTJ3(0);
kxtj3.SensorInit(upm_kxtj3.KXTJ3_ODR_T.KXTJ3_ODR_25,
upm_kxtj3.KXTJ3_RESOLUTION_T.HIGH_RES,
kxtj3.SensorInit(upm_kxtj3.KXTJ3_ODR_T.KXTJ3_ODR_25,
upm_kxtj3.KXTJ3_RESOLUTION_T.HIGH_RES,
upm_kxtj3.KXTJ3_G_RANGE_T.KXTJ3_RANGE_16G_14);
float waitTime = kxtj3.GetAccelerationSamplePeriod() * 1000;
int sampleCounter = 10;
System.out.println("Setting settings:\nODR: 25 Hz\nResolution: " +
"High\nAcceleration range: 16g with 14bits");
System.out.println("Acceleration");
upm_kxtj3.floatVector xyz;
int sampleCounter = 10;
System.out.println("Setting settings:\nODR: 25 Hz\nResolution: " +
"High\nAcceleration range: 16g with 14bits");
System.out.println("Acceleration");
upm_kxtj3.floatVector xyz;
while (sampleCounter-- > 0) {
xyz = kxtj3.GetAccelerationVector();
System.out.println("x = " + xyz.get(0) + " y = " + xyz.get(1) +
" z = " + xyz.get(2));
System.out.println("x = " + xyz.get(0) + " y = " + xyz.get(1) +
" z = " + xyz.get(2));
Thread.sleep((long) waitTime);
}

View File

@ -35,7 +35,7 @@ var waitTime = kxtj3_sensor.GetAccelerationSamplePeriod();
var counter = 10;
console.log("Setting settings:\nODR: 25 Hz\nResolution: \
High\nAcceleration range: 16g with 14bits");
console.log("Accerleration: ");
console.log("Acceleration: ");
var interval = setInterval(function() {
data = kxtj3_sensor.GetAccelerationVector();
console.log(

View File

@ -5,4 +5,4 @@ upm_mixed_module_init (NAME kxtj3
CPP_HDR kxtj3.hpp
CPP_SRC kxtj3.cxx
CPP_WRAPS_C
REQUIRES mraa)
REQUIRES mraa utilities-c)

View File

@ -25,6 +25,7 @@
#include <unistd.h>
#include <math.h>
#include "kxtj3.h"
#include "upm_utilities.h"
#define SW_RESET_MAX_LOOP_COUNT 10
#define SW_RESET_READ_WAIT_MICRO_S 50000
@ -201,7 +202,7 @@ static upm_result_t kxtj3_set_bit_off(const kxtj3_context dev, uint8_t reg, uint
@param reg The register address to write to
@param val byte data to write
@param bit_mask The bits or register mask
@return A UPM resutl
@return A UPM result
*/
static upm_result_t kxtj3_set_bits_with_mask(const kxtj3_context dev, uint8_t reg, uint8_t val, uint8_t bit_mask);
@ -231,11 +232,11 @@ This is used by the self-test functionality.
static struct Coordinates kxtj3_get_sample_averaged_data(kxtj3_context dev);
/**
@brief Check whether the self-test acceleration data difference is whithin the permitted threshold (0.5g)
@brief Check whether the self-test acceleration data difference is within the permitted threshold (0.5g)
@param before The Coordinates struct before the self-test
@param during The Coordinates struct of the self-test
@return true if difference is below thresold, false otherwise
@return true if difference is below threshold, false otherwise
*/
static bool kxtj3_check_self_test_difference(struct Coordinates before, struct Coordinates during);
@ -243,14 +244,14 @@ static bool kxtj3_check_self_test_difference(struct Coordinates before, struct C
@brief Checks the digital communication register (DCST_RESP) register value with an expected value
@param dev The sensor context
@param expected_val The expted byte value of the register
@param expected_val The expected byte value of the register
@return true if values match, false otherwise.
*/
static bool kxtj3_check_digital_communication_reg_value(kxtj3_context dev, uint8_t expected_val);
/**
@brief Gets the count value from a given time (in seconds) for the wake-up function.
Used by the wake-up motion counter and non-activity counter before anothe wake-up functions.
Used by the wake-up motion counter and non-activity counter before another wake-up functions.
@param dev The sensor context
@param time_sec Time in seconds to be converted
@ -642,7 +643,7 @@ static struct Coordinates kxtj3_get_sample_averaged_data(kxtj3_context dev)
coordinates_averaged_sample.x += fabs((x / EARTH_GRAVITY));
coordinates_averaged_sample.y += fabs((y / EARTH_GRAVITY));
coordinates_averaged_sample.z += fabs((z / EARTH_GRAVITY));
usleep(wait_time);
upm_delay_us(wait_time);
}
coordinates_averaged_sample.x /= SELF_TEST_SAMPLE_COUNT;
@ -720,7 +721,7 @@ upm_result_t kxtj3_sensor_software_reset(const kxtj3_context dev)
uint8_t srst_counter = 0;
while ((ctrl_reg2_data & KXTJ3_CTRL_REG2_SRST) != 0x00 && srst_counter < SW_RESET_MAX_LOOP_COUNT)
{
usleep(SW_RESET_READ_WAIT_MICRO_S);
upm_delay_us(SW_RESET_READ_WAIT_MICRO_S);
kxtj3_read_register(dev, KXTJ3_CTRL_REG2, &ctrl_reg2_data);
srst_counter++;
}

View File

@ -201,7 +201,7 @@ extern "C"
kxtj3_context kxtj3_init(int bus, uint8_t addr);
/**
@brief Intilializes the sensor with the given resolution and acceleration range
@brief Initializes the sensor with the given resolution and acceleration range
This gets called during the kxtj3_init(), so it will not need to be called unless the sensor is reset
@ -491,12 +491,12 @@ See datasheet for more details
upm_result_t kxtj3_set_interrupt_response(const kxtj3_context dev, KXTJ3_INTERRUPT_RESPONSE_T response_type);
/**
@brief Gets the status of the interrupts. (Has an interrupt occured).
@brief Gets the status of the interrupts. (Has an interrupt occurred).
See datasheet for more details
@param dev The sensor context
@return Return true if an interrupt event has occured (DRDY or WUFS is 1), returns false if no interrupts have occured
@return Return true if an interrupt event has occurred (DRDY or WUFS is 1), returns false if no interrupts have occurred
*/
bool kxtj3_get_interrupt_status(const kxtj3_context dev);
@ -585,7 +585,7 @@ See datasheet for more details
kxtj3_wakeup_axes kxtj3_get_wakeup_axis_and_direction(kxtj3_context dev);
/**
@brief Enables the Unlached mode motion interrupt (ULMODE). This mode is always by default enabled.
@brief Enables the Unlatched mode motion interrupt (ULMODE). This mode is always by default enabled.
When this bit is set, the wakeup interrupt has to be cleared manually
(cannot use interrupt response with pulse)
@ -598,7 +598,7 @@ Sensor must be in standby mode before performing this action
upm_result_t kxtj3_enable_wakeup_latch(kxtj3_context dev);
/**
@brief Disables the Unlached mode motion interrupt (ULMODE). This mode is always by default enabled
@brief Disables the Unlatched mode motion interrupt (ULMODE). This mode is always by default enabled
(cannot use interrupt response with pulse).
The wakeup threshold is advised to not be very low to avoid interrupt being triggered in

View File

@ -323,12 +323,12 @@ public:
void SetInerruptResponse(KXTJ3_INTERRUPT_RESPONSE_T response_type);
/**
* @brief Gets the status of the interrupts. (Has an interrupt occured)
* @brief Gets the status of the interrupts. (Has an interrupt occurred)
*
* See datasheet for more details
*
* @return Return true if an interrupt event has occured (DRDY or WUFS is 1),
* returns false if no interrupts have occured
* @return Return true if an interrupt event has occurred (DRDY or WUFS is 1),
* returns false if no interrupts have occurred
*/
bool GetInterruptStatus();
@ -410,7 +410,7 @@ public:
kxtj3_wakeup_axes GetWakeUpAxisDirection();
/**
* @brief Enables the Unlached mode motion interrupt (ULMODE). This mode is always by default enabled.
* @brief Enables the Unlatched mode motion interrupt (ULMODE). This mode is always by default enabled.
*
* When this bit is set, the wakeup interrupt has to be cleared manually
* (cannot use interrupt response with pulse)
@ -422,7 +422,7 @@ public:
void EnableWakeUpLatch();
/**
* @brief Disables the Unlached mode motion interrupt (ULMODE). This mode is always by default enabled.
* @brief Disables the Unlatched mode motion interrupt (ULMODE). This mode is always by default enabled.
* (cannot use interrupt response with pulse)
*
* The wakeup threshold is advised to not be very low to avoid interrupt being triggered in