12#ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_H_
13#define ZEPHYR_INCLUDE_DRIVERS_SENSOR_H_
412static inline int z_impl_sensor_attr_set(
const struct device *dev,
424 return api->
attr_set(dev, chan, attr, val);
444static inline int z_impl_sensor_attr_get(
const struct device *dev,
456 return api->
attr_get(dev, chan, attr, val);
508static inline int z_impl_sensor_sample_fetch(
const struct device *dev)
538static inline int z_impl_sensor_sample_fetch_chan(
const struct device *dev,
572static inline int z_impl_sensor_channel_get(
const struct device *dev,
585#define SENSOR_G 9806650LL
590#define SENSOR_PI 3141592LL
634 if (micro_rad_s > 0) {
661 return (
double)val->
val1 + (double)val->
val2 / 1000000;
684#include <syscalls/sensor.h>
irp nz macro MOVR cc d
Definition: asm-macro-32-bit-gnu.h:11
void
Definition: eswifi_shell.c:15
#define SENSOR_G
The value of gravitational constant in micro m/s^2.
Definition: sensor.h:585
static int32_t sensor_rad_to_degrees(const struct sensor_value *rad)
Helper function for converting radians to degrees.
Definition: sensor.h:630
sensor_trigger_type
Sensor trigger types.
Definition: sensor.h:203
sensor_attribute
Sensor attribute types.
Definition: sensor.h:269
int(* sensor_attr_set_t)(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val)
Callback API upon setting a sensor's attributes.
Definition: sensor.h:344
static void sensor_value_from_double(struct sensor_value *val, double inp)
Helper function for converting double to struct sensor_value.
Definition: sensor.h:670
int(* sensor_sample_fetch_t)(const struct device *dev, enum sensor_channel chan)
Callback API for fetching data from a sensor.
Definition: sensor.h:375
static double sensor_value_to_double(const struct sensor_value *val)
Helper function for converting struct sensor_value to double.
Definition: sensor.h:659
static void sensor_degrees_to_rad(int32_t d, struct sensor_value *rad)
Helper function for converting degrees to radians.
Definition: sensor.h:647
int(* sensor_attr_get_t)(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val)
Callback API upon getting a sensor's attributes.
Definition: sensor.h:355
static void sensor_g_to_ms2(int32_t g, struct sensor_value *ms2)
Helper function to convert acceleration from Gs to m/s^2.
Definition: sensor.h:617
#define SENSOR_PI
The value of constant PI in micros.
Definition: sensor.h:590
void(* sensor_trigger_handler_t)(const struct device *dev, struct sensor_trigger *trigger)
Callback API upon firing of a trigger.
Definition: sensor.h:335
static int sensor_trigger_set(const struct device *dev, struct sensor_trigger *trig, sensor_trigger_handler_t handler)
Activate a sensor's trigger and set the trigger handler.
Definition: sensor.h:476
int sensor_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val)
Get a reading from a sensor device.
int sensor_sample_fetch(const struct device *dev)
Fetch a sample from the sensor and store it in an internal driver buffer.
sensor_channel
Sensor channels.
Definition: sensor.h:53
int(* sensor_channel_get_t)(const struct device *dev, enum sensor_channel chan, struct sensor_value *val)
Callback API for getting a reading from a sensor.
Definition: sensor.h:383
static int32_t sensor_ms2_to_g(const struct sensor_value *ms2)
Helper function to convert acceleration from m/s^2 to Gs.
Definition: sensor.h:600
int(* sensor_trigger_set_t)(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler)
Callback API for setting a sensor's trigger and handler.
Definition: sensor.h:366
int sensor_sample_fetch_chan(const struct device *dev, enum sensor_channel type)
Fetch a sample from the sensor and store it in an internal driver buffer.
int sensor_attr_get(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val)
Get an attribute for a sensor.
int sensor_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val)
Set an attribute for a sensor.
@ SENSOR_TRIG_DELTA
Definition: sensor.h:219
@ SENSOR_TRIG_NEAR_FAR
Definition: sensor.h:221
@ SENSOR_TRIG_FREEFALL
Definition: sensor.h:237
@ SENSOR_TRIG_PRIV_START
Definition: sensor.h:248
@ SENSOR_TRIG_COMMON_COUNT
Definition: sensor.h:242
@ SENSOR_TRIG_THRESHOLD
Definition: sensor.h:228
@ SENSOR_TRIG_MAX
Definition: sensor.h:253
@ SENSOR_TRIG_DOUBLE_TAP
Definition: sensor.h:234
@ SENSOR_TRIG_TIMER
Definition: sensor.h:208
@ SENSOR_TRIG_TAP
Definition: sensor.h:231
@ SENSOR_TRIG_DATA_READY
Definition: sensor.h:210
@ SENSOR_ATTR_HYSTERESIS
Definition: sensor.h:287
@ SENSOR_ATTR_FEATURE_MASK
Definition: sensor.h:307
@ SENSOR_ATTR_CALIB_TARGET
Definition: sensor.h:301
@ SENSOR_ATTR_OFFSET
Definition: sensor.h:296
@ SENSOR_ATTR_OVERSAMPLING
Definition: sensor.h:289
@ SENSOR_ATTR_UPPER_THRESH
Definition: sensor.h:278
@ SENSOR_ATTR_CONFIGURATION
Definition: sensor.h:303
@ SENSOR_ATTR_CALIBRATION
Definition: sensor.h:305
@ SENSOR_ATTR_COMMON_COUNT
Definition: sensor.h:314
@ SENSOR_ATTR_ALERT
Definition: sensor.h:309
@ SENSOR_ATTR_SLOPE_TH
Definition: sensor.h:280
@ SENSOR_ATTR_SAMPLING_FREQUENCY
Definition: sensor.h:274
@ SENSOR_ATTR_FULL_SCALE
Definition: sensor.h:291
@ SENSOR_ATTR_LOWER_THRESH
Definition: sensor.h:276
@ SENSOR_ATTR_SLOPE_DUR
Definition: sensor.h:285
@ SENSOR_ATTR_MAX
Definition: sensor.h:325
@ SENSOR_ATTR_PRIV_START
Definition: sensor.h:320
@ SENSOR_CHAN_GAUGE_STATE_OF_HEALTH
Definition: sensor.h:166
@ SENSOR_CHAN_PM_1_0
Definition: sensor.h:105
@ SENSOR_CHAN_DIE_TEMP
Definition: sensor.h:79
@ SENSOR_CHAN_PRESS
Definition: sensor.h:83
@ SENSOR_CHAN_GAUGE_TIME_TO_FULL
Definition: sensor.h:170
@ SENSOR_CHAN_ACCEL_XYZ
Definition: sensor.h:61
@ SENSOR_CHAN_MAGN_X
Definition: sensor.h:71
@ SENSOR_CHAN_CURRENT
Definition: sensor.h:123
@ SENSOR_CHAN_GYRO_XYZ
Definition: sensor.h:69
@ SENSOR_CHAN_GREEN
Definition: sensor.h:98
@ SENSOR_CHAN_MAGN_Z
Definition: sensor.h:75
@ SENSOR_CHAN_MAGN_Y
Definition: sensor.h:73
@ SENSOR_CHAN_GAUGE_DESIRED_VOLTAGE
Definition: sensor.h:176
@ SENSOR_CHAN_POWER
Definition: sensor.h:125
@ SENSOR_CHAN_PM_2_5
Definition: sensor.h:107
@ SENSOR_CHAN_RESISTANCE
Definition: sensor.h:128
@ SENSOR_CHAN_GAUGE_AVG_CURRENT
Definition: sensor.h:146
@ SENSOR_CHAN_GYRO_Y
Definition: sensor.h:65
@ SENSOR_CHAN_GAUGE_DESIRED_CHARGING_CURRENT
Definition: sensor.h:178
@ SENSOR_CHAN_GAUGE_FULL_CHARGE_CAPACITY
Definition: sensor.h:156
@ SENSOR_CHAN_ROTATION
Definition: sensor.h:131
@ SENSOR_CHAN_AMBIENT_TEMP
Definition: sensor.h:81
@ SENSOR_CHAN_MAGN_XYZ
Definition: sensor.h:77
@ SENSOR_CHAN_GAUGE_STDBY_CURRENT
Definition: sensor.h:148
@ SENSOR_CHAN_GAUGE_MAX_LOAD_CURRENT
Definition: sensor.h:150
@ SENSOR_CHAN_ACCEL_Y
Definition: sensor.h:57
@ SENSOR_CHAN_RPM
Definition: sensor.h:141
@ SENSOR_CHAN_GAUGE_FULL_AVAIL_CAPACITY
Definition: sensor.h:162
@ SENSOR_CHAN_VOLTAGE
Definition: sensor.h:121
@ SENSOR_CHAN_BLUE
Definition: sensor.h:100
@ SENSOR_CHAN_LIGHT
Definition: sensor.h:92
@ SENSOR_CHAN_GAUGE_DESIGN_VOLTAGE
Definition: sensor.h:174
@ SENSOR_CHAN_ACCEL_Z
Definition: sensor.h:59
@ SENSOR_CHAN_CO2
Definition: sensor.h:114
@ SENSOR_CHAN_GAUGE_STATE_OF_CHARGE
Definition: sensor.h:154
@ SENSOR_CHAN_GAUGE_CYCLE_COUNT
Definition: sensor.h:172
@ SENSOR_CHAN_GAUGE_TEMP
Definition: sensor.h:152
@ SENSOR_CHAN_POS_DY
Definition: sensor.h:136
@ SENSOR_CHAN_GYRO_Z
Definition: sensor.h:67
@ SENSOR_CHAN_POS_DX
Definition: sensor.h:134
@ SENSOR_CHAN_GAUGE_AVG_POWER
Definition: sensor.h:164
@ SENSOR_CHAN_GAUGE_TIME_TO_EMPTY
Definition: sensor.h:168
@ SENSOR_CHAN_PM_10
Definition: sensor.h:109
@ SENSOR_CHAN_GAUGE_REMAINING_CHARGE_CAPACITY
Definition: sensor.h:158
@ SENSOR_CHAN_ALL
Definition: sensor.h:181
@ SENSOR_CHAN_GAUGE_VOLTAGE
Definition: sensor.h:144
@ SENSOR_CHAN_PROX
Definition: sensor.h:88
@ SENSOR_CHAN_COMMON_COUNT
Definition: sensor.h:186
@ SENSOR_CHAN_PRIV_START
Definition: sensor.h:192
@ SENSOR_CHAN_GYRO_X
Definition: sensor.h:63
@ SENSOR_CHAN_GAS_RES
Definition: sensor.h:118
@ SENSOR_CHAN_HUMIDITY
Definition: sensor.h:90
@ SENSOR_CHAN_DISTANCE
Definition: sensor.h:111
@ SENSOR_CHAN_IR
Definition: sensor.h:94
@ SENSOR_CHAN_MAX
Definition: sensor.h:197
@ SENSOR_CHAN_POS_DZ
Definition: sensor.h:138
@ SENSOR_CHAN_RED
Definition: sensor.h:96
@ SENSOR_CHAN_ALTITUDE
Definition: sensor.h:102
@ SENSOR_CHAN_GAUGE_NOM_AVAIL_CAPACITY
Definition: sensor.h:160
@ SENSOR_CHAN_ACCEL_X
Definition: sensor.h:55
@ SENSOR_CHAN_VOC
Definition: sensor.h:116
#define ENOSYS
Definition: errno.h:83
__INT32_TYPE__ int32_t
Definition: stdint.h:44
#define INT16_MAX
Definition: stdint.h:17
__INT64_TYPE__ int64_t
Definition: stdint.h:45
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
sensor_attr_set_t attr_set
Definition: sensor.h:388
sensor_attr_get_t attr_get
Definition: sensor.h:389
sensor_trigger_set_t trigger_set
Definition: sensor.h:390
sensor_sample_fetch_t sample_fetch
Definition: sensor.h:391
sensor_channel_get_t channel_get
Definition: sensor.h:392
Sensor trigger spec.
Definition: sensor.h:259
enum sensor_trigger_type type
Definition: sensor.h:261
enum sensor_channel chan
Definition: sensor.h:263
Representation of a sensor readout value.
Definition: sensor.h:43
int32_t val2
Definition: sensor.h:47
int32_t val1
Definition: sensor.h:45
static void handler(struct k_timer *timer)
Definition: main.c:19