Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Sensor Callbacks

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.
 

Detailed Description

Sensor Callbacks.

Typedef Documentation

◆ sensing_sensor_deinit_t

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.

Parameters
devThe sensor instance device structure.
Returns
0 on success or negative error value on failure.

◆ sensing_sensor_get_fifo_t

typedef int(* sensing_sensor_get_fifo_t) (const struct device *dev, uint32_t *samples)

#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.

Parameters
devThe sensor instance device structure.
samplesThe data buffer to receive the fifo sample number.
Returns
0 on success or negative error value on failure, not support etc.

◆ sensing_sensor_get_interval_t

typedef int(* sensing_sensor_get_interval_t) (const struct device *dev, uint32_t *value)

#include <zephyr/sensing/sensing_sensor.h>

Get current report interval.

Parameters
devThe sensor instance device structure.
valueThe data buffer to receive value.
Returns
0 on success or negative error value on failure.

◆ sensing_sensor_get_offset_t

typedef int(* sensing_sensor_get_offset_t) (const struct device *dev, int index, int32_t *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.

Parameters
devThe sensor instance device structure.
indexThe value fields index to be set, -1 for all fields (global).
valueThe data buffer to receive the offset value.
Returns
0 on success or negative error value on failure, not support etc.

◆ sensing_sensor_get_range_t

typedef int(* sensing_sensor_get_range_t) (const struct device *dev, int index, uint32_t *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.

Parameters
devThe sensor instance device structure.
indexThe value fields index to be set, -1 for all fields (global).
valueThe data buffer to receive value.
Returns
0 on success or negative error value on failure, not support etc.

◆ sensing_sensor_get_sensitivity_t

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.

Parameters
devThe sensor instance device structure.
indexThe value fields index to be set, -1 for all fields (global).
valueThe data buffer to receive value.
Returns
0 on success or negative error value on failure, not support etc.

◆ sensing_sensor_init_t

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.

Parameters
devThe sensor instance device structure.
infoThe sensor instance's constant information.
reporter_handlesThe reporters handles for this sensor, NULL for physical sensors.
reporters_countThe number of reporters, zero for physical sensors.
Returns
0 on success or negative error value on failure.

◆ sensing_sensor_process_t

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.

Parameters
devThe sensor instance device structure.
reporterThe reporter handle who delivered this sensor data
bufThe buffer stored the reporter's sensor data.
sizeThe size of the buffer in bytes.
Returns
0 on success or negative error value on failure.

◆ sensing_sensor_read_sample_t

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

Parameters
devThe sensor instance device structure.
bufSensor subsystem runtime allocated buffer, and passed its pointer to this sensor for store fetched sample.
sizeThe size of the buffer in bytes.
Returns
0 on success or negative error value on failure.

◆ sensing_sensor_reset_t

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.

Parameters
devThe sensor instance device structure.
Returns
0 on success or negative error value on failure.

◆ sensing_sensor_self_calibration_t

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.

Parameters
devThe sensor instance device structure.
Returns
0 on success or negative error value on failure.

◆ sensing_sensor_sensitivity_test_t

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.

Parameters
devThe sensor instance device structure.
indexThe value fields index to be set, -1 for all fields (global).
sensitivityThe sensitivity value.
last_sample_bufThe buffer stored last sample data.
last_sample_sizeThe size of last sample's data buffer in bytes
current_sample_bufThe buffer stored current sample data.
current_sample_sizeThe size of current sample's data buffer in bytes
Returns
0 on test passed or negative error value on failure.

◆ sensing_sensor_set_fifo_t

typedef int(* sensing_sensor_set_fifo_t) (const struct device *dev, uint32_t samples)

#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.

Parameters
devThe sensor instance device structure.
samplesThe sample number to set for fifo.
Returns
0 on success or negative error value on failure, not support etc.

◆ sensing_sensor_set_interval_t

typedef int(* sensing_sensor_set_interval_t) (const struct device *dev, uint32_t value)

#include <zephyr/sensing/sensing_sensor.h>

Set current report interval.

Parameters
devThe sensor instance device structure.
valueThe value to be set.
Returns
0 on success or negative error value on failure.

◆ sensing_sensor_set_offset_t

typedef int(* sensing_sensor_set_offset_t) (const struct device *dev, int index, int32_t value)

#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.

Parameters
devThe sensor instance device structure.
indexThe value fields index to be set, -1 for all fields (global).
valueThe offset value to be set.
Returns
0 on success or negative error value on failure, not support etc.

◆ sensing_sensor_set_range_t

typedef int(* sensing_sensor_set_range_t) (const struct device *dev, int index, uint32_t value)

#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.

Parameters
devThe sensor instance device structure.
indexThe value fields index to be set, -1 for all fields (global).
valueThe value to be set.
Returns
0 on success or negative error value on failure, not support etc.

◆ sensing_sensor_set_sensitivity_t

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.

Parameters
devThe sensor instance device structure.
indexThe value fields index to be set, -1 for all fields (global).
valueThe value to be set.
Returns
0 on success or negative error value on failure.