Skip to content

Commit

Permalink
Merge branch 'sfm_sf06_1.5.0_20240108_1256' into 'master'
Browse files Browse the repository at this point in the history
Update SFM_SF06 driver from Eris-flow model version 1.5.0

See merge request MSO-SW/drivers/embedded/embedded-i2c-sfm-sf06!9
  • Loading branch information
Rol-la committed Jan 15, 2024
2 parents c5fb239 + 73af3bd commit 2d318a9
Show file tree
Hide file tree
Showing 8 changed files with 159 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/sfm_sf06_i2c_example_usage
/example-usage/sfm_sf06_i2c_example_usage
/tests/sfm_sf06_test_hw_i2c
/tests/sfm_sf06_test_sw_i2c
30 changes: 20 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
# Changelog
All notable changes to this project will be documented in this file.
# CHANGELOG

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [Unreleased]

## [1.0.0] - 2023-10-30
## [3.0.0] - 2024-1-10

### Changed

- Update code from driver generator 0.34.0
- Move example and makefile into example-usage directory
- Improve readme
- Use new changelog format
- Add missing User-API function
- Add prefix for global symbols in C/Cpp code
- Renaming of functions
- Move usage examples to another folder
- Update readme

### Fixed

- Fix conversion function to avoid overflow

## [0.1.0] - 2021-10-27

## [0.1.0] - 2021-11-23
### Added

Initial release
- Provide initial version for SFM4300, SFM3xxx sensors

