ruuvi.drivers.c  ${PROJECT_VERSION}
Drivers for external sensors and peripherals on embedded systems.
SHTCX Interface

Implement rd_sensor_t functions on SHTCX. More...

Macros

#define LOW_POWER_SLEEP_MS_MIN   (1000U)
 
#define SHTCX_PROBE_RETRIES_MAX   (5U)
 
#define RETURN_SUCCESS_ON_VALID(param)
 Macro for checking "ignored" parameters NO_CHANGE, MIN, MAX, DEFAULT. More...
 
#define VERIFY_SENSOR_SLEEPS()
 Macro for checking that sensor is in sleep mode before configuration. More...
 
#define STATUS_OK   0
 SHTC driver ok. More...
 
#define STATUS_ERR_BAD_DATA   (-1)
 SHTC driver data invald. More...
 
#define STATUS_CRC_FAIL   (-2)
 SHTC driver CRC error. More...
 
#define STATUS_UNKNOWN_DEVICE   (-3)
 Invalid WHOAMI. More...
 
#define STATUS_WAKEUP_FAILED   (-4)
 Device didn't wake up. More...
 
#define STATUS_SLEEP_FAILED   (-5)
 Device didn't go to sleep. More...
 

Functions

rd_status_t ri_shtcx_init (rd_sensor_t *sensor, rd_bus_t bus, uint8_t handle)
 rd_sensor_init_fp More...
 
rd_status_t ri_shtcx_uninit (rd_sensor_t *sensor, rd_bus_t bus, uint8_t handle)
 rd_sensor_init_fp More...
 
rd_status_t ri_shtcx_samplerate_set (uint8_t *samplerate)
 rd_sensor_setup_fp More...
 
rd_status_t ri_shtcx_samplerate_get (uint8_t *samplerate)
 rd_sensor_setup_fp More...
 
rd_status_t ri_shtcx_resolution_set (uint8_t *resolution)
 rd_sensor_setup_fp More...
 
rd_status_t ri_shtcx_resolution_get (uint8_t *resolution)
 rd_sensor_setup_fp More...
 
rd_status_t ri_shtcx_scale_set (uint8_t *scale)
 rd_sensor_setup_fp More...
 
rd_status_t ri_shtcx_scale_get (uint8_t *scale)
 rd_sensor_setup_fp More...
 
rd_status_t ri_shtcx_dsp_set (uint8_t *dsp, uint8_t *parameter)
 rd_sensor_setup_fp More...
 
rd_status_t ri_shtcx_dsp_get (uint8_t *dsp, uint8_t *parameter)
 
rd_status_t ri_shtcx_mode_set (uint8_t *mode)
 rd_sensor_setup_fp More...
 
rd_status_t ri_shtcx_mode_get (uint8_t *mode)
 rd_sensor_setup_fp More...
 
rd_status_t ri_shtcx_data_get (rd_sensor_data_t *const p_data)
 rd_sensor_data_fp More...
 
void sensirion_sleep_usec (uint32_t useconds)
 Implement sleep function for SHTC driver. More...
 

Detailed Description

Implement rd_sensor_t functions on SHTCX.

The implementation supports taking single-samples and a pseudo-continuous mode by taking a new sample when data is polled in continuous mode

Macro Definition Documentation

◆ LOW_POWER_SLEEP_MS_MIN

#define LOW_POWER_SLEEP_MS_MIN   (1000U)

Definition at line 32 of file ruuvi_interface_shtcx.c.

◆ RETURN_SUCCESS_ON_VALID

#define RETURN_SUCCESS_ON_VALID (   param)
Value:
do {\
if(RD_SENSOR_CFG_DEFAULT == param ||\
RD_SENSOR_CFG_MIN == param ||\
RD_SENSOR_CFG_MAX == param ||\
) return RD_SUCCESS;\
} while(0)
#define RD_SUCCESS
Internal Error.
#define RD_SENSOR_CFG_MAX
Configure largest supported and implemented value.
#define RD_SENSOR_CFG_DEFAULT
Default value, always valid for the sensor.
#define RD_SENSOR_CFG_MIN
Configure smallest supported and implemented value.
#define RD_SENSOR_CFG_NO_CHANGE
Do not change configured value.

Macro for checking "ignored" parameters NO_CHANGE, MIN, MAX, DEFAULT.

Definition at line 41 of file ruuvi_interface_shtcx.c.

◆ SHTCX_PROBE_RETRIES_MAX

#define SHTCX_PROBE_RETRIES_MAX   (5U)

Definition at line 33 of file ruuvi_interface_shtcx.c.

◆ STATUS_CRC_FAIL

#define STATUS_CRC_FAIL   (-2)

