thermo8 2.0.0.0
thermo8.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 THERMO8_H
36#define THERMO8_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 THERMO8_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
54 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
55 cfg.ale = MIKROBUS( mikrobus, MIKROBUS_INT )
62#define THERMO8_RETVAL uint8_t
63
64#define THERMO8_OK 0x00
65#define THERMO8_INIT_ERROR 0xFF
72#define THERMO8_ADDR0 0x18
73#define THERMO8_ADDR1 (0x18 | 0x01)
74#define THERMO8_ADDR2 (0x18 | 0x02)
75#define THERMO8_ADDR3 (0x18 | 0x03)
76#define THERMO8_ADDR4 (0x18 | 0x04)
77#define THERMO8_ADDR5 (0x18 | 0x05)
78#define THERMO8_ADDR6 (0x18 | 0x06)
79#define THERMO8_ADDR7 (0x18 | 0x07)
86#define THERMO8_CONFIG 0x01
87#define THERMO8_TUPPER 0x02
88#define THERMO8_TLOWER 0x03
89#define THERMO8_TCRIT 0x04
90#define THERMO8_TUPPER_REACHED 0x03
91#define THERMO8_TLOWER_REACHED 0x0C
92#define THERMO8_TCRIT_REACHED 0x30
93#define THERMO8_TCRIT_ONLY_ALERT 1
94#define THERMO8_ALERT_ON_ALL 0
95#define THERMO8_THYS_0C 0x00
96#define THERMO8_THYS_1C5 0x01
97#define THERMO8_THYS_3C 0x02
98#define THERMO8_THYS_6C 0x03
105#define THERMO8_TA 0x05
106#define THERMO8_MANID 0x06
107#define THERMO8_DEVID 0x07
114#define THERMO8_RESOLUTION_REG 0x08
115#define THERMO8_R05C_30MS 0x00
116#define THERMO8_R025C_65MS 0x01
117#define THERMO8_R0125C_130MS 0x02
118#define THERMO8_R00625C_250MS 0x03 // End group macro
122// --------------------------------------------------------------- PUBLIC TYPES
131typedef struct
132{
133 // Input pins
134
135 digital_in_t ale;
136
137 // Modules
138
139 i2c_master_t i2c;
140
141 // ctx variable
142
144 uint16_t limit_status;
145
146} thermo8_t;
147
151typedef struct
152{
153 // Communication gpio pins
154
155 pin_name_t scl;
156 pin_name_t sda;
157
158 // Additional gpio pins
159
160 pin_name_t ale;
161
162 // static variable
163
164 uint32_t i2c_speed;
165 uint8_t i2c_address;
166
168 // End types group
170// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
171
177#ifdef __cplusplus
178extern "C"{
179#endif
180
190
200
209
220void thermo8_generic_write ( thermo8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
221
232void thermo8_generic_read ( thermo8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
233
241uint8_t thermo8_ale_get ( thermo8_t *ctx );
242
252void thermo8_write_reg ( thermo8_t *ctx, uint8_t r_addr, uint16_t r_data );
253
262uint16_t thermo8_read_reg ( thermo8_t *ctx, uint8_t r_addr );
263
273void thermo8_write_reg_8 ( thermo8_t *ctx, uint8_t r_addr, uint8_t r_data);
274
283uint8_t thermo8_read_reg_8 ( thermo8_t *ctx, uint8_t r_addr );
284
293
302void thermo8_set_resolution ( thermo8_t *ctx, uint8_t r_cfg );
303
312
321
331
340
350void thermo8_limit_set ( thermo8_t *ctx, uint8_t limit_reg_addr, float limit );
351
360
370void thermo8_alert_enable ( thermo8_t *ctx, uint8_t thys, uint8_t alert_cfg );
371
381
390
400
409
410#ifdef __cplusplus
411}
412#endif
413#endif // _THERMO8_H_
414 // End public_function group
417
418// ------------------------------------------------------------------------- END
#define THERMO8_RETVAL
Definition: thermo8.h:62
void thermo8_tcrit_lock(thermo8_t *ctx)
Function for locking the critical temperature setting register.
void thermo8_set_resolution(thermo8_t *ctx, uint8_t r_cfg)
Function will set the conversion resoult temperature step depending on the passed constant.
void thermo8_generic_write(thermo8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void thermo8_win_lock(thermo8_t *ctx)
Function for locking the Tupper and Tlower registers.
void thermo8_default_cfg(thermo8_t *ctx)
Click Default Configuration function.
void thermo8_write_reg_8(thermo8_t *ctx, uint8_t r_addr, uint8_t r_data)
Function for single byte writes.
void thermo8_cfg_setup(thermo8_cfg_t *cfg)
Config Object Initialization function.
void thermo8_tcrit_unlock(thermo8_t *ctx)
Function for unlocking the critical temperature setting register.
void thermo8_alert_enable(thermo8_t *ctx, uint8_t thys, uint8_t alert_cfg)
Function for setting the Tupper and Tlower hysterezis level as well as the alert mode.
float thermo8_get_temperature(thermo8_t *ctx)
Function will return the temperature value in �C.
void thermo8_generic_read(thermo8_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void thermo8_win_unlock(thermo8_t *ctx)
Function for unlocking the Tupper and Tlower registers.
void thermo8_limit_set(thermo8_t *ctx, uint8_t limit_reg_addr, float limit)
Function for setting the temperature alarm levels for the lower, upper and critical alert levels.
uint8_t thermo8_get_alert_stat(thermo8_t *ctx)
Function will return all alert states.
void thermo8_sleep(thermo8_t *ctx)
Function will place Thermo 8 to the low power mode.
uint8_t thermo8_read_reg_8(thermo8_t *ctx, uint8_t r_addr)
Function for single byte read's.
uint16_t thermo8_get_dev_id(thermo8_t *ctx)
Function will return the device ID.
uint16_t thermo8_get_man_id(thermo8_t *ctx)
Function will return the manufacturer ID.
uint8_t thermo8_ale_get(thermo8_t *ctx)
Function for returning the state of the alert pin.
uint16_t thermo8_read_reg(thermo8_t *ctx, uint8_t r_addr)
Function for reading from 16 bit registers.
THERMO8_RETVAL thermo8_init(thermo8_t *ctx, thermo8_cfg_t *cfg)
Initialization function.
void thermo8_write_reg(thermo8_t *ctx, uint8_t r_addr, uint16_t r_data)
Function for writing to 16 bit registers.
void thermo8_wake_up(thermo8_t *ctx)
Function for waking up the click board from the sleep mode.
Click configuration structure definition.
Definition: thermo8.h:152
uint32_t i2c_speed
Definition: thermo8.h:164
pin_name_t ale
Definition: thermo8.h:160
pin_name_t scl
Definition: thermo8.h:155
pin_name_t sda
Definition: thermo8.h:156
uint8_t i2c_address
Definition: thermo8.h:165
Click ctx object definition.
Definition: thermo8.h:132
digital_in_t ale
Definition: thermo8.h:135
uint16_t limit_status
Definition: thermo8.h:144
i2c_master_t i2c
Definition: thermo8.h:139
uint8_t slave_address
Definition: thermo8.h:143