hdc1000  2.0.0.0
hdc1000.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef HDC1000_H
36 #define HDC1000_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 // -------------------------------------------------------------- PUBLIC MACROS
52 #define HDC1000_MAP_MIKROBUS( cfg, mikrobus ) \
53  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
56 
62 #define HDC1000_RETVAL uint8_t
63 
64 #define HDC1000_OK 0x00
65 #define HDC1000_INIT_ERROR 0xFF
66 
71 #define HDC1000_SLAVE_ADDRESS 0x40
72 
78 #define HDC1000_REG_TEMP 0x00
79 #define HDC1000_REG_HUMI 0x01
80 #define HDC1000_REG_CONFIG 0x02
81 #define HDC1000_REG_SERID_1 0xFB
82 #define HDC1000_REG_SERID_2 0xFC
83 #define HDC1000_REG_SERID_3 0xFD
84 #define HDC1000_REG_MFID 0xFE
85 #define HDC1000_REG_DEVID 0xFF
86 
92 #define HDC1000_RST 0x80
93 #define HDC1000_HEAT_ON 0x20
94 #define HDC1000_HEAT_OFF 0x00
95 #define HDC1000_BOTH_TEMP_HUMI 0x10
96 #define HDC1000_SINGLE_MEASUR 0x00
97 #define HDC1000_TEMP_HUMI_14BIT 0x00
98 #define HDC1000_TEMP_11BIT 0x04
99 #define HDC1000_HUMI_11BIT 0x01
100 #define HDC1000_HUMI_8BIT 0x02
101  // End group macro
104 // --------------------------------------------------------------- PUBLIC TYPES
113 typedef struct
114 {
115  // Input pins
116 
117  digital_in_t rdy;
118 
119  // Modules
120 
121  i2c_master_t i2c;
122 
123  // ctx variable
124 
125  uint8_t slave_address;
126 
127 } hdc1000_t;
128 
132 typedef struct
133 {
134  // Communication gpio pins
135 
136  pin_name_t scl;
137  pin_name_t sda;
138 
139  // Additional gpio pins
140 
141  pin_name_t rdy;
142 
143  // static variable
144 
145  uint32_t i2c_speed;
146  uint8_t i2c_address;
147 
148 } hdc1000_cfg_t;
149  // End types group
151 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
152 
158 #ifdef __cplusplus
159 extern "C"{
160 #endif
161 
171 
181 
201 
212 void hdc1000_generic_write ( hdc1000_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
213 
224 void hdc1000_generic_read ( hdc1000_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
225 
237 
249 
268 
269 #ifdef __cplusplus
270 }
271 #endif
272 #endif // _HDC1000_H_
273  // End public_function group
276 
277 // ------------------------------------------------------------------------- END
hdc1000_cfg_t::i2c_address
uint8_t i2c_address
Definition: hdc1000.h:146
hdc1000_default_cfg
void hdc1000_default_cfg(hdc1000_t *ctx)
Click Default Configuration function.
hdc1000_t::slave_address
uint8_t slave_address
Definition: hdc1000.h:125
hdc1000_get_temperature_data
float hdc1000_get_temperature_data(hdc1000_t *ctx)
Get temperature value.
hdc1000_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: hdc1000.h:145
hdc1000_generic_write
void hdc1000_generic_write(hdc1000_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
hdc1000_cfg_t::rdy
pin_name_t rdy
Definition: hdc1000.h:141
hdc1000_get_interrupt
uint8_t hdc1000_get_interrupt(hdc1000_t *ctx)
Get interrupt state.
hdc1000_cfg_t::sda
pin_name_t sda
Definition: hdc1000.h:137
hdc1000_cfg_t::scl
pin_name_t scl
Definition: hdc1000.h:136
hdc1000_generic_read
void hdc1000_generic_read(hdc1000_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
hdc1000_get_humidity_data
float hdc1000_get_humidity_data(hdc1000_t *ctx)
Get humidity value.
hdc1000_cfg_setup
void hdc1000_cfg_setup(hdc1000_cfg_t *cfg)
Config Object Initialization function.
HDC1000_RETVAL
#define HDC1000_RETVAL
Definition: hdc1000.h:62
hdc1000_cfg_t
Click configuration structure definition.
Definition: hdc1000.h:133
hdc1000_t::i2c
i2c_master_t i2c
Definition: hdc1000.h:121
hdc1000_t
Click ctx object definition.
Definition: hdc1000.h:114
hdc1000_t::rdy
digital_in_t rdy
Definition: hdc1000.h:117
hdc1000_init
HDC1000_RETVAL hdc1000_init(hdc1000_t *ctx, hdc1000_cfg_t *cfg)
Initialization function.