SHTC driver CRC error.

Definition at line 65 of file ruuvi_interface_shtcx.c.

◆ STATUS_ERR_BAD_DATA

#define STATUS_ERR_BAD_DATA   (-1)

SHTC driver data invald.

Definition at line 64 of file ruuvi_interface_shtcx.c.

◆ STATUS_OK

#define STATUS_OK   0

SHTC driver ok.

Definition at line 63 of file ruuvi_interface_shtcx.c.

◆ STATUS_SLEEP_FAILED

#define STATUS_SLEEP_FAILED   (-5)

Device didn't go to sleep.

Definition at line 68 of file ruuvi_interface_shtcx.c.

◆ STATUS_UNKNOWN_DEVICE

#define STATUS_UNKNOWN_DEVICE   (-3)

Invalid WHOAMI.

Definition at line 66 of file ruuvi_interface_shtcx.c.

◆ STATUS_WAKEUP_FAILED

#define STATUS_WAKEUP_FAILED   (-4)

Device didn't wake up.

Definition at line 67 of file ruuvi_interface_shtcx.c.

◆ VERIFY_SENSOR_SLEEPS

#define VERIFY_SENSOR_SLEEPS ( )
Value:
do { \
uint8_t MACRO_MODE = 0; \
ri_shtcx_mode_get(&MACRO_MODE); \
if(RD_SENSOR_CFG_SLEEP != MACRO_MODE) { return RD_ERROR_INVALID_STATE; } \
} while(0)
#define RD_ERROR_INVALID_STATE
Invalid state, operation disallowed in this state.
#define RD_SENSOR_CFG_SLEEP
Sensor should go to sleep immediately.

Macro for checking that sensor is in sleep mode before configuration.

Definition at line 50 of file ruuvi_interface_shtcx.c.

Function Documentation

◆ ri_shtcx_data_get()

rd_status_t ri_shtcx_data_get ( rd_sensor_data_t *const  p_data)

rd_sensor_data_fp

Definition at line 337 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_dsp_get()

rd_status_t ri_shtcx_dsp_get ( uint8_t *  dsp,
uint8_t *  parameter 
)

Definition at line 258 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_dsp_set()

rd_status_t ri_shtcx_dsp_set ( uint8_t *  dsp,
uint8_t *  parameter 
)

rd_sensor_setup_fp

Definition at line 240 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_init()

rd_status_t ri_shtcx_init ( rd_sensor_t sensor,
rd_bus_t  bus,
uint8_t  handle 
)

rd_sensor_init_fp

Definition at line 91 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_mode_get()

rd_status_t ri_shtcx_mode_get ( uint8_t *  mode)

rd_sensor_setup_fp

Definition at line 320 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_mode_set()

rd_status_t ri_shtcx_mode_set ( uint8_t *  mode)

rd_sensor_setup_fp

Definition at line 269 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_resolution_get()

rd_status_t ri_shtcx_resolution_get ( uint8_t *  resolution)

rd_sensor_setup_fp

Definition at line 213 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_resolution_set()

rd_status_t ri_shtcx_resolution_set ( uint8_t *  resolution)

rd_sensor_setup_fp

Definition at line 202 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_samplerate_get()

rd_status_t ri_shtcx_samplerate_get ( uint8_t *  samplerate)

rd_sensor_setup_fp

Definition at line 194 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_samplerate_set()

rd_status_t ri_shtcx_samplerate_set ( uint8_t *  samplerate)

rd_sensor_setup_fp

Definition at line 178 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_scale_get()

rd_status_t ri_shtcx_scale_get ( uint8_t *  scale)

rd_sensor_setup_fp

Definition at line 232 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_scale_set()

rd_status_t ri_shtcx_scale_set ( uint8_t *  scale)

rd_sensor_setup_fp

Definition at line 221 of file ruuvi_interface_shtcx.c.

◆ ri_shtcx_uninit()

rd_status_t ri_shtcx_uninit ( rd_sensor_t sensor,
rd_bus_t  bus,
uint8_t  handle 
)

rd_sensor_init_fp

Definition at line 161 of file ruuvi_interface_shtcx.c.

◆ sensirion_sleep_usec()

void sensirion_sleep_usec ( uint32_t  useconds)

Implement sleep function for SHTC driver.

Sleep for a given number of microseconds. The function should delay the execution for at least the given time, but may also sleep longer.

If delay is at least millisecond, The function sleeps given number of milliseconds, rounded up, to benefit from low-power sleep in millisecond delay.

Parameters
[in]usecondsthe sleep time in microseconds
Note
sensirion interface signature isn't const, can't be const here.

Definition at line 395 of file ruuvi_interface_shtcx.c.