ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
ruuvi_task_sensor.h File Reference

Go to the source code of this file.

Data Structures

struct  rt_sensor_ctx_t
 

Functions

rd_status_t rt_sensor_initialize (rt_sensor_ctx_t *const sensor)
 Initialize sensor CTX. More...
 
rd_status_t rt_sensor_store (rt_sensor_ctx_t *const sensor)
 Store the sensor state to NVM. More...
 
rd_status_t rt_sensor_load (rt_sensor_ctx_t *const sensor)
 Load the sensor state from NVM. More...
 
rd_status_t rt_sensor_configure (rt_sensor_ctx_t *const sensor)
 Configure a sensor with given settings. More...
 
rt_sensor_ctx_trt_sensor_find_backend (rt_sensor_ctx_t *const sensor_list, const size_t count, const char *const name)
 Search for requested sensor backend in given list of sensors. More...
 
rt_sensor_ctx_trt_sensor_find_provider (rt_sensor_ctx_t *const sensor_list, const size_t count, rd_sensor_data_fields_t values)
 Search for a sensor which can provide requested values. More...
 

Detailed Description

Author
Otso Jousimaa otso@.nosp@m.ojou.nosp@m.sima..nosp@m.net
Date
2019-20-21

Helper functions common to all sensors

Definition in file ruuvi_task_sensor.h.

Function Documentation

◆ rt_sensor_configure()

rd_status_t rt_sensor_configure ( rt_sensor_ctx_t *const  sensor)

Configure a sensor with given settings.

Parameters
[in,out]sensorIn: Sensor to configure. Out: Sensor->configuration will be set to actual configuration.
Return values
RD_SUCCESSon success.
RD_ERROR_NULLif sensor is NULL.
errorcode from sensor on other error.

◆ rt_sensor_find_backend()

rt_sensor_ctx_t* rt_sensor_find_backend ( rt_sensor_ctx_t *const  sensor_list,
const size_t  count,
const char *const  name 
)

Search for requested sensor backend in given list of sensors.

Parameters
[in]sensor_listArray of sensors to search the backend from.
[in]countNumber of sensor backends in the list.
[in]nameNULL-terminated, max 9-byte (including trailing NULL) string representation of sensor.
Returns
pointer to requested sensor CTX if found
NULL if requested sensor was not found

◆ rt_sensor_find_provider()

rt_sensor_ctx_t* rt_sensor_find_provider ( rt_sensor_ctx_t *const  sensor_list,
const size_t  count,
rd_sensor_data_fields_t  values 
)

Search for a sensor which can provide requested values.

Parameters
[in]sensor_listArray of sensors to search the backend from.
[in]countNumber of sensor backends in the list.
[in]valuesFields which sensor must provide.
Returns
Pointer to requested sensor CTXif found. If there are many candidates, first is returned
NULL if requested sensor was not found.

◆ rt_sensor_initialize()

rd_status_t rt_sensor_initialize ( rt_sensor_ctx_t *const  sensor)

Initialize sensor CTX.

To initialize a sensor, initialization function, sensor bus and sensor handle must be set. After initialization, sensor control structure is ready to use, initial configuration is set to actual values on sensor.

To configure the sensor, set the sensor configuration in struct and call rt_sensor_configure.

Parameters
[in]sensorSensor to initialize.
Returns
RD_SUCCESS on success.
RD_ERROR_NULL if sensor is NULL.
error code from sensor on other error.

◆ rt_sensor_load()

rd_status_t rt_sensor_load ( rt_sensor_ctx_t *const  sensor)

Load the sensor state from NVM.

Parameters
[in]sensorSensor to store.
Returns
RD_SUCCESS on success.
RD_ERROR_NULL if sensor is NULL.
error code from sensor on other error.

◆ rt_sensor_store()

rd_status_t rt_sensor_store ( rt_sensor_ctx_t *const  sensor)

Store the sensor state to NVM.

Parameters
[in]sensorSensor to store.
Returns
RD_SUCCESS on success.
RD_ERROR_NULL if sensor is NULL.
error code from sensor on other error.