samples: sensor: wsen_itds: remove example for wsen_itds
Remove example for wsen_itds to switch to generic sensor driver examples. Signed-off-by: Wajdi ELMuhtadi <wajdi.elmuhtadi@we-online.com>
This commit is contained in:
parent
b5a39b896b
commit
56b70bddcc
@ -173,6 +173,7 @@ REDIRECTS = [
|
||||
('reference/util/index', 'kernel/util/index'),
|
||||
('samples/drivers/kscan_touch', 'samples/subsys/input/input'),
|
||||
('samples/net/cloud/google_iot_mqtt', 'samples/net/cloud'),
|
||||
('samples/sensor/wsen_itds/README', 'samples/sensor/sensor'),
|
||||
('services/portability/posix', 'services/portability/posix/index'),
|
||||
# zephyr-keep-sorted-stop
|
||||
]
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(wsen_itds)
|
||||
|
||||
target_sources(app PRIVATE src/main.c)
|
||||
@ -1,57 +0,0 @@
|
||||
.. _wsen-itds:
|
||||
|
||||
WSEN-ITDS: 3-axis acceleration sensor
|
||||
#####################################
|
||||
|
||||
Overview
|
||||
********
|
||||
This sample periodically measures acceleration in 3-axis and die temperature for
|
||||
5 sec in the interval of 300msec in polling mode. Then data ready trigger mode
|
||||
is enabled with the sample frequency of 400Hz and 3-axis data is fetched based
|
||||
on interrupt. The result is displayed on the console.
|
||||
|
||||
Requirements
|
||||
************
|
||||
|
||||
This sample uses the WSEN-ITDS sensor controlled using the I2C interface.
|
||||
Connect sensor IN1 for interrupt(data ready trigger) to Disco board D8 pin
|
||||
Connect sensor CS pin high to enable I2C communication, SAO to ground for 0x18
|
||||
I2C address selection.
|
||||
|
||||
References
|
||||
**********
|
||||
|
||||
- WSEN-ITDS: https://www.we-online.com/components/products/manual/2533020201601_WSEN-ITDS%202533020201601%20Manual_rev2.3.pdf
|
||||
|
||||
Building and Running
|
||||
********************
|
||||
|
||||
This project outputs sensor data to the console. It requires a WSEN-ITDS
|
||||
sensor, which is present on the disco_l475_iot1 board.
|
||||
|
||||
.. zephyr-app-commands::
|
||||
:app: samples/sensor/wsen_itds/
|
||||
:goals: build flash
|
||||
|
||||
|
||||
Sample Output
|
||||
=============
|
||||
|
||||
.. code-block:: console
|
||||
|
||||
Testing the polling mode.
|
||||
Accl (m/s): X=2.311466, Y=-39.433716, Z=2.636890
|
||||
Temperature (Celsius): 28.000000
|
||||
|
||||
<repeats 5sec every 300ms>
|
||||
|
||||
Polling mode test finished.
|
||||
Testing the trigger mode.
|
||||
Testing data ready trigger.
|
||||
any drdy.
|
||||
Accl (m/s): X=8.039883, Y=-1.780260, Z=6.063412
|
||||
|
||||
<repeats 5sec every 300ms>
|
||||
|
||||
Data ready trigger test finished.
|
||||
Trigger mode test finished.
|
||||
@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Linumiz
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
&i2c1 {
|
||||
itds@18 {
|
||||
compatible = "we,wsen-itds";
|
||||
reg = <0x18>;
|
||||
int-gpios = <&gpiob 2 GPIO_ACTIVE_HIGH>;
|
||||
odr = "800";
|
||||
op-mode = "high-perf";
|
||||
};
|
||||
};
|
||||
@ -1,5 +0,0 @@
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_GPIO=y
|
||||
CONFIG_I2C=y
|
||||
CONFIG_SENSOR=y
|
||||
CONFIG_CBPRINTF_FP_SUPPORT=y
|
||||
@ -1,10 +0,0 @@
|
||||
sample:
|
||||
name: WSEN-ITDS Sensor Sample
|
||||
tests:
|
||||
sample.sensor.wsen-itds:
|
||||
harness: sensor
|
||||
tags: sensors
|
||||
depends_on:
|
||||
- i2c
|
||||
- gpio
|
||||
filter: dt_compat_enabled("we,wsen-itds")
|
||||
@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Linumiz
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#include <zephyr/sys/printk.h>
|
||||
#include <zephyr/sys_clock.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/sensor.h>
|
||||
#include <zephyr/drivers/i2c.h>
|
||||
|
||||
#define MAX_TEST_TIME 5000
|
||||
#define SLEEPTIME 300
|
||||
|
||||
static void print_accl_data(const struct device *itds)
|
||||
{
|
||||
struct sensor_value val[3];
|
||||
|
||||
if (sensor_channel_get(itds, SENSOR_CHAN_ACCEL_XYZ, val) < 0) {
|
||||
printf("Cannot read itds accl channels.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Accl (m/s): X=%f, Y=%f, Z=%f\n",
|
||||
sensor_value_to_double(&val[0]),
|
||||
sensor_value_to_double(&val[1]),
|
||||
sensor_value_to_double(&val[2]));
|
||||
}
|
||||
|
||||
static void print_temp_data(const struct device *itds)
|
||||
{
|
||||
struct sensor_value val;
|
||||
|
||||
if (sensor_channel_get(itds, SENSOR_CHAN_DIE_TEMP, &val) < 0) {
|
||||
printf("Temperature channel read error.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Temperature (Celsius): %f\n",
|
||||
sensor_value_to_double(&val));
|
||||
}
|
||||
|
||||
static void test_polling_mode(const struct device *itds)
|
||||
{
|
||||
int32_t remaining_test_time = MAX_TEST_TIME;
|
||||
|
||||
do {
|
||||
if (sensor_sample_fetch(itds) < 0) {
|
||||
printf("accl sample update error.\n");
|
||||
} else {
|
||||
print_accl_data(itds);
|
||||
|
||||
print_temp_data(itds);
|
||||
}
|
||||
|
||||
/* wait a while */
|
||||
k_sleep(K_MSEC(SLEEPTIME));
|
||||
|
||||
remaining_test_time -= SLEEPTIME;
|
||||
} while (remaining_test_time > 0);
|
||||
}
|
||||
|
||||
#if defined(CONFIG_ITDS_TRIGGER)
|
||||
static void trigger_handler(const struct device *itds,
|
||||
const struct sensor_trigger *trigger)
|
||||
{
|
||||
switch (trigger->type) {
|
||||
case SENSOR_TRIG_DATA_READY:
|
||||
printf("Data ready.\n");
|
||||
if (sensor_sample_fetch(itds) < 0) {
|
||||
printf("sample update error.\n");
|
||||
} else {
|
||||
print_accl_data(itds);
|
||||
}
|
||||
return;
|
||||
|
||||
default:
|
||||
printf("trigger handler: unknown trigger type.\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void test_trigger_mode(const struct device *itds)
|
||||
{
|
||||
#if defined(CONFIG_ITDS_TRIGGER)
|
||||
struct sensor_trigger trig;
|
||||
struct sensor_value attr;
|
||||
|
||||
printf("Testing data ready trigger.\n");
|
||||
|
||||
attr.val1 = 400;
|
||||
attr.val2 = 0;
|
||||
|
||||
if (sensor_attr_set(itds, SENSOR_CHAN_ACCEL_XYZ,
|
||||
SENSOR_ATTR_SAMPLING_FREQUENCY, &attr) < 0) {
|
||||
printf("cannot set sampling frequency.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
trig.type = SENSOR_TRIG_DATA_READY;
|
||||
trig.chan = SENSOR_CHAN_ACCEL_XYZ;
|
||||
|
||||
if (sensor_trigger_set(itds, &trig, trigger_handler) < 0) {
|
||||
printf("cannot set trigger.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
k_sleep(K_MSEC(MAX_TEST_TIME));
|
||||
|
||||
trig.type = SENSOR_TRIG_DATA_READY;
|
||||
trig.chan = SENSOR_CHAN_ACCEL_XYZ;
|
||||
if (sensor_trigger_set(itds, &trig, NULL) < 0) {
|
||||
printf("cannot clear trigger.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Data ready trigger test finished.\n");
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const struct device *const itds = DEVICE_DT_GET_ONE(we_wsen_itds);
|
||||
struct sensor_value attr;
|
||||
|
||||
printf("get device wsen-itds\n");
|
||||
if (!device_is_ready(itds)) {
|
||||
printk("sensor: device not ready.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set accl range to +/- 16 G. Since the sensor API needs SI
|
||||
* units, convert the range to rad/s.
|
||||
*/
|
||||
sensor_g_to_ms2(4, &attr);
|
||||
|
||||
if (sensor_attr_set(itds, SENSOR_CHAN_ACCEL_XYZ,
|
||||
SENSOR_ATTR_FULL_SCALE, &attr) < 0) {
|
||||
printf("Cannot set accl range.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("Testing the polling mode.\n");
|
||||
test_polling_mode(itds);
|
||||
printf("Polling mode test finished.\n");
|
||||
|
||||
printf("Testing the trigger mode.\n");
|
||||
test_trigger_mode(itds);
|
||||
printf("Trigger mode test finished.\n");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user