Skip to content

Commit

Permalink
Rework sensing subsystem
Browse files Browse the repository at this point in the history
Signed-off-by: Yuval Peress <peress@google.com>
  • Loading branch information
yperess committed Jun 27, 2023
1 parent b3e9f1e commit 0a11578
Show file tree
Hide file tree
Showing 28 changed files with 269 additions and 1,542 deletions.
43 changes: 43 additions & 0 deletions dts/bindings/sensing/zephyr,sensing-pipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (c) 2023 Google LLC
# SPDX-License-Identifier: Apache-2.0

description: Passthrough sensor type which enables the sensing subsystem to communicate with physical devices

compatible: "zephyr,sensing-pipe"

include: [sensor-device.yaml, base.yaml]

properties:
dev:
type: phandle
required: true
description: Physical device which provides the data

sensor-types:
type: array
required: true
description: |
One or more sensor data types that are provided by this device. For
example, a 'dev' pointing to a bmi160 may report accel/gyro/die_temp or
any subset of those types.
rotation-matrix:
type: array
description: |
3x3 matrix to rotation x, y, and z axes.
In order to make application logic agnostic to how the device was placed
on the board, it's possible to enter the rotation matrix which will be
applied to every sample produced by this sensor. The final orientation
will be:
* X-axis is horizontal and positive toward the right
* Y-axis is vertical and positive toward the top
* Z-axis is depth and positive toward the user
If not provided, the rotation matrix will be the identity matrix.
Otherwise, the following will be used:
+- -+ +- -+ +- -+
| v1 v2 v3 | | sensor_X | = | X |
| v4 v5 v6 | * | sensor_Y | = | Y |
| v7 v8 v9 | | sensor_Z | = | Z |
+- -+ +- -+ +- -+
13 changes: 0 additions & 13 deletions dts/bindings/sensor/zephyr,sensing-phy-sensor.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions dts/bindings/sensor/zephyr,sensing-sensor.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions dts/bindings/sensor/zephyr,sensing.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions dts/bindings/sensor/zephyr,senss-phy-3d-sensor.yaml

This file was deleted.

11 changes: 9 additions & 2 deletions include/zephyr/drivers/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ struct sensor_info {
}

#define SENSOR_INFO_DEFINE(name, ...) \
static const STRUCT_SECTION_ITERABLE(sensor_info, name) = \
const STRUCT_SECTION_ITERABLE(sensor_info, name) = \
SENSOR_INFO_INITIALIZER(__VA_ARGS__)

#define SENSOR_INFO_DT_NAME(node_id) \
Expand All @@ -1221,7 +1221,14 @@ struct sensor_info {
DEVICE_DT_GET(node_id), \
DT_NODE_VENDOR_OR(node_id, NULL), \
DT_NODE_MODEL_OR(node_id, NULL), \
DT_PROP_OR(node_id, friendly_name, NULL)) \
DT_PROP_OR(node_id, friendly_name, NULL))

#if defined(CONFIG_HAS_DTS) || defined(__DOXYGEN__)
#define Z_MAYBE_SENSOR_INFO_DECLARE_INTERNAL(node_id) \
extern const struct sensor_info SENSOR_INFO_DT_NAME(node_id);

DT_FOREACH_STATUS_OKAY_NODE(Z_MAYBE_SENSOR_INFO_DECLARE_INTERNAL);
#endif /* CONFIG_HAS_DTS || __DOXYGEN__ */

#else

Expand Down
File renamed without changes.
77 changes: 5 additions & 72 deletions include/zephyr/sensing/sensing.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
* @ingroup sensing
*/

#include <zephyr/sensing/sensing_datatypes.h>
#include <zephyr/sensing/sensing_sensor_types.h>
#include <zephyr/device.h>
#include <zephyr/drivers/sensor.h>
#include <zephyr/sensing/datatypes.h>
#include <zephyr/sensing/sensor_types.h>

/**
* @brief Sensing Subsystem API
Expand Down Expand Up @@ -82,17 +83,6 @@ enum sensing_sensor_state {
SENSING_SENSOR_STATE_OFFLINE = 1,
};

/**
* @brief Sensing subsystem sensor config attribute
*
*/
enum sensing_sensor_attribute {
SENSING_SENSOR_ATTRIBUTE_INTERVAL = 0,
SENSING_SENSOR_ATTRIBUTE_SENSITIVITY = 1,
SENSING_SENSOR_ATTRIBUTE_LATENCY = 2,
SENSING_SENSOR_ATTRIBUTE_MAX,
};


/**
* @brief Define Sensing subsystem sensor handle
Expand All @@ -118,23 +108,10 @@ typedef void (*sensing_data_event_t)(
*
*/
struct sensing_sensor_info {
/** Name of the sensor instance */
const char *name;

/** Friendly name of the sensor instance */
const char *friendly_name;

/** Vendor name of the sensor instance */
const char *vendor;

/** Model name of the sensor instance */
const char *model;
const struct sensor_info * info;

/** Sensor type */
const int32_t type;

/** Minimal report interval in micro seconds */
const uint32_t minimal_interval;
int32_t type;
};

/**
Expand All @@ -145,20 +122,6 @@ struct sensing_sensor_info {
struct sensing_callback_list {
sensing_data_event_t on_data_event;
};
/**
* @struct sensing_sensor_config
* @brief Sensing subsystem sensor configure, including interval, sensitivity, latency
*
*/
struct sensing_sensor_config {
enum sensing_sensor_attribute attri;
int8_t data_field;
union {
uint32_t interval;
uint32_t sensitivity;
uint64_t latency;
};
};


/**
Expand Down Expand Up @@ -227,36 +190,6 @@ int sensing_open_sensor_by_dt(
int sensing_close_sensor(
sensing_sensor_handle_t *handle);

/**
* @brief Set current config items to Sensing subsystem.
*
* @param handle The sensor instance handle.
*
* @param configs The configs to be set according to config attribute.
*
* @param count count of configs.
*
* @return 0 on success or negative error value on failure, not support etc.
*/
int sensing_set_config(
sensing_sensor_handle_t handle,
struct sensing_sensor_config *configs, int count);

/**
* @brief Get current config items from Sensing subsystem.
*
* @param handle The sensor instance handle.
*
* @param configs The configs to be get according to config attribute.
*
* @param count count of configs.
*
* @return 0 on success or negative error value on failure, not support etc.
*/
int sensing_get_config(
sensing_sensor_handle_t handle,
struct sensing_sensor_config *configs, int count);

/**
* @brief Get sensor information from sensor instance handle.
*
Expand Down
Loading

0 comments on commit 0a11578

Please sign in to comment.