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 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
60 #define IRTHERMO5V_SET_DEV_ADDR 0x5A
61  // irthermo5v_set
63 
78 #define IRTHERMO5V_MAP_MIKROBUS( cfg, mikrobus ) \
79  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
80  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
81  cfg.pwm = MIKROBUS( mikrobus, MIKROBUS_PWM )
82  // irthermo5v_map // irthermo5v
85 
90 typedef struct
91 {
92  // Input pins
93 
94  digital_in_t pwm;
95 
96  // Modules
97  i2c_master_t i2c;
99  // I2C slave address
100  uint8_t slave_address;
102 } irthermo5v_t;
103 
108 typedef struct
109 {
110  pin_name_t scl;
111  pin_name_t sda;
113  pin_name_t pwm;
114 
115  uint32_t i2c_speed;
116  uint8_t i2c_address;
119 
124 typedef enum
125 {
127  IRTHERMO5V_ERROR = -1
128 
130 
148 
165 
176 
187 
198 uint16_t irthermo5v_read_reg ( irthermo5v_t* ctx, uint8_t address );
199 
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 #endif // IRTHERMO5V_H
205  // irthermo5v
207 
208 // ------------------------------------------------------------------------ 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:115
irthermo5v_t::pwm
digital_in_t pwm
Definition: irthermo5v.h:94
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:109
IRTHERMO5V_OK
@ IRTHERMO5V_OK
Definition: irthermo5v.h:126
irthermo5v_cfg_t::scl
pin_name_t scl
Definition: irthermo5v.h:110
irthermo5v_cfg_t::pwm
pin_name_t pwm
Definition: irthermo5v.h:113
irthermo5v_t
IrThermo 5V Click context object.
Definition: irthermo5v.h:91
irthermo5v_t::slave_address
uint8_t slave_address
Definition: irthermo5v.h:100
irthermo5v_cfg_t::sda
pin_name_t sda
Definition: irthermo5v.h:111
irthermo5v_cfg_t::i2c_address
uint8_t i2c_address
Definition: irthermo5v.h:116
IRTHERMO5V_ERROR
@ IRTHERMO5V_ERROR
Definition: irthermo5v.h:127
irthermo5v_return_value_t
irthermo5v_return_value_t
IrThermo 5V Click return value data.
Definition: irthermo5v.h:125
irthermo5v_t::i2c
i2c_master_t i2c
Definition: irthermo5v.h:97
irthermo5v_get_t_object
float irthermo5v_get_t_object(irthermo5v_t *ctx)
Reads Temperature object1 from sensor.