templog6 2.0.0.0
templog6.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 TEMPLOG6_H
36#define TEMPLOG6_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_in.h"
53#include "drv_i2c_master.h"
54
55// -------------------------------------------------------------- PUBLIC MACROS
65#define TEMPLOG6_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
68 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
75#define TEMPLOG6_RETVAL uint8_t
76
77#define TEMPLOG6_OK 0x00
78#define TEMPLOG6_INIT_ERROR 0xFF
85#define TEMPLOG6_REG_LOCAL_TEMPERATURE 0x00
86#define TEMPLOG6_REG_REMOTE_TEMPERATURE 0x01
87#define TEMPLOG6_REG_STATUS 0x02
88#define TEMPLOG6_REG_RD_CONFIGURATION 0x03
89#define TEMPLOG6_REG_RD_LOCAL_HIGH_LIMIT 0x05
90#define TEMPLOG6_REG_RD_REMOTE_HIGH_LIMIT 0x07
91#define TEMPLOG6_REG_WR_CONFIGURATION 0x09
92#define TEMPLOG6_REG_WR_LOCAL_HIGH_LIMIT 0x0B
93#define TEMPLOG6_REG_WR_REMOTE_HIGH_LIMIT 0x0D
94#define TEMPLOG6_REG_SINGLE_SHOT 0x0F
95#define TEMPLOG6_REG_REMOTE_EXTENDED_TEMP 0x10
96#define TEMPLOG6_REG_INTERNAL_EXTENDED_TEMP 0x11
97#define TEMPLOG6_REG_MANUFACTURER_ID 0xFE
104#define TEMPLOG6_CFG_ALERT_OFF 0x80
105#define TEMPLOG6_CFG_ALERT_ON 0x00
106#define TEMPLOG6_CFG_STANDBY_MODE 0x40
107#define TEMPLOG6_CFG_NORMAL_MODE 0x00
108#define TEMPLOG6_CFG_LOCAL_MEASUREMENT_OFF 0x20
109#define TEMPLOG6_CFG_LOCAL_MEASUREMENT_ON 0x00
110#define TEMPLOG6_CFG_ALERT_1_FAULT 0x00
111#define TEMPLOG6_CFG_ALERT_2_FAULT 0x10
112
113#define TEMPLOG6_DEVICE_SLAVE_ADDRESS 0x4A
114#define TEMPLOG6_MANUFACTURER_ID 0x4D
117 // End group macro
118// --------------------------------------------------------------- PUBLIC TYPES
127typedef struct
128{
129 // Input pins
130
131 digital_in_t int_pin;
132
133 // Modules
134
135 i2c_master_t i2c;
136
137 // ctx variable
138
140
141} templog6_t;
142
146typedef struct
147{
148 // Communication gpio pins
149
150 pin_name_t scl;
151 pin_name_t sda;
152
153 // Additional gpio pins
154
155 pin_name_t int_pin;
156
157 // static variable
158
159 uint32_t i2c_speed;
160 uint8_t i2c_address;
161
163
164 // End variable group
165// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
166
172#ifdef __cplusplus
173extern "C"{
174#endif
175
185
195
204
215void templog6_generic_write ( templog6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
216
227void templog6_generic_read ( templog6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
228
238void templog6_write_byte ( templog6_t *ctx, uint8_t reg, uint8_t data_buf );
239
248uint8_t templog6_read_byte ( templog6_t *ctx, uint8_t reg );
249
258
259#ifdef __cplusplus
260}
261#endif
262#endif // _TEMPLOG6_H_
263
264 // End public_function group
266
267// ------------------------------------------------------------------------- END
#define TEMPLOG6_RETVAL
Definition templog6.h:75
void templog6_default_cfg(templog6_t *ctx)
Click Default Configuration function.
uint8_t templog6_read_byte(templog6_t *ctx, uint8_t reg)
Read one byte function.
void templog6_generic_read(templog6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void templog6_write_byte(templog6_t *ctx, uint8_t reg, uint8_t data_buf)
Write one byte function.
void templog6_cfg_setup(templog6_cfg_t *cfg)
Config Object Initialization function.
TEMPLOG6_RETVAL templog6_init(templog6_t *ctx, templog6_cfg_t *cfg)
Initialization function.
void templog6_generic_write(templog6_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t templog6_get_interrupt(templog6_t *ctx)
Gets interrupt.
Click configuration structure definition.
Definition templog6.h:147
uint32_t i2c_speed
Definition templog6.h:159
pin_name_t scl
Definition templog6.h:150
pin_name_t int_pin
Definition templog6.h:155
pin_name_t sda
Definition templog6.h:151
uint8_t i2c_address
Definition templog6.h:160
Click ctx object definition.
Definition templog6.h:128
digital_in_t int_pin
Definition templog6.h:131
i2c_master_t i2c
Definition templog6.h:135
uint8_t slave_address
Definition templog6.h:139