NTURT Zephyr v0.0.1
NTURT common library for Zephyr RTOS
Loading...
Searching...
No Matches
sensors.h File Reference
#include <stdbool.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/sensor.h>
#include "nturt/err.h"
+ Include dependency graph for sensors.h:

Data Structures

struct  sensor_tol
 Sensor tolerant structure. More...
 

Macros

#define SENSOR_TOL_INITIALIZER(NODE_ID, THRES, WEIGHT, ERR)
 Designated initializer for sensor_tol.
 
#define SENSOR_TOL_DEFINE(NAME, NODE_ID, THRES, WEIGHT, ERR)
 Instantiate a sensor_tol.
 

Functions

int sensor_tol_init (struct sensor_tol *tol)
 
bool sensor_tol_is_ok (struct sensor_tol *tol)
 
int sensor_tol_chan_read (struct sensor_tol *tol, enum sensor_channel chan, struct sensor_value *val)
 Read sensor data with tolerance. Sets error when error level reaches threshold. Does nothing if the sensor error is set and returns -ENODEV.
 
void sensor_tol_report_fail (struct sensor_tol *tol)
 Report sensor failure.
 
void sensor_tol_report_error (struct sensor_tol *tol)
 

Macro Definition Documentation

◆ SENSOR_TOL_DEFINE

#define SENSOR_TOL_DEFINE ( NAME,
NODE_ID,
THRES,
WEIGHT,
ERR )
Value:
static struct sensor_tol NAME = \
SENSOR_TOL_INITIALIZER(NODE_ID, THRES, WEIGHT, ERR)
Sensor tolerant structure.
Definition sensors.h:48

Instantiate a sensor_tol.

Parameters
NAMEName of the sensor tolerant read structure.
NODE_IDNode ID of the sensor device.
THRESError level when greater or equal is considered an error.
WEIGHTError level increase of one sensor failure.
ERRError code corresponding to the sensor.

◆ SENSOR_TOL_INITIALIZER

#define SENSOR_TOL_INITIALIZER ( NODE_ID,
THRES,
WEIGHT,
ERR )
Value:
{ \
.dev = DEVICE_DT_GET(NODE_ID), \
.thres = THRES, \
.weight = WEIGHT, \
.err = ERR, \
.level = 0, \
}

Designated initializer for sensor_tol.

Parameters
NODE_IDNode ID of the sensor device.
THRESError level when greater or equal is considered an error.
WEIGHTError level increase of one sensor failure.
ERRError code corresponding to the sensor.

Function Documentation

◆ sensor_tol_chan_read()

int sensor_tol_chan_read ( struct sensor_tol * tol,
enum sensor_channel chan,
struct sensor_value * val )

Read sensor data with tolerance. Sets error when error level reaches threshold. Does nothing if the sensor error is set and returns -ENODEV.

Parameters
tolSensor tolerant read structure.
chanSensor channel.
valSensor value.
Returns
0 if read successful, negative error code otherwise.

◆ sensor_tol_init()

int sensor_tol_init ( struct sensor_tol * tol)

◆ sensor_tol_is_ok()

bool sensor_tol_is_ok ( struct sensor_tol * tol)

◆ sensor_tol_report_error()

void sensor_tol_report_error ( struct sensor_tol * tol)

◆ sensor_tol_report_fail()

void sensor_tol_report_fail ( struct sensor_tol * tol)

Report sensor failure.

Parameters
tolSensor tolerant read structure.