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_i2c_master.h"
73#define TEMPALARM_REG_TEMP_LOCAL 0x00
74#define TEMPALARM_REG_TEMP_REMOTE_MSB 0x01
75#define TEMPALARM_REG_ALERT_STATUS 0x02
76#define TEMPALARM_REG_CONFIGURATION 0x03
77#define TEMPALARM_REG_CONV_PERIOD 0x04
78#define TEMPALARM_REG_THIGH_LIMIT_LOCAL 0x05
79#define TEMPALARM_REG_THIGH_LIMIT_REMOTE_MSB 0x07
80#define TEMPALARM_REG_TLOW_LIMIT_REMOTE_MSB 0x08
81#define TEMPALARM_REG_ONE_SHOT 0x0F
82#define TEMPALARM_REG_TEMP_REMOTE_LSB 0x10
83#define TEMPALARM_REG_REMOTE_OFFSET_MSB 0x11
84#define TEMPALARM_REG_REMOTE_OFFSET_LSB 0x12
85#define TEMPALARM_REG_THIGH_LIMIT_REMOTE_LSB 0x13
86#define TEMPALARM_REG_TLOW_LIMIT_REMOTE_LSB 0x14
87#define TEMPALARM_REG_ALERT_MASK 0x16
88#define TEMPALARM_REG_THIGH_CRIT_REMOTE 0x19
89#define TEMPALARM_REG_THIGH_CRIT_LOCAL 0x20
90#define TEMPALARM_REG_CRIT_HYSTERESIS 0x21
91#define TEMPALARM_REG_LOG1 0x2D
92#define TEMPALARM_REG_LOG2 0x2E
93#define TEMPALARM_REG_LOG3 0x2F
94#define TEMPALARM_REG_FILTER_ALERT_MODE 0xBF
95#define TEMPALARM_REG_CHIP_ID 0xFD
96#define TEMPALARM_REG_VENDOR_ID 0xFE
97#define TEMPALARM_REG_DEVICE_REV_ID 0xFF
115#define TEMPALARM_THIGH_LA_ALERT_DIS_MASK 0x80
116#define TEMPALARM_THIGH_LA_ALERT_ENABLE_MASK 0x80
117#define TEMPALARM_THIGH_RA_ALERT_DIS_MASK 0x10
118#define TEMPALARM_THIGH_RA_ALERT_ENABLE_MASK 0x00
119#define TEMPALARM_TLOW_RA_ALERT_DIS_MASK 0x08
120#define TEMPALARM_TLOW_RA_ALERT_ENABLE_MASK 0x00
121#define TEMPALARM_TCRIT_R_ALERT_DIS_MASK 0x02
122#define TEMPALARM_TCRIT_R_ALERT_ENABLE_MASK 0x00
123#define TEMPALARM_TCRIT_L_ALERT_DIS_MASK 0x01
124#define TEMPALARM_TCRIT_L_ALERT_ENABLE_MASK 0x00
130#define TEMPALARM_ADC_BUSY_MASK 0x80
131#define TEMPALARM_THIGH_LA_MASK 0x40
132#define TEMPALARM_THIGH_RA_MASK 0x10
133#define TEMPALARM_TLOW_RA_MASK 0x08
134#define TEMPALARM_REMOTE_DC_MASK 0x04
135#define TEMPALARM_TCRIT_R_MASK 0x02
136#define TEMPALARM_TCRIT_L_MASK 0x01
142#define TEMPALARM_FILTER_LEVEL_0_MASK 0x00
143#define TEMPALARM_FILTER_LEVEL_4_MASK 0x02
144#define TEMPALARM_FILTER_LEVEL_8_MASK 0x06
145#define TEMPALARM_INTERRUPT_ALERT_MODE 0x00
146#define TEMPALARM_COMPARATOR_MODE 0x01
152#define TEMPALARM_ALERT_DISABLED 0x80
153#define TEMPALARM_SHUTDOWN_MODE 0x40
154#define TEMPALARM_CONTINUOUS_MODE 0x00
155#define TEMPALARM_REMOTE_EN 0x04
156#define TEMPALARM_REMOTE_DIS 0x00
157#define TEMPALARM_WTC_EN 0x02
158#define TEMPALARM_WTC_DIS 0x00
159#define TEMPALARM_FAULT_QUE_EN 0x01
160#define TEMPALARM_FAULT_QUE_DIS 0x00
166#define TEMPALARM_CONVERSION_PERIOD_16S 0x00
167#define TEMPALARM_CONVERSION_PERIOD_8S 0x01
168#define TEMPALARM_CONVERSION_PERIOD_4S 0x02
169#define TEMPALARM_CONVERSION_PERIOD_2S 0x03
170#define TEMPALARM_CONVERSION_PERIOD_1S 0x04
171#define TEMPALARM_CONVERSION_PERIOD_500MS 0x05
172#define TEMPALARM_CONVERSION_PERIOD_250MS 0x06
173#define TEMPALARM_CONVERSION_PERIOD_125MS 0x07
174#define TEMPALARM_CONVERSION_PERIOD_62MS5 0x08
180#define TEMPALARM_PIN_STATE_HIGH 0x01
181#define TEMPALARM_PIN_STATE_LOW 0x00
187#define TEMPALARM_CHIP_ID 0x50
188#define TEMPALARM_VENDOR_ID 0x60
194#define TEMPALARM_TEMP_CLC 0.125f
201#define TEMPALARM_DEVICE_ADDRESS 0x4C
219#define TEMPALARM_MAP_MIKROBUS( cfg, mikrobus ) \
220 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
221 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
222 cfg.tcr = MIKROBUS( mikrobus, MIKROBUS_AN ); \
223 cfg.alr = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t tempalarm_write_reg(tempalarm_t *ctx, uint8_t reg, uint8_t data_in)
Temp Alarm register writing function.
err_t tempalarm_read_reg(tempalarm_t *ctx, uint8_t reg, uint8_t *data_out)
Temp Alarm register reading function.
void tempalarm_cfg_setup(tempalarm_cfg_t *cfg)
Temp Alarm configuration object setup function.
err_t tempalarm_set_limit_thigh(tempalarm_t *ctx, int8_t max_temperature)
Temp Alarm local sensor set limit high temperature function.
err_t tempalarm_read_remote_temp(tempalarm_t *ctx, float *temperature)
Temp Alarm remote sensor read temperature function.
err_t tempalarm_set_crit_thigh(tempalarm_t *ctx, int8_t max_temperature)
Temp Alarm local sensor set critical high temperature function.
err_t tempalarm_read_temperature(tempalarm_t *ctx, int8_t *temperature)
Temp Alarm local sensor read temperature function.
uint8_t tempalarm_get_tcr_pin(tempalarm_t *ctx)
Temp Alarm get critical temperature alert pin state function.
err_t tempalarm_default_cfg(tempalarm_t *ctx)
Temp Alarm default configuration function.
err_t tempalarm_generic_write(tempalarm_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Temp Alarm I2C writing function.
err_t tempalarm_generic_read(tempalarm_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Temp Alarm I2C reading function.
err_t tempalarm_get_alarms(tempalarm_t *ctx, uint8_t *alarms)
Temp Alarm read alarms state function.
err_t tempalarm_set_alarm_low_limit(tempalarm_t *ctx, float min_temperature)
Temp Alarm remote sensor set limit low temperature function.
uint8_t tempalarm_get_alr_pin(tempalarm_t *ctx)
Temp Alarm get alarm pin state function.
err_t tempalarm_init(tempalarm_t *ctx, tempalarm_cfg_t *cfg)
Temp Alarm initialization function.
err_t tempalarm_set_alarm_high_limit(tempalarm_t *ctx, float max_temperature)
Temp Alarm remote sensor set limit high temperature function.
Temp Alarm Click configuration object.
Definition tempalarm.h:251
pin_name_t alr
Definition tempalarm.h:256
uint32_t i2c_speed
Definition tempalarm.h:258
pin_name_t scl
Definition tempalarm.h:252
pin_name_t tcr
Definition tempalarm.h:255
pin_name_t sda
Definition tempalarm.h:253
uint8_t i2c_address
Definition tempalarm.h:259
Temp Alarm Click context object.
Definition tempalarm.h:233
digital_in_t tcr
Definition tempalarm.h:235
digital_in_t alr
Definition tempalarm.h:236
i2c_master_t i2c
Definition tempalarm.h:239
uint8_t slave_address
Definition tempalarm.h:242
tempalarm_return_value_t
Temp Alarm Click return value data.
Definition tempalarm.h:268
@ TEMPALARM_OK
Definition tempalarm.h:269
@ TEMPALARM_ERROR
Definition tempalarm.h:270