irthermo5v  2.0.0.0
irthermo5v.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 IRTHERMO5V_H
29 #define IRTHERMO5V_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 #include "drv_i2c_master.h"
52 
74 #define IRTHERMO5V_SET_DEV_ADDR 0x5A
75  // irthermo5v_set
77 
92 #define IRTHERMO5V_MAP_MIKROBUS( cfg, mikrobus ) \
93  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
94  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
95  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM )
96  // irthermo5v_map // irthermo5v
99 
104 typedef struct
105 {
106  // Input pins
107 
108  digital_in_t pwm;
109 
110  // Modules
111  i2c_master_t i2c;
113  // I2C slave address
114  uint8_t slave_address;
116 } irthermo5v_t;
117 
122 typedef struct
123 {
124  pin_name_t scl;
125  pin_name_t sda;
127  pin_name_t pwm;
128 
129  uint32_t i2c_speed;
130  uint8_t i2c_address;
133 
138 typedef enum
139 {
141  IRTHERMO5V_ERROR = -1
142 
144 
162 
179 
190 
201 
212 uint16_t irthermo5v_read_reg ( irthermo5v_t* ctx, uint8_t address );
213 
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 #endif // IRTHERMO5V_H
219  // irthermo5v
221 
222 // ------------------------------------------------------------------------ END
irthermo5v_cfg_setup
void irthermo5v_cfg_setup(irthermo5v_cfg_t *cfg)
IrThermo 5V configuration object setup function.
irthermo5v_read_reg
uint16_t irthermo5v_read_reg(irthermo5v_t *ctx, uint8_t address)
Generic function for reading values from RAM.
irthermo5v_get_t_ambient
float irthermo5v_get_t_ambient(irthermo5v_t *ctx)
Reads Temperature ambient from sensor.
irthermo5v_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: irthermo5v.h:129
irthermo5v_t::pwm
digital_in_t pwm
Definition: irthermo5v.h:108
irthermo5v_init
err_t irthermo5v_init(irthermo5v_t *ctx, irthermo5v_cfg_t *cfg)
IrThermo 5V initialization function.
irthermo5v_cfg_t
IrThermo 5V Click configuration object.
Definition: irthermo5v.h:123
IRTHERMO5V_OK
@ IRTHERMO5V_OK
Definition: irthermo5v.h:140
irthermo5v_cfg_t::scl
pin_name_t scl
Definition: irthermo5v.h:124
irthermo5v_cfg_t::pwm
pin_name_t pwm
Definition: irthermo5v.h:127
irthermo5v_t
IrThermo 5V Click context object.
Definition: irthermo5v.h:105
irthermo5v_t::slave_address
uint8_t slave_address
Definition: irthermo5v.h:114
irthermo5v_cfg_t::sda
pin_name_t sda
Definition: irthermo5v.h:125
irthermo5v_cfg_t::i2c_address
uint8_t i2c_address
Definition: irthermo5v.h:130
IRTHERMO5V_ERROR
@ IRTHERMO5V_ERROR
Definition: irthermo5v.h:141
irthermo5v_return_value_t
irthermo5v_return_value_t
IrThermo 5V Click return value data.
Definition: irthermo5v.h:139
irthermo5v_t::i2c
i2c_master_t i2c
Definition: irthermo5v.h:111
irthermo5v_get_t_object
float irthermo5v_get_t_object(irthermo5v_t *ctx)
Reads Temperature object1 from sensor.