sht1x 2.0.0.0
sht1x.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef SHT1X_H
36#define SHT1X_H
37
38#include "drv_digital_out.h"
39#include "drv_digital_in.h"
40
41// -------------------------------------------------------------- PUBLIC MACROS
51#define SHT1X_MAP_MIKROBUS( cfg, mikrobus ) \
52 cfg.scl= MIKROBUS( mikrobus, MIKROBUS_SCL ); \
53 cfg.sda= MIKROBUS( mikrobus, MIKROBUS_SDA )
54
61#define SHT1X_RETVAL uint8_t
62
63#define SHT1X_OK 0x00
64#define SHT1X_INIT_ERROR 0xFF
71#define SHT1X_MEAS_TEMP 0x03
72#define SHT1X_MEAS_HUMI 0x05
73#define SHT1X_STAT_REG_W 0x06
74#define SHT1X_STAT_REG_R 0x07
75#define SHT1X_SOFT_RESET 0x1E
82#define SHT1X_SR_MASK 0x07
89#define SHT1X_NACK 0
90#define SHT1X_ACK 1
97#define SHT1X_D1 -40.1
98#define SHT1X_D2h 0.01
99#define SHT1X_D2l 0.04
100#define SHT1X_V3_C1 -4.0000
101#define SHT1X_V3_C2h 0.0405
102#define SHT1X_V3_C3h -2.8000E-6
103#define SHT1X_V3_C2l 0.6480
104#define SHT1X_V3_C3l -7.2000E-4
105#define SHT1X_V4_C1 -2.0468
106#define SHT1X_V4_C2h 0.0367
107#define SHT1X_V4_C3h -1.5955E-6
108#define SHT1X_V4_C2l 0.5872
109#define SHT1X_V4_C3l -4.0845E-4
110#define SHT1X_T1 0.01
111#define SHT1X_T2h 0.00008
112#define SHT1X_T2l 0.00128 // End group macro
118// --------------------------------------------------------------- PUBLIC TYPES
127typedef struct
128{
129 // Output pins
130
131 digital_out_t scl;
132 digital_out_t sda;
133
134} sht1x_t;
135
139typedef struct
140{
141 // Additional gpio pins
142
143 pin_name_t scl;
144 pin_name_t sda;
145
147 // End types group
149// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
150
156#ifdef __cplusplus
157extern "C"{
158#endif
159
169
178
188
198
207
215void sht1x_sda_low ( sht1x_t *ctx );
216
228uint8_t sht1x_get_sda ( sht1x_t *ctx );
229
238
246void sht1x_scl_low ( sht1x_t *ctx );
247
258float sht1x_calc_temp ( sht1x_t *ctx, uint16_t t );
259
271float sht1x_calc_humi ( sht1x_t *ctx, uint16_t h, uint16_t t );
272
273#ifdef __cplusplus
274}
275#endif
276#endif // _SHT1X_H_
277 // End public_function group
280
281// ------------------------------------------------------------------------- END
#define SHT1X_RETVAL
Definition: sht1x.h:61
void sht1x_scl_low(sht1x_t *ctx)
Set SCL low function.
float sht1x_calc_temp(sht1x_t *ctx, uint16_t t)
Calculate temperature function.
void sht1x_sda_low(sht1x_t *ctx)
Set SDA low function.
void sht1x_cfg_setup(sht1x_cfg_t *cfg)
Config Object Initialization function.
void sht1x_input_sda(sht1x_t *ctx, sht1x_cfg_t *cfg)
Set pin on input.
void sht1x_sda_high(sht1x_t *ctx)
Set SDA high function.
uint8_t sht1x_get_sda(sht1x_t *ctx)
Check SDA state function.
void sht1x_scl_high(sht1x_t *ctx)
Set SCL high function.
SHT1X_RETVAL sht1x_init(sht1x_t *ctx, sht1x_cfg_t *cfg)
Initialization function.
float sht1x_calc_humi(sht1x_t *ctx, uint16_t h, uint16_t t)
Calculate humidity function.
void sht1x_output_sda(sht1x_t *ctx, sht1x_cfg_t *cfg)
Set pin on output.
Click configuration structure definition.
Definition: sht1x.h:140
pin_name_t scl
Definition: sht1x.h:143
pin_name_t sda
Definition: sht1x.h:144
Click ctx object definition.
Definition: sht1x.h:128
digital_out_t sda
Definition: sht1x.h:132
digital_out_t scl
Definition: sht1x.h:131