[Unreleased]: https://github.com/Sensirion/embedded-i2c-sfm-sf06/compare/3.0.0...HEAD
[3.0.0]: https://github.com/Sensirion/embedded-i2c-sfm-sf06/compare/0.1.0...3.0.0
[0.1.0]: https://github.com/Sensirion/embedded-i2c-sfm-sf06/releases/tag/0.1.0
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2023, Sensirion AG
Copyright (c) 2024, Sensirion AG
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
6 changes: 3 additions & 3 deletions example-usage/sfm_sf06_i2c_example_usage.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
* Generator: sensirion-driver-generator 0.33.0
* Generator: sensirion-driver-generator 0.37.0
* Product: sfm_sf06
* Model-Version: 1.4.0
* Model-Version: 1.5.0
*/
/*
* Copyright (c) 2023, Sensirion AG
* Copyright (c) 2024, Sensirion AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
6 changes: 3 additions & 3 deletions metadata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generator_version: 0.33.0
model_version: 1.4.0
generator_version: 0.37.0
model_version: 1.5.0
dg_status:
- released
is_manually_modified: true
first_generated: '2021-10-25 11:00'
last_generated: '2023-10-31 15:48'
last_generated: '2024-01-08 12:56'
38 changes: 26 additions & 12 deletions sfm_sf06_i2c.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
* Generator: sensirion-driver-generator 0.33.0
* Generator: sensirion-driver-generator 0.37.0
* Product: sfm_sf06
* Model-Version: 1.4.0
* Model-Version: 1.5.0
*/
/*
* Copyright (c) 2023, Sensirion AG
* Copyright (c) 2024, Sensirion AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -57,7 +57,7 @@ void sfm_sf06_init(uint8_t i2c_address) {
int16_t sfm_sf06_start_o2_continuous_measurement() {
int16_t local_error = 0;
local_error = sfm_sf06_read_scale_offset_unit(
START_O2_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
SFM_SF06_START_O2_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
&_flow_offset, &_flow_unit);
if (local_error != NO_ERROR) {
return local_error;
Expand All @@ -69,7 +69,7 @@ int16_t sfm_sf06_start_o2_continuous_measurement() {
int16_t sfm_sf06_start_air_continuous_measurement() {
int16_t local_error = 0;
local_error = sfm_sf06_read_scale_offset_unit(
START_AIR_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
SFM_SF06_START_AIR_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
&_flow_offset, &_flow_unit);
if (local_error != NO_ERROR) {
return local_error;
Expand All @@ -81,7 +81,7 @@ int16_t sfm_sf06_start_air_continuous_measurement() {
int16_t sfm_sf06_start_n2o_continuous_measurement() {
int16_t local_error = 0;
local_error = sfm_sf06_read_scale_offset_unit(
START_N2O_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
SFM_SF06_START_N2O_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
&_flow_offset, &_flow_unit);
if (local_error != NO_ERROR) {
return local_error;
Expand All @@ -93,7 +93,7 @@ int16_t sfm_sf06_start_n2o_continuous_measurement() {
int16_t sfm_sf06_start_co2_continuous_measurement() {
int16_t local_error = 0;
local_error = sfm_sf06_read_scale_offset_unit(
START_CO2_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
SFM_SF06_START_CO2_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
&_flow_offset, &_flow_unit);
if (local_error != NO_ERROR) {
return local_error;
Expand All @@ -105,8 +105,8 @@ int16_t sfm_sf06_start_co2_continuous_measurement() {
int16_t sfm_sf06_start_n2o_o2_continuous_measurement(uint16_t volume_fraction) {
int16_t local_error = 0;
local_error = sfm_sf06_read_scale_offset_unit(
START_N2O_O2_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
&_flow_offset, &_flow_unit);
SFM_SF06_START_N2O_O2_CONTINUOUS_MEASUREMENT_CMD_ID,
&_flow_scale_factor, &_flow_offset, &_flow_unit);
if (local_error != NO_ERROR) {
return local_error;
}
Expand All @@ -118,8 +118,8 @@ int16_t sfm_sf06_start_n2o_o2_continuous_measurement(uint16_t volume_fraction) {
int16_t sfm_sf06_start_co2_o2_continuous_measurement(uint16_t volume_fraction) {
int16_t local_error = 0;
local_error = sfm_sf06_read_scale_offset_unit(
START_CO2_O2_CONTINUOUS_MEASUREMENT_CMD_ID, &_flow_scale_factor,
&_flow_offset, &_flow_unit);
SFM_SF06_START_CO2_O2_CONTINUOUS_MEASUREMENT_CMD_ID,
&_flow_scale_factor, &_flow_offset, &_flow_unit);
if (local_error != NO_ERROR) {
return local_error;
}
Expand All @@ -128,6 +128,19 @@ int16_t sfm_sf06_start_co2_o2_continuous_measurement(uint16_t volume_fraction) {
return local_error;
}

int16_t sfm_sf06_start_air_o2_continuous_measurement(uint16_t volume_fraction) {
int16_t local_error = 0;
local_error = sfm_sf06_read_scale_offset_unit(
SFM_SF06_START_AIR_O2_CONTINUOUS_MEASUREMENT_CMD_ID,
&_flow_scale_factor, &_flow_offset, &_flow_unit);
if (local_error != NO_ERROR) {
return local_error;
}
local_error =
ll_sfm_sf06_start_air_o2_continuous_measurement(volume_fraction);
return local_error;
}

int16_t sfm_sf06_read_measurement_data_raw(int16_t* flow, int16_t* temperature,
uint16_t* status_word) {
int16_t local_error = 0;
Expand Down Expand Up @@ -205,7 +218,8 @@ int16_t ll_sfm_sf06_start_co2_continuous_measurement() {
return local_error;
}

int16_t sfm_sf06_start_air_o2_continuous_measurement(uint16_t volume_fraction) {
int16_t
ll_sfm_sf06_start_air_o2_continuous_measurement(uint16_t volume_fraction) {
int16_t local_error = NO_ERROR;
uint8_t* buffer_ptr = communication_buffer;
uint16_t local_offset = 0;
Expand Down
126 changes: 103 additions & 23 deletions sfm_sf06_i2c.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
* Generator: sensirion-driver-generator 0.33.0
* Generator: sensirion-driver-generator 0.37.0
* Product: sfm_sf06
* Model-Version: 1.4.0
* Model-Version: 1.5.0
*/
/*
* Copyright (c) 2023, Sensirion AG
* Copyright (c) 2024, Sensirion AG
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -55,27 +55,27 @@ extern "C" {
#define SFM3019_I2C_ADDR_2E 0x2e

typedef enum {
START_O2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3603,
START_AIR_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3608,
START_N2O_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3615,
START_CO2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x361e,
START_AIR_O2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3632,
START_N2O_O2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3639,
START_CO2_O2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3646,
UPDATE_CONCENTRATION_SET_CMD_ID = 0xe17d,
UPDATE_CONCENTRATION_ACTIVATE_CMD_ID = 0xe000,
STOP_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3ff9,
CONFIGURE_AVERAGING_CMD_ID = 0x366a,
READ_SCALE_OFFSET_UNIT_CMD_ID = 0x3661,
ENTER_SLEEP_CMD_ID = 0x3677,
EXIT_SLEEP_CMD_ID = 0x0,
READ_PRODUCT_IDENTIFIER_CMD_ID = 0xe102,
} cmd_id_t;
SFM_SF06_START_O2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3603,
SFM_SF06_START_AIR_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3608,
SFM_SF06_START_N2O_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3615,
SFM_SF06_START_CO2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x361e,
SFM_SF06_START_AIR_O2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3632,
SFM_SF06_START_N2O_O2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3639,
SFM_SF06_START_CO2_O2_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3646,
SFM_SF06_UPDATE_CONCENTRATION_SET_CMD_ID = 0xe17d,
SFM_SF06_UPDATE_CONCENTRATION_ACTIVATE_CMD_ID = 0xe000,
SFM_SF06_STOP_CONTINUOUS_MEASUREMENT_CMD_ID = 0x3ff9,
SFM_SF06_CONFIGURE_AVERAGING_CMD_ID = 0x366a,
SFM_SF06_READ_SCALE_OFFSET_UNIT_CMD_ID = 0x3661,
SFM_SF06_ENTER_SLEEP_CMD_ID = 0x3677,
SFM_SF06_EXIT_SLEEP_CMD_ID = 0x0,
SFM_SF06_READ_PRODUCT_IDENTIFIER_CMD_ID = 0xe102,
} SFM_SF06_CMD_ID;

typedef enum {
ERROR_CODE_I2C_ERROR = 0,
ERROR_CODE_TIMEOUT = 1,
} error_code_t;
SFM_SF06_ERROR_CODE_I2C_ERROR = 0,
SFM_SF06_ERROR_CODE_TIMEOUT = 1,
} sfm_sf06_error_code_t;

/**
* @brief Initialize i2c address of driver
Expand Down Expand Up @@ -134,6 +134,15 @@ int16_t sfm_sf06_start_n2o_o2_continuous_measurement(uint16_t volume_fraction);
*/
int16_t sfm_sf06_start_co2_o2_continuous_measurement(uint16_t volume_fraction);

