LibDriver SCD4X
Loading...
Searching...
No Matches
scd4x basic driver function

scd4x basic driver modules More...

Collaboration diagram for scd4x basic driver function:

Data Structures

struct  scd4x_handle_s
 scd4x handle structure definition More...
struct  scd4x_info_s
 scd4x information structure definition More...

Typedefs

typedef struct scd4x_handle_s scd4x_handle_t
 scd4x handle structure definition
typedef struct scd4x_info_s scd4x_info_t
 scd4x information structure definition

Enumerations

enum  scd4x_t { SCD40 = 0x00 , SCD41 = 0x01 , SCD43 = 0x02 }
 scd4x type enumeration definition More...
enum  scd4x_bool_t { SCD4X_BOOL_FALSE = 0x00 , SCD4X_BOOL_TRUE = 0x01 }
 scd4x bool enumeration definition More...

Functions

uint8_t scd4x_info (scd4x_info_t *info)
 get chip information
uint8_t scd4x_set_type (scd4x_handle_t *handle, scd4x_t type)
 set type
uint8_t scd4x_get_type (scd4x_handle_t *handle, scd4x_t *type)
 get type
uint8_t scd4x_init (scd4x_handle_t *handle)
 initialize the chip
uint8_t scd4x_deinit (scd4x_handle_t *handle)
 close the chip
uint8_t scd4x_start_periodic_measurement (scd4x_handle_t *handle)
 start periodic measurement
