Go to the source code of this file.
- Author
- Otso Jousimaa otso@.nosp@m.ojou.nosp@m.sima..nosp@m.net
- Date
- 2019-20-21
- Copyright
- Ruuvi Innovations Ltd, license BSD-3-Clause.
Helper functions common to all sensors
Definition in file ruuvi_task_sensor.h.
◆ rt_sensor_configure()
Configure a sensor with given settings.
- Parameters
-
[in,out] | sensor | In: Sensor to configure. Out: Sensor->configuration will be set to actual configuration. |
- Return values
-
RD_SUCCESS | on success. |
RD_ERROR_NULL | if sensor is NULL. |
error | code from sensor on other error. |
◆ rt_sensor_find_backend()
Search for requested sensor backend in given list of sensors.
- Parameters
-
[in] | sensor_list | Array of sensors to search the backend from. |
[in] | count | Number of sensor backends in the list. |
[in] | name | NULL-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()
Search for a sensor which can provide requested values.
- Parameters
-
[in] | sensor_list | Array of sensors to search the backend from. |
[in] | count | Number of sensor backends in the list. |
[in] | values | Fields 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()
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] | sensor | Sensor to initialize. |
- Returns
- RD_SUCCESS on success.
-
RD_ERROR_NULL if sensor is NULL.
-
error code from sensor on other error.
◆ rt_sensor_load()
Load the sensor state from NVM.
- Parameters
-
[in] | sensor | Sensor to store. |
- Returns
- RD_SUCCESS on success.
-
RD_ERROR_NULL if sensor is NULL.
-
error code from sensor on other error.
◆ rt_sensor_store()
Store the sensor state to NVM.
- Parameters
-
[in] | sensor | Sensor to store. |
- Returns
- RD_SUCCESS on success.
-
RD_ERROR_NULL if sensor is NULL.
-
error code from sensor on other error.