Added sht4.c, sht4x.h
This commit is contained in:
53
sht4x.h
Normal file
53
sht4x.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* sht4x.h
|
||||
*
|
||||
* Created on: Jun 8, 2021
|
||||
* Author: user
|
||||
*/
|
||||
|
||||
#ifndef INC_SHT4X_H_
|
||||
#define INC_SHT4X_H_
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
/*
|
||||
* Defines & macros
|
||||
*/
|
||||
|
||||
#define SHT4X_I2C_ADDRESS 0x44
|
||||
|
||||
/*
|
||||
* Return values
|
||||
*/
|
||||
|
||||
#define SHT4X_OK 0
|
||||
#define SHT4X_ERROR -1 // generic error
|
||||
#define SHT4X_CRC8_ERROR -2 // checksum failed
|
||||
|
||||
/*
|
||||
* Data types
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
SHT4X_START_MEAS_HIGH_PRECISION = 0xFD,
|
||||
SHT4X_START_MEAS_MEDIUM_PRECISION = 0xF6,
|
||||
SHT4X_START_MEAS_LOW_PRECISION = 0xE0,
|
||||
SHT4X_READ_SERIAL = 0x89,
|
||||
SHT4X_SOFT_RESET = 0x94,
|
||||
SHT4X_HEATER_200_mW_1_s = 0x39,
|
||||
SHT4X_HEATER_200_mW_01_s = 0x32,
|
||||
SHT4X_HEATER_110_mW_1_s = 0x2F,
|
||||
SHT4X_HEATER_110_mW_01_s = 0x24,
|
||||
SHT4X_HEATER_20_mW_1_s = 0x1E,
|
||||
SHT4X_HEATER_20_mW_01_s = 0x15
|
||||
} sht4x_cmd_t;
|
||||
|
||||
/*
|
||||
* Function prototypes
|
||||
*/
|
||||
|
||||
int8_t sht4x_send_cmd(sht4x_cmd_t cmd);
|
||||
int8_t sht4x_read_data(uint8_t *buffer, int len);
|
||||
int8_t sht4x_measure(int16_t *temperature, uint16_t *relative_humidity);
|
||||
|
||||
#endif /* INC_SHT4X_H_ */
|
||||
Reference in New Issue
Block a user