Zephyr API Documentation
3.5.0
A Scalable Open Source RTOS
|
|
3.5.0 |
Sensor Callbacks. More...
Data Structures | |
struct | sensing_sensor_api |
Sensor callback api. More... | |
Typedefs | |
typedef int(* | sensing_sensor_init_t) (const struct device *dev, const struct sensing_sensor_info *info, const sensing_sensor_handle_t *reporter_handles, int reporters_count) |
Sensor initialize. | |
typedef int(* | sensing_sensor_deinit_t) (const struct device *dev) |
Sensor's de-initialize. | |
typedef int(* | sensing_sensor_reset_t) (const struct device *dev) |
Sensor reset. | |
typedef int(* | sensing_sensor_read_sample_t) (const struct device *dev, void *buf, int size) |
Sensor read sample. | |
typedef int(* | sensing_sensor_process_t) (const struct device *dev, int reporter, void *buf, int size) |
Sensor process data. | |
typedef int(* | sensing_sensor_self_calibration_t) (const struct device *dev) |
Trigger a sensor to do self calibration. | |
typedef int(* | sensing_sensor_sensitivity_test_t) (const struct device *dev, int index, uint32_t sensitivity, void *last_sample_buf, int last_sample_size, void *current_sample_buf, int current_sample_size) |
Sensitivity arbitration. | |
typedef int(* | sensing_sensor_set_interval_t) (const struct device *dev, uint32_t value) |
Set current report interval. | |
typedef int(* | sensing_sensor_get_interval_t) (const struct device *dev, uint32_t *value) |
Get current report interval. | |
typedef int(* | sensing_sensor_set_sensitivity_t) (const struct device *dev, int index, uint32_t value) |
Set data change sensitivity. | |
typedef int(* | sensing_sensor_get_sensitivity_t) (const struct device *dev, int index, uint32_t *value) |
Get current data change sensitivity. | |
typedef int(* | sensing_sensor_set_range_t) (const struct device *dev, int index, uint32_t value) |
Set data range. | |
typedef int(* | sensing_sensor_get_range_t) (const struct device *dev, int index, uint32_t *value) |
Get current data range. | |
typedef int(* | sensing_sensor_set_fifo_t) (const struct device *dev, uint32_t samples) |
Set current sensor's hardware fifo size. | |
typedef int(* | sensing_sensor_get_fifo_t) (const struct device *dev, uint32_t *samples) |
Get current sensor's hardware fifo size. | |
typedef int(* | sensing_sensor_set_offset_t) (const struct device *dev, int index, int32_t value) |
Set current sensor data offset. | |
typedef int(* | sensing_sensor_get_offset_t) (const struct device *dev, int index, int32_t *value) |
Get current sensor data offset. | |
Sensor Callbacks.
typedef int(* sensing_sensor_deinit_t) (const struct device *dev) |
#include <zephyr/sensing/sensing_sensor.h>
Sensor's de-initialize.
Sensor can release it's runtime context in this callback.
dev | The sensor instance device structure. |
#include <zephyr/sensing/sensing_sensor.h>
Get current sensor's hardware fifo size.
Some sensors especially for physical sensors, support fifo, this API can get the current fifo size.
dev | The sensor instance device structure. |
samples | The data buffer to receive the fifo sample number. |
#include <zephyr/sensing/sensing_sensor.h>
Get current report interval.
dev | The sensor instance device structure. |
value | The data buffer to receive value. |
#include <zephyr/sensing/sensing_sensor.h>
Get current sensor data offset.
Some sensors especially for physical sensors, such as accelerometer senors, as data drift, need configure offset calibration.
Since each sensor type may have multiple data fields for it's value, this API support get separated offset for each data field, or global offset for all data fields.
dev | The sensor instance device structure. |
index | The value fields index to be set, -1 for all fields (global). |
value | The data buffer to receive the offset value. |
#include <zephyr/sensing/sensing_sensor.h>
Get current data range.
Some sensors especially for physical sensors, support data range configuration, this may change data resolution.
Since each sensor type may have multiple data fields for it's value, this API support get separated range for each data field, or global range for all data fields.
dev | The sensor instance device structure. |
index | The value fields index to be set, -1 for all fields (global). |
value | The data buffer to receive value. |
typedef int(* sensing_sensor_get_sensitivity_t) (const struct device *dev, int index, uint32_t *value) |
#include <zephyr/sensing/sensing_sensor.h>
Get current data change sensitivity.
Since each sensor type may have multiple data fields for it's value, this API support get separated sensitivity for each data field, or global sensitivity for all data fields.
dev | The sensor instance device structure. |
index | The value fields index to be set, -1 for all fields (global). |
value | The data buffer to receive value. |
typedef int(* sensing_sensor_init_t) (const struct device *dev, const struct sensing_sensor_info *info, const sensing_sensor_handle_t *reporter_handles, int reporters_count) |
#include <zephyr/sensing/sensing_sensor.h>
Sensor initialize.
Sensor can initialize it's runtime context in this callback.
dev | The sensor instance device structure. |
info | The sensor instance's constant information. |
reporter_handles | The reporters handles for this sensor, NULL for physical sensors. |
reporters_count | The number of reporters, zero for physical sensors. |
typedef int(* sensing_sensor_process_t) (const struct device *dev, int reporter, void *buf, int size) |
#include <zephyr/sensing/sensing_sensor.h>
Sensor process data.
Only virtual sensor need implement this callback. Virtual sensor can receive reporter's data and do fusion computing in this callback.
dev | The sensor instance device structure. |
reporter | The reporter handle who delivered this sensor data |
buf | The buffer stored the reporter's sensor data. |
size | The size of the buffer in bytes. |
typedef int(* sensing_sensor_read_sample_t) (const struct device *dev, void *buf, int size) |
#include <zephyr/sensing/sensing_sensor.h>
Sensor read sample.
Only physical sensor need implement this callback. Physical sensor can fetch sample data from sensor device in this callback
dev | The sensor instance device structure. |
buf | Sensor subsystem runtime allocated buffer, and passed its pointer to this sensor for store fetched sample. |
size | The size of the buffer in bytes. |
typedef int(* sensing_sensor_reset_t) (const struct device *dev) |
#include <zephyr/sensing/sensing_sensor.h>
Sensor reset.
Sensor can reset its runtime context in this callback to default values without resources release and re-allocation.
Its very useful for a virtual sensor to quickly reset its runtime context to a default state.
dev | The sensor instance device structure. |
typedef int(* sensing_sensor_self_calibration_t) (const struct device *dev) |
#include <zephyr/sensing/sensing_sensor.h>
Trigger a sensor to do self calibration.
If not support self calibration, can not implement this callback.
dev | The sensor instance device structure. |
typedef int(* sensing_sensor_sensitivity_test_t) (const struct device *dev, int index, uint32_t sensitivity, void *last_sample_buf, int last_sample_size, void *current_sample_buf, int current_sample_size) |
#include <zephyr/sensing/sensing_sensor.h>
Sensitivity arbitration.
This callback API provides a chance for sensor to do customized arbitration on data change sensitivity. The sensor can check two sequential samples with client's sensitivity value (passed with parameters in this callback) and decide if can pass the sensor sample to its client.
dev | The sensor instance device structure. |
index | The value fields index to be set, -1 for all fields (global). |
sensitivity | The sensitivity value. |
last_sample_buf | The buffer stored last sample data. |
last_sample_size | The size of last sample's data buffer in bytes |
current_sample_buf | The buffer stored current sample data. |
current_sample_size | The size of current sample's data buffer in bytes |
#include <zephyr/sensing/sensing_sensor.h>
Set current sensor's hardware fifo size.
Some sensors especially for physical sensors, support hardware fifo, this API can configure the current fifo size.
dev | The sensor instance device structure. |
samples | The sample number to set for fifo. |
#include <zephyr/sensing/sensing_sensor.h>
Set current report interval.
dev | The sensor instance device structure. |
value | The value to be set. |
#include <zephyr/sensing/sensing_sensor.h>
Set current sensor data offset.
Some sensors especially for physical sensors, such as accelerometer senors, as data drift, need configure offset calibration.
Since each sensor type may have multiple data fields for it's value, this API support set separated offset for each data field, or global offset for all data fields.
dev | The sensor instance device structure. |
index | The value fields index to be set, -1 for all fields (global). |
value | The offset value to be set. |
#include <zephyr/sensing/sensing_sensor.h>
Set data range.
Some sensors especially for physical sensors, support data range configuration, this may change data resolution.
Since each sensor type may have multiple data fields for it's value, this API support set separated range for each data field, or global range for all data fields.
dev | The sensor instance device structure. |
index | The value fields index to be set, -1 for all fields (global). |
value | The value to be set. |
typedef int(* sensing_sensor_set_sensitivity_t) (const struct device *dev, int index, uint32_t value) |
#include <zephyr/sensing/sensing_sensor.h>
Set data change sensitivity.
Since each sensor type may have multiple data fields for it's value, this API support set separated sensitivity for each data field, or global sensitivity for all data fields.
dev | The sensor instance device structure. |
index | The value fields index to be set, -1 for all fields (global). |
value | The value to be set. |