/**
* @brief Start measurement and update internal state
*
* @param[in] volume_fraction Volume fraction of dioxigen in ‰.
*
* @return error_code 0 on success, an error code otherwise.
*/
int16_t sfm_sf06_start_air_o2_continuous_measurement(uint16_t volume_fraction);

/**
* @brief Rename overwritten function.
*
Expand Down Expand Up @@ -273,8 +282,23 @@ int16_t ll_sfm_sf06_start_co2_continuous_measurement();
* @param[in] volume_fraction Volume fraction of dioxigen in ‰.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sfm_sf06_start_air_o2_continuous_measurement(50);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t sfm_sf06_start_air_o2_continuous_measurement(uint16_t volume_fraction);
int16_t
ll_sfm_sf06_start_air_o2_continuous_measurement(uint16_t volume_fraction);

/**
* @brief Start continuous measurement of N₂O / O₂ mixture.
Expand All @@ -293,6 +317,20 @@ int16_t sfm_sf06_start_air_o2_continuous_measurement(uint16_t volume_fraction);
* @param[in] volume_fraction Volume fraction of O₂ in ‰.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sfm_sf06_start_n2o_o2_continuous_measurement(50);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t
ll_sfm_sf06_start_n2o_o2_continuous_measurement(uint16_t volume_fraction);
Expand All @@ -312,6 +350,20 @@ ll_sfm_sf06_start_n2o_o2_continuous_measurement(uint16_t volume_fraction);
* @param[in] volume_fraction Volume fraction of O₂ in ‰.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sfm_sf06_start_co2_o2_continuous_measurement(50);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t
ll_sfm_sf06_start_co2_o2_continuous_measurement(uint16_t volume_fraction);
Expand Down Expand Up @@ -357,6 +409,20 @@ int16_t sfm_sf06_read_measurement_data(int16_t* flow, int16_t* temperature,
* measurement mode will stop.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sfm_sf06_update_concentration_set(50);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t sfm_sf06_update_concentration_set(uint16_t volume_fraction);

Expand Down Expand Up @@ -409,6 +475,20 @@ int16_t sfm_sf06_stop_continuous_measurement();
* @param[in] average_window Average window configuration value.
*
* @return error_code 0 on success, an error code otherwise.
*
* Example:
* --------
*
* @code{.c}
*
* int16_t local_error = 0;
* local_error = sfm_sf06_configure_averaging(50);
* if (local_error != NO_ERROR) {
* return local_error;
* }
*
* @endcode
*
*/
int16_t sfm_sf06_configure_averaging(uint16_t average_window);

Expand Down
4 changes: 2 additions & 2 deletions tests/sfm_sf06_i2c_test.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* THIS FILE IS AUTOMATICALLY GENERATED
*
* Generator: sensirion-driver-generator 0.33.0
* Generator: sensirion-driver-generator 0.37.0
* Product: sfm_sf06
* Model-Version: 1.4.0
* Model-Version: 1.5.0
*/

#include "sensirion_common.h"
Expand Down

0 comments on commit 2d318a9

Please sign in to comment.