thermo20  2.0.0.0
thermo20.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 THERMO20_H
29 #define THERMO20_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
59 #define THERMO20_CMD_RESET 0x1E
60 #define THERMO20_CMD_READ_SERIAL_NUMBER 0x0A
61 #define THERMO20_CMD_CONVERSION 0x46
62 #define THERMO20_CMD_READ_ADC 0x00
63  // thermo20_reg
65 
81 #define THERMO20_SET_DEV_ADDR 0x40
82  // thermo20_set
84 
99 #define THERMO20_MAP_MIKROBUS( cfg, mikrobus ) \
100  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
101  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA );
102  // thermo20_map // thermo20
105 
110 typedef struct
111 {
112  // Modules
113  i2c_master_t i2c;
115  // I2C slave address
116  uint8_t slave_address;
118 } thermo20_t;
119 
124 typedef struct
125 {
126  pin_name_t scl;
127  pin_name_t sda;
129  uint32_t i2c_speed;
130  uint8_t i2c_address;
133 
138 typedef enum
139 {
141  THERMO20_ERROR = -1
142 
144 
161 
177 
192 
208 err_t thermo20_generic_write ( thermo20_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
209 
225 err_t thermo20_generic_read ( thermo20_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
226 
239 err_t thermo20_set_cmd ( thermo20_t *ctx, uint8_t cmd );
240 
250 
262 
271 uint16_t thermo20_read_adc ( thermo20_t *ctx );
272 
282 
292 
293 #ifdef __cplusplus
294 }
295 #endif
296 #endif // THERMO20_H
297  // thermo20
299 
300 // ------------------------------------------------------------------------ END
thermo20_cfg_t::scl
pin_name_t scl
Definition: thermo20.h:126
thermo20_t::slave_address
uint8_t slave_address
Definition: thermo20.h:116
thermo20_return_value_t
thermo20_return_value_t
Thermo 20 Click return value data.
Definition: thermo20.h:139
thermo20_t
Thermo 20 Click context object.
Definition: thermo20.h:111
thermo20_get_temperature
float thermo20_get_temperature(thermo20_t *ctx)
Get temperature data function.
thermo20_cfg_t::i2c_address
uint8_t i2c_address
Definition: thermo20.h:130
thermo20_cfg_t::sda
pin_name_t sda
Definition: thermo20.h:127
thermo20_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: thermo20.h:129
thermo20_soft_reset
void thermo20_soft_reset(thermo20_t *ctx)
Soft reset function.
THERMO20_OK
@ THERMO20_OK
Definition: thermo20.h:140
thermo20_cfg_t
Thermo 20 Click configuration object.
Definition: thermo20.h:125
thermo20_generic_read
err_t thermo20_generic_read(thermo20_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Thermo 20 I2C reading function.
THERMO20_ERROR
@ THERMO20_ERROR
Definition: thermo20.h:141
thermo20_read_adc
uint16_t thermo20_read_adc(thermo20_t *ctx)
Read ADC data function.
thermo20_get_serial_number
uint32_t thermo20_get_serial_number(thermo20_t *ctx)
Get serial number function.
thermo20_t::i2c
i2c_master_t i2c
Definition: thermo20.h:113
thermo20_init
err_t thermo20_init(thermo20_t *ctx, thermo20_cfg_t *cfg)
Thermo 20 initialization function.
thermo20_generic_write
err_t thermo20_generic_write(thermo20_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Thermo 20 I2C writing function.
thermo20_set_cmd
err_t thermo20_set_cmd(thermo20_t *ctx, uint8_t cmd)
Send command function.
thermo20_cfg_setup
void thermo20_cfg_setup(thermo20_cfg_t *cfg)
Thermo 20 configuration object setup function.
thermo20_default_cfg
err_t thermo20_default_cfg(thermo20_t *ctx)
Thermo 20 default configuration function.
thermo20_start_conversion
void thermo20_start_conversion(thermo20_t *ctx)
Start conversion function.