thermo28  2.1.0.0
thermo28.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef THERMO28_H
29 #define THERMO28_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_in.h"
36 #include "drv_i2c_master.h"
37 
58 #define THERMO28_REG_TVAL 0x00
59 #define THERMO28_REG_CONFIG 0x01
60 #define THERMO28_REG_TLOW 0x02
61 #define THERMO28_REG_THIGH 0x03
62  // thermo28_reg
64 
79 #define THERMO28_CFG_DEFAULT_CONFIG 0x40A0
80 #define THERMO28_CFG_SINGLE_SHOT 0x8000
81 #define THERMO28_CONV_RATE_BIT_MASK 0x00C0
82 #define THERMO28_STATE_BIT_MASK 0x0100
83 #define THERMO28_CONSEC_FAULTS_BIT_MASK 0x3000
84 #define THERMO28_ALERT_BIT_MASK 0x0200
85 #define THERMO28_SINGLE_SHOT_BIT_MASK 0x8000
86 
92 #define THERMO28_DEVICE_ADDRESS_VSS 0x48
93 #define THERMO28_DEVICE_ADDRESS_VDD 0x49
94 #define THERMO28_DEVICE_ADDRESS_SDA 0x4A
95 #define THERMO28_DEVICE_ADDRESS_SCL 0x4B
96  // thermo28_set
98 
113 #define THERMO28_MAP_MIKROBUS( cfg, mikrobus ) \
114  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
115  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
116  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
117  // thermo28_map // thermo28
120 
125 typedef enum
126 {
128  THERMO28_ERROR = -1
129 
131 
136 typedef enum
137 {
141  THERMO28_CONV_RATE8 = 0x00C0
142 
144 
149 typedef enum
150 {
152  THERMO28_STATE_ACTIVE = 0x0000
153 
155 
160 typedef enum
161 {
164 
166 
167 
172 typedef enum
173 {
176 
178 
183 typedef enum
184 {
188  THERMO28_CONSEC_FAULTS4 = 0x3000
189 
191 
196 typedef enum
197 {
200 
202 
207 typedef struct
208 {
209  // Input pins
210  digital_in_t int_pin;
212  // Modules
213  i2c_master_t i2c;
215  // I2C slave address
216  uint8_t slave_address;
218 } thermo28_t;
219 
224 typedef struct
225 {
226  pin_name_t scl;
227  pin_name_t sda;
229  pin_name_t int_pin;
231  uint32_t i2c_speed;
232  uint8_t i2c_address;
235 
240 typedef struct
241 {
248 
250 
267 
282 
296 
311 err_t thermo28_generic_write ( thermo28_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
312 
327 err_t thermo28_generic_read ( thermo28_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
328 
340 err_t thermo28_get_temperature ( thermo28_t *ctx, float *temperature );
341 
354 err_t thermo28_set_alert_limits ( thermo28_t *ctx, float alert_min, float alert_max );
355 
369 
382 
395 
408 
420 
421 #ifdef __cplusplus
422 }
423 #endif
424 #endif // THERMO28_H
425  // thermo28
427 
428 // ------------------------------------------------------------------------ END
THERMO28_CONV_RATE4
@ THERMO28_CONV_RATE4
Definition: thermo28.h:140
thermo28_get_int_pin
uint8_t thermo28_get_int_pin(thermo28_t *ctx)
Thermo 28 set alert status function.
THERMO28_CONSEC_FAULTS1
@ THERMO28_CONSEC_FAULTS1
Definition: thermo28.h:185
THERMO28_STATE_ACTIVE
@ THERMO28_STATE_ACTIVE
Definition: thermo28.h:152
THERMO28_ALERT_COMPARATOR
@ THERMO28_ALERT_COMPARATOR
Definition: thermo28.h:163
thermo28_generic_read
err_t thermo28_generic_read(thermo28_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Thermo 28 I2C reading function.
thermo28_get_temperature
err_t thermo28_get_temperature(thermo28_t *ctx, float *temperature)
Thermo 28 get temperature function.
thermo28_config_t::alert_mode
thermo28_alert_mode_t alert_mode
Definition: thermo28.h:244
thermo28_set_continuous_conversion
err_t thermo28_set_continuous_conversion(thermo28_t *ctx)
Thermo 28 set continuous conversion function.
thermo28_device_mode_t
thermo28_device_mode_t
Thermo 28 Click sleep mode value data.
Definition: thermo28.h:150
THERMO28_ALERT_ACTIVE_LOW
@ THERMO28_ALERT_ACTIVE_LOW
Definition: thermo28.h:174
thermo28_default_cfg
err_t thermo28_default_cfg(thermo28_t *ctx)
Thermo 28 default configuration function.
THERMO28_CONSEC_FAULTS3
@ THERMO28_CONSEC_FAULTS3
Definition: thermo28.h:187
THERMO28_CONV_RATE1
@ THERMO28_CONV_RATE1
Definition: thermo28.h:139
thermo28_return_value_t
thermo28_return_value_t
Thermo 28 Click return value data.
Definition: thermo28.h:126
THERMO28_CONV_RATE025
@ THERMO28_CONV_RATE025
Definition: thermo28.h:138
thermo28_config_t::consecutive_faults
thermo28_consec_faults_t consecutive_faults
Definition: thermo28.h:246
thermo28_t::i2c
i2c_master_t i2c
Definition: thermo28.h:213
THERMO28_ALERT_INTERRUPT
@ THERMO28_ALERT_INTERRUPT
Definition: thermo28.h:162
THERMO28_ALERT_ACTIVE_HIGH
@ THERMO28_ALERT_ACTIVE_HIGH
Definition: thermo28.h:175
THERMO28_CONV_RATE8
@ THERMO28_CONV_RATE8
Definition: thermo28.h:141
thermo28_cfg_setup
void thermo28_cfg_setup(thermo28_cfg_t *cfg)
Thermo 28 configuration object setup function.
thermo28_t::slave_address
uint8_t slave_address
Definition: thermo28.h:216
thermo28_cfg_t::i2c_address
uint8_t i2c_address
Definition: thermo28.h:232
thermo28_config_t::single_shot
thermo28_single_shot_t single_shot
Definition: thermo28.h:247
thermo28_config_t::conv_rate
thermo28_conv_rate_t conv_rate
Definition: thermo28.h:242
THERMO28_OK
@ THERMO28_OK
Definition: thermo28.h:127
thermo28_set_config
err_t thermo28_set_config(thermo28_t *ctx, thermo28_config_t config)
Thermo 28 set configuration function.
thermo28_cfg_t
Thermo 28 Click configuration object.
Definition: thermo28.h:225
thermo28_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: thermo28.h:231
thermo28_set_trigger_single_shot
err_t thermo28_set_trigger_single_shot(thermo28_t *ctx)
Thermo 28 set trigger single-shot function.
THERMO28_CONSEC_FAULTS4
@ THERMO28_CONSEC_FAULTS4
Definition: thermo28.h:188
thermo28_set_sleep_mode
err_t thermo28_set_sleep_mode(thermo28_t *ctx)
Thermo 28 set device working mode function.
thermo28_config_t::alert_polarity
thermo28_alert_polarity_t alert_polarity
Definition: thermo28.h:245
THERMO28_CONSEC_FAULTS2
@ THERMO28_CONSEC_FAULTS2
Definition: thermo28.h:186
THERMO28_SINGLE_SHOT_START_CONVERSION
@ THERMO28_SINGLE_SHOT_START_CONVERSION
Definition: thermo28.h:199
thermo28_conv_rate_t
thermo28_conv_rate_t
Thermo 28 Click conversion rate value data.
Definition: thermo28.h:137
thermo28_consec_faults_t
thermo28_consec_faults_t
Thermo 28 Click consecutive faults value data.
Definition: thermo28.h:184
thermo28_alert_polarity_t
thermo28_alert_polarity_t
Thermo 28 Click polarity of the alert output value data.
Definition: thermo28.h:173
thermo28_init
err_t thermo28_init(thermo28_t *ctx, thermo28_cfg_t *cfg)
Thermo 28 initialization function.
thermo28_cfg_t::int_pin
pin_name_t int_pin
Definition: thermo28.h:229
thermo28_generic_write
err_t thermo28_generic_write(thermo28_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Thermo 28 I2C writing function.
thermo28_set_alert_limits
err_t thermo28_set_alert_limits(thermo28_t *ctx, float alert_min, float alert_max)
Thermo 28 set alert limits function.
thermo28_config_t
Thermo 28 Click configuration object.
Definition: thermo28.h:241
thermo28_t::int_pin
digital_in_t int_pin
Definition: thermo28.h:210
THERMO28_SINGLE_SHOT_NO_CONVERSION
@ THERMO28_SINGLE_SHOT_NO_CONVERSION
Definition: thermo28.h:198
thermo28_cfg_t::scl
pin_name_t scl
Definition: thermo28.h:226
thermo28_config_t::device_mode
thermo28_device_mode_t device_mode
Definition: thermo28.h:243
THERMO28_ERROR
@ THERMO28_ERROR
Definition: thermo28.h:128
thermo28_alert_mode_t
thermo28_alert_mode_t
Thermo 28 Click interrupt mode value data.
Definition: thermo28.h:161
THERMO28_STATE_SLEEP
@ THERMO28_STATE_SLEEP
Definition: thermo28.h:151
thermo28_single_shot_t
thermo28_single_shot_t
Thermo 28 Click measurement mode value data.
Definition: thermo28.h:197
thermo28_t
Thermo 28 Click context object.
Definition: thermo28.h:208
thermo28_cfg_t::sda
pin_name_t sda
Definition: thermo28.h:227