39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_one_wire.h"
73#define THERMO2_CMD_CONVERT_TEMPERATURE 0x44
74#define THERMO2_CMD_WRITE_SCRATCHPAD 0x4E
75#define THERMO2_CMD_READ_SCRATCHPAD 0xBE
76#define THERMO2_CMD_COPY_SCRATCHPAD 0x48
77#define THERMO2_CMD_RECALL_SCRATCHPAD 0xB8
78#define THERMO2_CMD_READ_POWER_SUPPLY 0xB4
96#define THERMO2_CONFIG_ADDRESS_0 0x00
97#define THERMO2_CONFIG_ADDRESS_1 0x01
98#define THERMO2_CONFIG_ADDRESS_2 0x02
99#define THERMO2_CONFIG_ADDRESS_3 0x03
100#define THERMO2_CONFIG_ADDRESS_4 0x04
101#define THERMO2_CONFIG_ADDRESS_5 0x05
102#define THERMO2_CONFIG_ADDRESS_6 0x06
103#define THERMO2_CONFIG_ADDRESS_7 0x07
104#define THERMO2_CONFIG_ADDRESS_8 0x08
105#define THERMO2_CONFIG_ADDRESS_9 0x09
106#define THERMO2_CONFIG_ADDRESS_10 0x0A
107#define THERMO2_CONFIG_ADDRESS_11 0x0B
108#define THERMO2_CONFIG_ADDRESS_12 0x0C
109#define THERMO2_CONFIG_ADDRESS_13 0x0D
110#define THERMO2_CONFIG_ADDRESS_14 0x0E
111#define THERMO2_CONFIG_ADDRESS_15 0x0F
112#define THERMO2_CONFIG_ADDRESS_ALL 0x10
113#define THERMO2_CONFIG_ADDRESS_BIT_MASK 0x1F
114#define THERMO2_CONFIG_RESOLUTION_9BIT 0x00
115#define THERMO2_CONFIG_RESOLUTION_10BIT 0x20
116#define THERMO2_CONFIG_RESOLUTION_11BIT 0x40
117#define THERMO2_CONFIG_RESOLUTION_12BIT 0x60
118#define THERMO2_CONFIG_RESOLUTION_BIT_MASK 0x60
119#define THERMO2_CONFIG_RESERVED_BITS 0x10
125#define THERMO2_DATA_RESOLUTION 0.0625
131#define THERMO2_FAMILY_CODE 0x3B
137#define THERMO2_DEFAULT_ADDRESS THERMO2_CONFIG_ADDRESS_ALL
138#define THERMO2_DEFAULT_RESOLUTION THERMO2_CONFIG_RESOLUTION_12BIT
139#define THERMO2_DEFAULT_TEMP_HIGH_ALARM 0xFF
140#define THERMO2_DEFAULT_TEMP_LOW_ALARM 0x00
158#define THERMO2_MAP_MIKROBUS( cfg, mikrobus ) \
159 cfg.gp0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
160 cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_AN );
err_t thermo2_init(thermo2_t *ctx, thermo2_cfg_t *cfg)
Thermo 2 initialization function.
err_t thermo2_write_scratchpad(thermo2_t *ctx, uint8_t temp_high, uint8_t temp_low, uint8_t config)
Thermo 2 write scratchpad function.
err_t thermo2_read_scratchpad(thermo2_t *ctx, uint8_t *scratchpad)
Thermo 2 read scratchpad function.
void thermo2_gpio_selection(thermo2_cfg_t *cfg, thermo2_gpio_sel_t gpio_sel)
Thermo 2 driver interface setup function.
err_t thermo2_read_temperature(thermo2_t *ctx, float *temperature)
Thermo 2 read temperature function.
err_t thermo2_start_measurement(thermo2_t *ctx)
Thermo 2 start measurement function.
err_t thermo2_check_communication(thermo2_t *ctx)
Thermo 2 check communication function.
err_t thermo2_default_cfg(thermo2_t *ctx)
Thermo 2 default configuration function.
err_t thermo2_select_device(thermo2_t *ctx)
Thermo 2 select device function.
void thermo2_cfg_setup(thermo2_cfg_t *cfg)
Thermo 2 configuration object setup function.
Thermo 2 Click configuration object.
Definition thermo2.h:195
thermo2_gpio_sel_t gpio_sel
Definition thermo2.h:200
pin_name_t gp0
Definition thermo2.h:197
pin_name_t gp1
Definition thermo2.h:198
Thermo 2 Click context object.
Definition thermo2.h:181
one_wire_rom_address_t rom_addr
Definition thermo2.h:185
uint8_t config
Definition thermo2.h:186
one_wire_t ow
Definition thermo2.h:183
thermo2_gpio_sel_t
Thermo 2 Click gpio selector.
Definition thermo2.h:170
@ THERMO2_GPIO_0
Definition thermo2.h:171
@ THERMO2_GPIO_1
Definition thermo2.h:172
thermo2_return_value_t
Thermo 2 Click return value data.
Definition thermo2.h:209
@ THERMO2_OK
Definition thermo2.h:210
@ THERMO2_ERROR
Definition thermo2.h:211