LibDriver HTU21D
Loading...
Searching...
No Matches
driver_htu21d.c File Reference

driver htu21d source file More...

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

Go to the source code of this file.

Macros

#define CHIP_NAME   "TE HTU21D"
 chip information definition
#define MANUFACTURER_NAME   "TE"
#define SUPPLY_VOLTAGE_MIN   1.5f
#define SUPPLY_VOLTAGE_MAX   3.6f
#define MAX_CURRENT   0.5f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   125.0f
#define DRIVER_VERSION   1000
#define HTU21D_ADDRESS   0x80
 chip address definition
#define HTU21D_COMMAND_TRIG_TEMP_HOLD_MASTER   0xE3
 chip command definition
#define HTU21D_COMMAND_TRIG_HUMI_HOLD_MASTER   0xE5
#define HTU21D_COMMAND_TRIG_TEMP_NO_HOLD_MASTER   0xF3
#define HTU21D_COMMAND_TRIG_HUMI_NO_HOLD_MASTER   0xF5
#define HTU21D_COMMAND_WRITE_USER_REGISTER   0xE6
#define HTU21D_COMMAND_READ_USER_REGISTER   0xE7
#define HTU21D_COMMAND_SOFT_RESET   0xFE

Functions

uint8_t htu21d_set_mode (htu21d_handle_t *handle, htu21d_mode_t mode)
 set the chip mode
uint8_t htu21d_get_mode (htu21d_handle_t *handle, htu21d_mode_t *mode)
 get the chip mode
uint8_t htu21d_soft_reset (htu21d_handle_t *handle)
 soft reset
uint8_t htu21d_read_temperature_humidity (htu21d_handle_t *handle, uint16_t *temperature_raw, float *temperature_s, uint16_t *humidity_raw, float *humidity_s)
 read the temperature and humidity data
uint8_t htu21d_read_temperature (htu21d_handle_t *handle, uint16_t *temperature_raw, float *temperature_s)
 read the temperature data
uint8_t htu21d_read_humidity (htu21d_handle_t *handle, uint16_t *humidity_raw, float *humidity_s)
 read the humidity data
uint8_t htu21d_set_resolution (htu21d_handle_t *handle, htu21d_resolution_t resolution)
 set the resolution
uint8_t htu21d_get_resolution (htu21d_handle_t *handle, htu21d_resolution_t *resolution)
 get the resolution
uint8_t htu21d_get_battery_status (htu21d_handle_t *handle, htu21d_status_t *status)
 get the battery status
uint8_t htu21d_set_heater (htu21d_handle_t *handle, htu21d_bool_t enable)
 enable or disable the heater
uint8_t htu21d_get_heater (htu21d_handle_t *handle, htu21d_bool_t *enable)
 get the heater status
uint8_t htu21d_set_disable_otp_reload (htu21d_handle_t *handle, htu21d_bool_t enable)
 enable or disable otp reload
uint8_t htu21d_get_disable_otp_reload (htu21d_handle_t *handle, htu21d_bool_t *enable)
 get the disable otp reload status
uint8_t htu21d_get_serial_number (htu21d_handle_t *handle, uint64_t *number)
 get the serial number
uint8_t htu21d_init (htu21d_handle_t *handle)
 initialize the chip
uint8_t htu21d_deinit (htu21d_handle_t *handle)
 close the chip
uint8_t htu21d_set_reg (htu21d_handle_t *handle, uint8_t *buf, uint16_t len)
 set the chip register
uint8_t htu21d_get_reg (htu21d_handle_t *handle, uint8_t *buf, uint16_t len)
 get the chip register
uint8_t htu21d_info (htu21d_info_t *info)
 get chip's information

Detailed Description

driver htu21d 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
2022-10-31

history

Date Version Author Description
2022/10/31 1.0 Shifeng Li first upload

Definition in file driver_htu21d.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "TE HTU21D"

chip information definition

chip name

Definition at line 42 of file driver_htu21d.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 49 of file driver_htu21d.c.

◆ HTU21D_ADDRESS

#define HTU21D_ADDRESS   0x80

chip address definition

iic device address

Definition at line 54 of file driver_htu21d.c.

◆ HTU21D_COMMAND_READ_USER_REGISTER

#define HTU21D_COMMAND_READ_USER_REGISTER   0xE7

read user register command

Definition at line 64 of file driver_htu21d.c.

◆ HTU21D_COMMAND_SOFT_RESET

#define HTU21D_COMMAND_SOFT_RESET   0xFE

soft reset command

Definition at line 65 of file driver_htu21d.c.

◆ HTU21D_COMMAND_TRIG_HUMI_HOLD_MASTER

#define HTU21D_COMMAND_TRIG_HUMI_HOLD_MASTER   0xE5

trigger humidity measurement with hold master command

Definition at line 60 of file driver_htu21d.c.

◆ HTU21D_COMMAND_TRIG_HUMI_NO_HOLD_MASTER

#define HTU21D_COMMAND_TRIG_HUMI_NO_HOLD_MASTER   0xF5

trigger humidity measurement command

Definition at line 62 of file driver_htu21d.c.

◆ HTU21D_COMMAND_TRIG_TEMP_HOLD_MASTER

#define HTU21D_COMMAND_TRIG_TEMP_HOLD_MASTER   0xE3

chip command definition

trigger temperature measurement with hold master command

Definition at line 59 of file driver_htu21d.c.

◆ HTU21D_COMMAND_TRIG_TEMP_NO_HOLD_MASTER

#define HTU21D_COMMAND_TRIG_TEMP_NO_HOLD_MASTER   0xF3

trigger temperature measurement command

Definition at line 61 of file driver_htu21d.c.

◆ HTU21D_COMMAND_WRITE_USER_REGISTER

#define HTU21D_COMMAND_WRITE_USER_REGISTER   0xE6

write user register command

Definition at line 63 of file driver_htu21d.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "TE"

manufacturer name

Definition at line 43 of file driver_htu21d.c.

◆ MAX_CURRENT

#define MAX_CURRENT   0.5f

chip max current

Definition at line 46 of file driver_htu21d.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   3.6f

chip max supply voltage

Definition at line 45 of file driver_htu21d.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   1.5f

chip min supply voltage

Definition at line 44 of file driver_htu21d.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   125.0f

chip max operating temperature

Definition at line 48 of file driver_htu21d.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 47 of file driver_htu21d.c.