Zephyr API Documentation
3.5.0
A Scalable Open Source RTOS
|
|
3.5.0 |
Sensing Sensor API. More...
Modules | |
Sensor Callbacks | |
Sensor Callbacks. | |
Data Structures | |
struct | sensing_sensor_register_info |
Sensor registration information. More... | |
struct | sensing_sensor_ctx |
Sensor context data structure. More... | |
Macros | |
#define | SENSING_SENSOR_DT_DEFINE(node_id, reg_ptr, ctx_ptr, api_ptr) |
Macro for define a sensor instance from device tree node id. | |
Functions | |
static int | sensing_sensor_dev_init (const struct device *dev) |
static void * | sensing_sensor_get_ctx_data (const struct device *dev) |
Get registered context data pointer for a sensor instance. | |
int | sensing_sensor_post_data (const struct device *dev, void *buf, int size) |
Post sensor data, sensor subsystem runtime will deliver to it's clients. | |
int | sensing_sensor_get_reporters (const struct device *dev, int type, const int *reporter_handles, int max_handles) |
Get reporter handles of a given sensor instance by sensor type. | |
int | sensing_sensor_get_reporters_count (const struct device *dev, int type) |
Get reporters count of a given sensor instance by sensor type. | |
int | sensing_sensor_get_state (const struct device *dev, enum sensing_sensor_state *state) |
Get this sensor's state. | |
int | sensing_sensor_notify_data_ready (const struct device *dev) |
Trigger the data ready event to sensing. | |
int | sensing_sensor_set_data_ready (const struct device *dev, bool data_ready) |
Set the data ready mode of the sensor. | |
Sensing Sensor API.
#define SENSING_SENSOR_DT_DEFINE | ( | node_id, | |
reg_ptr, | |||
ctx_ptr, | |||
api_ptr | |||
) |
#include <zephyr/sensing/sensing_sensor.h>
Macro for define a sensor instance from device tree node id.
This macro also defined a struct device for this sensor instance, and registered sensors' private context data, configuration data structure and API.
sensing_init will enumerate all sensor instances from device tree, and initialize each sensor instance defined by this macro.
|
inlinestatic |
#include <zephyr/sensing/sensing_sensor.h>
Nothing need to do in system auto initialization. Sensor subsystem runtime will call each sensor instance's initialization function via API callback according sensor reporting dependency sequences. Sensor subsystem can make sure the depends sensor instances always initialized before client sensors.
|
inlinestatic |
#include <zephyr/sensing/sensing_sensor.h>
Get registered context data pointer for a sensor instance.
Used by a sensor instance to get its registered context data pointer with its struct device.
dev | The sensor instance device structure. |
int sensing_sensor_get_reporters | ( | const struct device * | dev, |
int | type, | ||
const int * | reporter_handles, | ||
int | max_handles | ||
) |
#include <zephyr/sensing/sensing_sensor.h>
Get reporter handles of a given sensor instance by sensor type.
dev | The sensor instance device structure. |
type | The given type, SENSING_SENSOR_TYPE_ALL to get reporters with all types. |
max_handles | The max count of the reporter_handles array input. Can get real count number via sensing_sensor_get_reporters_count |
reporter_handles | Input handles array for receiving found reporter sensor instances |
int sensing_sensor_get_reporters_count | ( | const struct device * | dev, |
int | type | ||
) |
#include <zephyr/sensing/sensing_sensor.h>
Get reporters count of a given sensor instance by sensor type.
dev | The sensor instance device structure. |
type | The sensor type for checking, SENSING_SENSOR_TYPE_ALL |
type
, 0 returned if no reporters by type
. int sensing_sensor_get_state | ( | const struct device * | dev, |
enum sensing_sensor_state * | state | ||
) |
#include <zephyr/sensing/sensing_sensor.h>
Get this sensor's state.
dev | The sensor instance device structure. |
state | Returned sensor state value |
int sensing_sensor_notify_data_ready | ( | const struct device * | dev | ) |
#include <zephyr/sensing/sensing_sensor.h>
Trigger the data ready event to sensing.
dev | Pointer to the sensor device |
int sensing_sensor_post_data | ( | const struct device * | dev, |
void * | buf, | ||
int | size | ||
) |
#include <zephyr/sensing/sensing_sensor.h>
Post sensor data, sensor subsystem runtime will deliver to it's clients.
Unblocked function, returned immediately.
Used by a virtual sensor to post data to it's clients.
A reporter sensor can use this API to post data to it's clients. For example, when a virtual sensor computed a data, then can use this API to deliver the data to it's clients. Please note, this API just for reporter post data to the sensor subsystem runtime, the runtime will help delivered the data to it's all clients according clients' configurations such as reporter interval, data change sensitivity.
dev | The sensor instance device structure. |
buf | The data buffer. |
size | The buffer size in bytes. |
#include <zephyr/sensing/sensing_sensor.h>
Set the data ready mode of the sensor.
dev | Pointer to the sensor device |
data_ready | Enable/disable the data ready mode. Default:disabled |