LibDriver STS21
Loading...
Searching...
No Matches
driver_sts21.c File Reference

driver sts21 source file More...

#include "driver_sts21.h"
Include dependency graph for driver_sts21.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "Sensirion STS21"
 chip information definition
#define MANUFACTURER_NAME   "Sensirion"
#define SUPPLY_VOLTAGE_MIN   2.1f
#define SUPPLY_VOLTAGE_MAX   3.6f
#define MAX_CURRENT   0.33f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   125.0f
#define DRIVER_VERSION   1000
#define STS21_COMMAND_TRIGGER_T_MEASUREMENT_HOLD_MASTER   0xE3
 chip command definition
#define STS21_COMMAND_TRIGGER_T_MEASUREMENT_NO_HOLD_MASTER   0xF3
#define STS21_COMMAND_WRITE_REG   0xE6
#define STS21_COMMAND_READ_REG   0xE7
#define STS21_COMMAND_SOFT_RESET   0xFE
#define STS21_COMMAND_GET_SN1   0xFA0FU
#define STS21_COMMAND_GET_SN2   0xFCC9U
#define STS21_ADDRESS   0x94
 chip address definition

Functions

uint8_t sts21_init (sts21_handle_t *handle)
 initialize the chip
uint8_t sts21_deinit (sts21_handle_t *handle)
 close the chip
uint8_t sts21_soft_reset (sts21_handle_t *handle)
 soft reset the chip
uint8_t sts21_set_resolution (sts21_handle_t *handle, sts21_resolution_t resolution)
 set resolution
uint8_t sts21_get_resolution (sts21_handle_t *handle, sts21_resolution_t *resolution)
 get resolution
uint8_t sts21_set_heater (sts21_handle_t *handle, sts21_bool_t enable)
 enable or disable heater
uint8_t sts21_get_heater (sts21_handle_t *handle, sts21_bool_t *enable)
 get heater status
uint8_t sts21_set_disable_otp_reload (sts21_handle_t *handle, sts21_bool_t enable)
 enable or disable disable otp reload
uint8_t sts21_get_disable_otp_reload (sts21_handle_t *handle, sts21_bool_t *enable)
 get disable otp reload status
uint8_t sts21_get_status (sts21_handle_t *handle, sts21_status_t *status)
 get status
uint8_t sts21_set_mode (sts21_handle_t *handle, sts21_mode_t mode)
 set chip mode
uint8_t sts21_get_mode (sts21_handle_t *handle, sts21_mode_t *mode)
 get chip mode
uint8_t sts21_read (sts21_handle_t *handle, uint16_t *temperature_raw, float *temperature_s)
 read data
uint8_t sts21_get_serial_number (sts21_handle_t *handle, uint8_t sn[8])
 get serial number
uint8_t sts21_set_reg (sts21_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
 set the chip register
uint8_t sts21_get_reg (sts21_handle_t *handle, uint8_t reg, uint8_t *data, uint16_t len)
 get the chip register
uint8_t sts21_get_reg16 (sts21_handle_t *handle, uint16_t reg, uint8_t *data, uint16_t len)
 get the chip register16
uint8_t sts21_set_cmd (sts21_handle_t *handle, uint8_t *data, uint16_t len)
 set command
uint8_t sts21_get_cmd (sts21_handle_t *handle, uint8_t *data, uint16_t len)
 get command
uint8_t sts21_info (sts21_info_t *info)
 get chip's information

Detailed Description

driver sts21 source file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2025-07-30

history

Date Version Author Description
2025/07/30 1.0 Shifeng Li first upload

Definition in file driver_sts21.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Sensirion STS21"

chip information definition

chip name

Definition at line 42 of file driver_sts21.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_sts21.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Sensirion"

manufacturer name

Definition at line 43 of file driver_sts21.c.

◆ MAX_CURRENT

#define MAX_CURRENT   0.33f

chip max current

Definition at line 46 of file driver_sts21.c.

◆ STS21_ADDRESS

#define STS21_ADDRESS   0x94

chip address definition

iic device address

Definition at line 65 of file driver_sts21.c.

◆ STS21_COMMAND_GET_SN1

#define STS21_COMMAND_GET_SN1   0xFA0FU

read from memory location 1 command

Definition at line 59 of file driver_sts21.c.

◆ STS21_COMMAND_GET_SN2

#define STS21_COMMAND_GET_SN2   0xFCC9U

read from memory location 2 command

Definition at line 60 of file driver_sts21.c.

◆ STS21_COMMAND_READ_REG

#define STS21_COMMAND_READ_REG   0xE7

read user register command

Definition at line 57 of file driver_sts21.c.

◆ STS21_COMMAND_SOFT_RESET

#define STS21_COMMAND_SOFT_RESET   0xFE

soft reset command

Definition at line 58 of file driver_sts21.c.

◆ STS21_COMMAND_TRIGGER_T_MEASUREMENT_HOLD_MASTER

#define STS21_COMMAND_TRIGGER_T_MEASUREMENT_HOLD_MASTER   0xE3

chip command definition

trigger t measurement hold master command

Definition at line 54 of file driver_sts21.c.

◆ STS21_COMMAND_TRIGGER_T_MEASUREMENT_NO_HOLD_MASTER

#define STS21_COMMAND_TRIGGER_T_MEASUREMENT_NO_HOLD_MASTER   0xF3

trigger t measurement no hold master command

Definition at line 55 of file driver_sts21.c.

◆ STS21_COMMAND_WRITE_REG

#define STS21_COMMAND_WRITE_REG   0xE6

write user register command

Definition at line 56 of file driver_sts21.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   3.6f

chip max supply voltage

Definition at line 45 of file driver_sts21.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   2.1f

chip min supply voltage

Definition at line 44 of file driver_sts21.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   125.0f

chip max operating temperature

Definition at line 48 of file driver_sts21.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 47 of file driver_sts21.c.