Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
sht_click.h
Go to the documentation of this file.
1 
5 /*
6  * Copyright (c) 2022, Cascoda Ltd.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the copyright holder nor the
17  * names of its contributors may be used to endorse or promote products
18  * derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  * Example click interface driver
34 */
35 
36 #ifndef SHT_CLICK_H
37 #define SHT_CLICK_H
38 
39 #include <stdint.h>
40 
41 /* use alarm pin as interrupt (1) with continuous mode instead of polling (0) with single-shot mode */
42 #define SHT_USE_INTERRUPT 0
43 
44 /* all sgp30 maximum data length */
45 #define SHT3X_MAXDLEN 6
46 /* I2C slave address + memory address (command) */
47 #define SHT3X_ADDLEN 3
48 
49 /* simple boolean state mapping */
50 #define MIKROSDK_SHT_ON 1
51 #define MIKROSDK_SHT_OFF 0
52 
53 /* additional commands for alert function (not in original code) */
54 #define SHT_CMD_WR_LO_SET 0x6100 /* write low limits set */
55 #define SHT_CMD_WR_LO_CLR 0x610B /* write low limits clear */
56 #define SHT_CMD_WR_HI_SET 0x611D /* write high limits set */
57 #define SHT_CMD_WR_HI_CLR 0x6116 /* write high limits clear */
58 #define SHT_CMD_RD_LO_SET 0xE102 /* write low limits set */
59 #define SHT_CMD_RD_LO_CLR 0xE109 /* write low limits clear */
60 #define SHT_CMD_RD_HI_SET 0xE11F /* write high limits set */
61 #define SHT_CMD_RD_HI_CLR 0xE114 /* write high limits clear */
62 
63 /* timing parameters [ms] */
64 #define SHT_T_COMMS 2 /* 2 ms between communication exchange */
65 
66 /* alarm active high */
68 {
72 };
73 
74 /* default alarm limits */
75 /* H in % * 100 */
76 /* T in 'C * 100 */
77 #define SHT_LIMIT_H_HI 5500 /* humidity high */
78 #define SHT_LIMIT_H_LO 2000 /* humidity low */
79 #define SHT_LIMIT_T_HI 6000 /* temperature high */
80 #define SHT_LIMIT_T_LO -1000 /* temperature low */
81 #define SHT_LIMIT_H_HYS 200 /* humidity hysteresis for clearing alarms */
82 #define SHT_LIMIT_T_HYS 200 /* temperature hysteresis for clearing alarms */
83 
84 /* data acquisition status */
86 {
87  SHT_ST_OK = 0, /* read values ok */
88  SHT_ST_ALARM_CLEARED = 1, /* alarm has been cleared (values ok) */
89  SHT_ST_ALARM_TRIGGERED = 2, /* alarm has been triggered (values ok) */
90  SHT_ST_FAIL = 3 /* acquisition failed */
91 };
92 
93 /* new functions */
94 uint8_t MIKROSDK_SHT_start_pm(void);
95 uint8_t MIKROSDK_SHT_stop_pm(void);
96 uint8_t MIKROSDK_SHT_get_temp_hum_pm(int16_t *humidity, int16_t *temperature);
97 uint8_t MIKROSDK_SHT_get_temp_hum_ss(int16_t *humidity, int16_t *temperature);
98 uint8_t MIKROSDK_SHT_heater_control(uint8_t state);
99 uint8_t MIKROSDK_SHT_read_status(uint16_t *statusregister);
100 uint8_t MIKROSDK_SHT_clear_status(void);
101 void MIKROSDK_SHT_hard_reset(void);
102 uint8_t MIKROSDK_SHT_soft_reset(void);
103 uint8_t MIKROSDK_SHT_set_hi_alert_limits(int16_t h_set, int16_t h_clr, int16_t t_set, int16_t t_clr);
104 uint8_t MIKROSDK_SHT_set_lo_alert_limits(int16_t h_set, int16_t h_clr, int16_t t_set, int16_t t_clr);
105 uint8_t MIKROSDK_SHT_get_hi_alert_limits(int16_t *h_set, int16_t *h_clr, int16_t *t_set, int16_t *t_clr);
106 uint8_t MIKROSDK_SHT_get_lo_alert_limits(int16_t *h_set, int16_t *h_clr, int16_t *t_set, int16_t *t_clr);
107 void MIKROSDK_SHT_config(void);
108 void MIKROSDK_SHT_pin_mapping(uint8_t reset, uint8_t alarm);
109 uint8_t MIKROSDK_SHT_get_alarm(void);
110 uint8_t MIKROSDK_SHT_alarm_triggered(void);
111 uint8_t MIKROSDK_SHT_Initialise(void);
112 uint8_t MIKROSDK_SHT_Reinitialise(void);
113 uint8_t MIKROSDK_SHT_Acquire(int16_t *humidity, int16_t *temperature);
114 
115 #endif // SHT_CLICK_H
uint8_t MIKROSDK_SHT_set_lo_alert_limits(int16_t h_set, int16_t h_clr, int16_t t_set, int16_t t_clr)
Definition: sht.c:462
uint8_t MIKROSDK_SHT_Initialise(void)
Definition: sht.c:569
uint8_t MIKROSDK_SHT_Reinitialise(void)
Definition: sht.c:615
uint8_t MIKROSDK_SHT_get_temp_hum_ss(int16_t *humidity, int16_t *temperature)
Definition: sht.c:346
uint8_t MIKROSDK_SHT_soft_reset(void)
Definition: sht.c:410
sht_alarm_state
Definition: sht_click.h:68
@ SHT_ALARM_CLEARED
Definition: sht_click.h:70
@ SHT_ALARM_TRIGGERED
Definition: sht_click.h:69
@ SHT_ALARM_NOALARM
Definition: sht_click.h:71
uint8_t MIKROSDK_SHT_get_lo_alert_limits(int16_t *h_set, int16_t *h_clr, int16_t *t_set, int16_t *t_clr)
Definition: sht.c:520
uint8_t MIKROSDK_SHT_clear_status(void)
Definition: sht.c:390
void MIKROSDK_SHT_pin_mapping(uint8_t reset, uint8_t alarm)
Definition: sht.c:562
void MIKROSDK_SHT_config(void)
Definition: sht.c:419
uint8_t MIKROSDK_SHT_get_temp_hum_pm(int16_t *humidity, int16_t *temperature)
Definition: sht.c:331
uint8_t MIKROSDK_SHT_heater_control(uint8_t state)
Definition: sht.c:359
void MIKROSDK_SHT_hard_reset(void)
Definition: sht.c:401
uint8_t MIKROSDK_SHT_set_hi_alert_limits(int16_t h_set, int16_t h_clr, int16_t t_set, int16_t t_clr)
Definition: sht.c:429
uint8_t MIKROSDK_SHT_read_status(uint16_t *statusregister)
Definition: sht.c:377
uint8_t MIKROSDK_SHT_Acquire(int16_t *humidity, int16_t *temperature)
Definition: sht.c:625
uint8_t MIKROSDK_SHT_get_hi_alert_limits(int16_t *h_set, int16_t *h_clr, int16_t *t_set, int16_t *t_clr)
Definition: sht.c:495
uint8_t MIKROSDK_SHT_alarm_triggered(void)
Definition: sht.c:543
uint8_t MIKROSDK_SHT_stop_pm(void)
Definition: sht.c:318
uint8_t MIKROSDK_SHT_start_pm(void)
Definition: sht.c:307
uint8_t MIKROSDK_SHT_get_alarm(void)
Definition: sht.c:551
sht_status
Definition: sht_click.h:86
@ SHT_ST_OK
Definition: sht_click.h:87
@ SHT_ST_ALARM_CLEARED
Definition: sht_click.h:88
@ SHT_ST_ALARM_TRIGGERED
Definition: sht_click.h:89
@ SHT_ST_FAIL
Definition: sht_click.h:90