uint8_t scd4x_read (scd4x_handle_t *handle, uint16_t *co2_raw, uint16_t *co2_ppm, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
 read data
uint8_t scd4x_stop_periodic_measurement (scd4x_handle_t *handle)
 stop periodic measurement
uint8_t scd4x_set_temperature_offset (scd4x_handle_t *handle, uint16_t offset)
 set temperature offset
uint8_t scd4x_get_temperature_offset (scd4x_handle_t *handle, uint16_t *offset)
 get temperature offset
uint8_t scd4x_temperature_offset_convert_to_register (scd4x_handle_t *handle, float degrees, uint16_t *reg)
 convert the temperature offset to the register raw data
uint8_t scd4x_temperature_offset_convert_to_data (scd4x_handle_t *handle, uint16_t reg, float *degrees)
 convert the register raw data to the temperature offset
uint8_t scd4x_set_sensor_altitude (scd4x_handle_t *handle, uint16_t altitude)
 set sensor altitude
uint8_t scd4x_get_sensor_altitude (scd4x_handle_t *handle, uint16_t *altitude)
 get sensor altitude
uint8_t scd4x_sensor_altitude_convert_to_register (scd4x_handle_t *handle, float m, uint16_t *reg)
 convert the sensor altitude to the register raw data
uint8_t scd4x_sensor_altitude_convert_to_data (scd4x_handle_t *handle, uint16_t reg, float *m)
 convert the register raw data to the sensor altitude
uint8_t scd4x_set_ambient_pressure (scd4x_handle_t *handle, uint16_t pressure)
 set ambient pressure
uint8_t scd4x_get_ambient_pressure (scd4x_handle_t *handle, uint16_t *pressure)
 get ambient pressure
uint8_t scd4x_ambient_pressure_convert_to_register (scd4x_handle_t *handle, float pa, uint16_t *reg)
 convert the ambient pressure to the register raw data
uint8_t scd4x_ambient_pressure_convert_to_data (scd4x_handle_t *handle, uint16_t reg, float *pa)
 convert the register raw data to the ambient pressure
uint8_t scd4x_perform_forced_recalibration (scd4x_handle_t *handle, uint16_t co2_raw, uint16_t *frc)
 perform forced recalibration
uint8_t scd4x_co2_convert_to_register (scd4x_handle_t *handle, float ppm, uint16_t *reg)
 convert the co2 to the register raw data
uint8_t scd4x_co2_convert_to_data (scd4x_handle_t *handle, uint16_t reg, float *ppm)
 convert the register raw data to the co2
uint8_t scd4x_set_automatic_self_calibration (scd4x_handle_t *handle, scd4x_bool_t enable)
 enable or disable automatic self calibration
uint8_t scd4x_get_automatic_self_calibration (scd4x_handle_t *handle, scd4x_bool_t *enable)
 get automatic self calibration status
uint8_t scd4x_start_low_power_periodic_measurement (scd4x_handle_t *handle)
 start low power periodic measurement
uint8_t scd4x_get_data_ready_status (scd4x_handle_t *handle, scd4x_bool_t *enable)
 get data ready status
uint8_t scd4x_persist_settings (scd4x_handle_t *handle)
 persist settings
uint8_t scd4x_get_serial_number (scd4x_handle_t *handle, uint16_t number[3])
 get serial number
uint8_t scd4x_perform_self_test (scd4x_handle_t *handle, scd4x_bool_t *malfunction_detected)
 perform self test
uint8_t scd4x_perform_factory_reset (scd4x_handle_t *handle)
 perform factory reset
uint8_t scd4x_reinit (scd4x_handle_t *handle)
 reinit

Detailed Description

scd4x basic driver modules

Typedef Documentation

◆ scd4x_handle_t

scd4x handle structure definition

◆ scd4x_info_t

typedef struct scd4x_info_s scd4x_info_t

scd4x information structure definition

Enumeration Type Documentation

◆ scd4x_bool_t

scd4x bool enumeration definition

Enumerator
SCD4X_BOOL_FALSE 

false

SCD4X_BOOL_TRUE 

true

Definition at line 72 of file driver_scd4x.h.

◆ scd4x_t

enum scd4x_t

scd4x type enumeration definition

Enumerator
SCD40 

scd40

SCD41 

scd41

SCD43 

scd43

Definition at line 62 of file driver_scd4x.h.

Function Documentation

◆ scd4x_ambient_pressure_convert_to_data()

uint8_t scd4x_ambient_pressure_convert_to_data ( scd4x_handle_t * handle,
uint16_t reg,
float * pa )

convert the register raw data to the ambient pressure

Parameters
[in]*handlepointer to an scd4x handle structure
[in]regregister raw data
[out]*papointer to a pa buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 846 of file driver_scd4x.c.

◆ scd4x_ambient_pressure_convert_to_register()

uint8_t scd4x_ambient_pressure_convert_to_register ( scd4x_handle_t * handle,
float pa,
uint16_t * reg )

convert the ambient pressure to the register raw data

Parameters
[in]*handlepointer to an scd4x handle structure
[in]paset pa
[out]*regpointer to a register raw buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 819 of file driver_scd4x.c.

◆ scd4x_co2_convert_to_data()

uint8_t scd4x_co2_convert_to_data ( scd4x_handle_t * handle,
uint16_t reg,
float * ppm )

convert the register raw data to the co2

Parameters
[in]*handlepointer to an scd4x handle structure
[in]regregister raw data
[out]*ppmpointer to a ppm buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 950 of file driver_scd4x.c.

◆ scd4x_co2_convert_to_register()

uint8_t scd4x_co2_convert_to_register ( scd4x_handle_t * handle,
float ppm,
uint16_t * reg )

convert the co2 to the register raw data

Parameters
[in]*handlepointer to an scd4x handle structure
[in]ppmset ppm
[out]*regpointer to a register raw buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 923 of file driver_scd4x.c.

◆ scd4x_deinit()

uint8_t scd4x_deinit ( scd4x_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to an scd4x handle structure
Returns
status code
  • 0 success
  • 1 iic deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 stop periodic measurement failed
Note
none

Definition at line 1800 of file driver_scd4x.c.

◆ scd4x_get_ambient_pressure()

uint8_t scd4x_get_ambient_pressure ( scd4x_handle_t * handle,
uint16_t * pressure )

get ambient pressure

Parameters
[in]*handlepointer to an scd4x handle structure
[out]*pressurepointer to a pressure buffer
Returns
status code
  • 0 success
  • 1 get ambient pressure failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
Note
none

Definition at line 776 of file driver_scd4x.c.

◆ scd4x_get_automatic_self_calibration()

uint8_t scd4x_get_automatic_self_calibration ( scd4x_handle_t * handle,
scd4x_bool_t * enable )

get automatic self calibration status

Parameters
[in]*handlepointer to an scd4x handle structure
[out]*enablepointer to a bool buffer
Returns
status code
  • 0 success
  • 1 get automatic self calibration failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
Note
none

Definition at line 1020 of file driver_scd4x.c.

◆ scd4x_get_data_ready_status()

uint8_t scd4x_get_data_ready_status ( scd4x_handle_t * handle,
scd4x_bool_t * enable )

get data ready status

Parameters
[in]*handlepointer to an scd4x handle structure
[out]*enablepointer to a bool buffer
Returns
status code
  • 0 success
  • 1 get data ready status failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
Note
none

Definition at line 1100 of file driver_scd4x.c.

◆ scd4x_get_sensor_altitude()

uint8_t scd4x_get_sensor_altitude ( scd4x_handle_t * handle,
uint16_t * altitude )

get sensor altitude

Parameters
[in]*handlepointer to an scd4x handle structure
[out]*altitudepointer to an altitude buffer
Returns
status code
  • 0 success
  • 1 get sensor altitude failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
Note
none

Definition at line 638 of file driver_scd4x.c.

◆ scd4x_get_serial_number()

uint8_t scd4x_get_serial_number ( scd4x_handle_t * handle,
uint16_t number[3] )

get serial number

Parameters
[in]*handlepointer to an scd4x handle structure
[out]*numberpointer to a number buffer
Returns
status code
  • 0 success
  • 1 get serial number failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
Note
none

Definition at line 1188 of file driver_scd4x.c.

◆ scd4x_get_temperature_offset()

uint8_t scd4x_get_temperature_offset ( scd4x_handle_t * handle,
uint16_t * offset )

get temperature offset

Parameters
[in]*handlepointer to an scd4x handle structure
[out]*offsetpointer to a temperature offset buffer
Returns
status code
  • 0 success
  • 1 get temperature offset failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
Note
none

Definition at line 500 of file driver_scd4x.c.

◆ scd4x_get_type()

uint8_t scd4x_get_type ( scd4x_handle_t * handle,
scd4x_t * type )

get type

Parameters
[in]*handlepointer to an scd4x handle structure
[out]*typepointer to a chip type buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 274 of file driver_scd4x.c.

◆ scd4x_info()

uint8_t scd4x_info ( scd4x_info_t * info)

get chip information

Parameters
[out]*infopointer to an scd4x info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 1894 of file driver_scd4x.c.

◆ scd4x_init()

uint8_t scd4x_init ( scd4x_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to an scd4x handle structure
Returns
status code
  • 0 success
  • 1 iic initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
Note
none

Definition at line 1737 of file driver_scd4x.c.

◆ scd4x_perform_factory_reset()

uint8_t scd4x_perform_factory_reset ( scd4x_handle_t * handle)

perform factory reset

Parameters
[in]*handlepointer to an scd4x handle structure
Returns
status code
  • 0 success
  • 1 perform factory reset failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1297 of file driver_scd4x.c.

◆ scd4x_perform_forced_recalibration()

uint8_t scd4x_perform_forced_recalibration ( scd4x_handle_t * handle,
uint16_t co2_raw,
uint16_t * frc )

perform forced recalibration

Parameters
[in]*handlepointer to an scd4x handle structure
[in]co2_rawco2 raw data
[out]*frcpointer to a frc buffer
Returns
status code
  • 0 success
  • 1 perform forced recalibration failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
Note
none

Definition at line 875 of file driver_scd4x.c.

◆ scd4x_perform_self_test()

uint8_t scd4x_perform_self_test ( scd4x_handle_t * handle,
scd4x_bool_t * malfunction_detected )

perform self test

Parameters
[in]*handlepointer to an scd4x handle structure
[out]*malfunction_detectedpointer to a bool value buffer
Returns
status code
  • 0 success
  • 1 perform self test failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
Note
none

Definition at line 1246 of file driver_scd4x.c.

◆ scd4x_persist_settings()

uint8_t scd4x_persist_settings ( scd4x_handle_t * handle)

persist settings

Parameters
[in]*handlepointer to an scd4x handle structure
Returns
status code
  • 0 success
  • 1 persist settings failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1151 of file driver_scd4x.c.

◆ scd4x_read()

uint8_t scd4x_read ( scd4x_handle_t * handle,
uint16_t * co2_raw,
uint16_t * co2_ppm,
uint16_t * temperature_raw,
float * temperature_s,
uint16_t * humidity_raw,
float * humidity_s )

read data

Parameters
[in]*handlepointer to an scd4x handle structure
[out]*co2_rawpointer to a co2 raw buffer
[out]*co2_ppmpointer to a co2 ppm buffer
[out]*temperature_rawpointer to a temperature raw buffer
[out]*temperature_spointer to a temperature buffer
[out]*humidity_rawpointer to a humidity raw buffer
[out]*humidity_spointer to a humidity buffer
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 crc is error
  • 5 data is not ready
Note
none

Definition at line 338 of file driver_scd4x.c.

◆ scd4x_reinit()

uint8_t scd4x_reinit ( scd4x_handle_t * handle)

reinit

Parameters
[in]*handlepointer to an scd4x handle structure
Returns
status code
  • 0 success
  • 1 reinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1332 of file driver_scd4x.c.

◆ scd4x_sensor_altitude_convert_to_data()

uint8_t scd4x_sensor_altitude_convert_to_data ( scd4x_handle_t * handle,
uint16_t reg,
float * m )

convert the register raw data to the sensor altitude

Parameters
[in]*handlepointer to an scd4x handle structure
[in]regregister raw data
[out]*mpointer to an m buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 708 of file driver_scd4x.c.

◆ scd4x_sensor_altitude_convert_to_register()

uint8_t scd4x_sensor_altitude_convert_to_register ( scd4x_handle_t * handle,
float m,
uint16_t * reg )

convert the sensor altitude to the register raw data

Parameters
[in]*handlepointer to an scd4x handle structure
[in]mset m
[out]*regpointer to a register raw buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 681 of file driver_scd4x.c.

◆ scd4x_set_ambient_pressure()

uint8_t scd4x_set_ambient_pressure ( scd4x_handle_t * handle,
uint16_t pressure )

set ambient pressure

Parameters
[in]*handlepointer to an scd4x handle structure
[in]pressureset pressure
Returns
status code
  • 0 success
  • 1 set ambient pressure failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 735 of file driver_scd4x.c.

◆ scd4x_set_automatic_self_calibration()

uint8_t scd4x_set_automatic_self_calibration ( scd4x_handle_t * handle,
scd4x_bool_t enable )

enable or disable automatic self calibration

Parameters
[in]*handlepointer to an scd4x handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 1 set automatic self calibration failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 977 of file driver_scd4x.c.

◆ scd4x_set_sensor_altitude()

uint8_t scd4x_set_sensor_altitude ( scd4x_handle_t * handle,
uint16_t altitude )

set sensor altitude

Parameters
[in]*handlepointer to an scd4x handle structure
[in]altitudeset altitude
Returns
status code
  • 0 success
  • 1 set sensor altitude failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 597 of file driver_scd4x.c.

◆ scd4x_set_temperature_offset()

uint8_t scd4x_set_temperature_offset ( scd4x_handle_t * handle,
uint16_t offset )

set temperature offset

Parameters
[in]*handlepointer to an scd4x handle structure
[in]offsettemperature offset
Returns
status code
  • 0 success
  • 1 set temperature offset failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 459 of file driver_scd4x.c.

◆ scd4x_set_type()

uint8_t scd4x_set_type ( scd4x_handle_t * handle,
scd4x_t type )

set type

Parameters
[in]*handlepointer to an scd4x handle structure
[in]typechip type
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 253 of file driver_scd4x.c.

◆ scd4x_start_low_power_periodic_measurement()

uint8_t scd4x_start_low_power_periodic_measurement ( scd4x_handle_t * handle)

start low power periodic measurement

Parameters
[in]*handlepointer to an scd4x handle structure
Returns
status code
  • 0 success
  • 1 start low power periodic measurement failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1064 of file driver_scd4x.c.

◆ scd4x_start_periodic_measurement()

uint8_t scd4x_start_periodic_measurement ( scd4x_handle_t * handle)

start periodic measurement

Parameters
[in]*handlepointer to an scd4x handle structure
Returns
status code
  • 0 success
  • 1 start periodic measurement failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 296 of file driver_scd4x.c.

◆ scd4x_stop_periodic_measurement()

uint8_t scd4x_stop_periodic_measurement ( scd4x_handle_t * handle)

stop periodic measurement

Parameters
[in]*handlepointer to an scd4x handle structure
Returns
status code
  • 0 success
  • 1 stop periodic measurement failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 423 of file driver_scd4x.c.

◆ scd4x_temperature_offset_convert_to_data()

uint8_t scd4x_temperature_offset_convert_to_data ( scd4x_handle_t * handle,
uint16_t reg,
float * degrees )

convert the register raw data to the temperature offset

Parameters
[in]*handlepointer to an scd4x handle structure
[in]regregister raw data
[out]*degreespointer to a temperature offset buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 570 of file driver_scd4x.c.

◆ scd4x_temperature_offset_convert_to_register()

uint8_t scd4x_temperature_offset_convert_to_register ( scd4x_handle_t * handle,
float degrees,
uint16_t * reg )

convert the temperature offset to the register raw data

Parameters
[in]*handlepointer to an scd4x handle structure
[in]degreesset degrees
[out]*regpointer to a register raw buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 543 of file driver_scd4x.c.