Line data Source code
1 0 : /* 2 : * Copyright (c) 2024 Jan Fäh 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : #ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_SCD4X_H_ 8 : #define ZEPHYR_INCLUDE_DRIVERS_SENSOR_SCD4X_H_ 9 : 10 : #include <zephyr/drivers/sensor.h> 11 : 12 0 : enum sensor_attribute_scd4x { 13 : /* Offset temperature: Toffset_actual = Tscd4x – Treference + Toffset_previous 14 : * 0 - 20°C 15 : */ 16 : SENSOR_ATTR_SCD4X_TEMPERATURE_OFFSET = SENSOR_ATTR_PRIV_START, 17 : /* Altidude of the sensor; 18 : * 0 - 3000m 19 : */ 20 : SENSOR_ATTR_SCD4X_SENSOR_ALTITUDE, 21 : /* Ambient pressure in hPa 22 : * 700 - 1200hPa 23 : */ 24 : SENSOR_ATTR_SCD4X_AMBIENT_PRESSURE, 25 : /* Set the current state (enabled: 1 / disabled: 0). 26 : * Default: enabled. 27 : */ 28 : SENSOR_ATTR_SCD4X_AUTOMATIC_CALIB_ENABLE, 29 : /* Set the initial period for automatic self calibration correction in hours. Allowed values 30 : * are integer multiples of 4 hours. 31 : * Default: 44 32 : */ 33 : SENSOR_ATTR_SCD4X_SELF_CALIB_INITIAL_PERIOD, 34 : /* Set the standard period for automatic self calibration correction in hours. Allowed 35 : * values are integer multiples of 4 hours. Default: 156 36 : */ 37 : SENSOR_ATTR_SCD4X_SELF_CALIB_STANDARD_PERIOD, 38 : }; 39 : 40 : /** 41 : * @brief Performs a forced recalibration. 42 : * 43 : * Operate the SCD4x in the operation mode for at least 3 minutes in an environment with a 44 : * homogeneous and constant CO2 concentration. Otherwise the recalibratioin will fail. The sensor 45 : * must be operated at the voltage desired for the application when performing the FRC sequence. 46 : * 47 : * @param dev Pointer to the sensor device 48 : * @param target_concentration Reference CO2 concentration. 49 : * @param frc_correction Previous differences from the target concentration 50 : * 51 : * @return 0 if successful, negative errno code if failure. 52 : */ 53 1 : int scd4x_forced_recalibration(const struct device *dev, uint16_t target_concentration, 54 : uint16_t *frc_correction); 55 : 56 : /** 57 : * @brief Performs a self test. 58 : * 59 : * The self_test command can be used as an end-of-line test to check the sensor functionality 60 : * 61 : * @param dev Pointer to the sensor device 62 : * 63 : * @return 0 if successful, negative errno code if failure. 64 : */ 65 1 : int scd4x_self_test(const struct device *dev); 66 : 67 : /** 68 : * @brief Performs a self test. 69 : * 70 : * The persist_settings command can be used to save the actual configuration. This command 71 : * should only be sent when persistence is required and if actual changes to the configuration have 72 : * been made. The EEPROM is guaranteed to withstand at least 2000 write cycles 73 : * 74 : * @param dev Pointer to the sensor device 75 : * 76 : * @return 0 if successful, negative errno code if failure. 77 : */ 78 1 : int scd4x_persist_settings(const struct device *dev); 79 : 80 : /** 81 : * @brief Performs a factory reset. 82 : * 83 : * The perform_factory_reset command resets all configuration settings stored in the EEPROM and 84 : * erases the FRC and ASC algorithm history. 85 : * 86 : * @param dev Pointer to the sensor device 87 : * 88 : * @return 0 if successful, negative errno code if failure. 89 : */ 90 1 : int scd4x_factory_reset(const struct device *dev); 91 : 92 : #endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_SCD4X_H_ */