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 HWMONITOR3_REG_INT_SRC 0x10
74#define HWMONITOR3_REG_INT_MONITOR 0x11
75#define HWMONITOR3_REG_INT_UVHF 0x12
76#define HWMONITOR3_REG_INT_UVLF 0x14
77#define HWMONITOR3_REG_INT_OVHF 0x16
78#define HWMONITOR3_REG_INT_OVLF 0x18
79#define HWMONITOR3_REG_INT_SEQ_ON 0x1A
80#define HWMONITOR3_REG_INT_SEQ_OFF 0x1C
81#define HWMONITOR3_REG_INT_SEQ_EXS 0x1E
82#define HWMONITOR3_REG_INT_SEQ_ENS 0x20
83#define HWMONITOR3_REG_INT_CONTROL 0x22
84#define HWMONITOR3_REG_INT_TEST 0x23
85#define HWMONITOR3_REG_INT_VENDOR 0x24
86#define HWMONITOR3_REG_VMON_STAT 0x30
87#define HWMONITOR3_REG_TEST_INFO 0x31
88#define HWMONITOR3_REG_OFF_STAT 0x32
89#define HWMONITOR3_REG_SEQ_REC_STAT 0x34
90#define HWMONITOR3_REG_SEQ_OW_STAT 0x35
91#define HWMONITOR3_REG_SEQ_ORD_STAT 0x36
92#define HWMONITOR3_REG_MON_LVL_1 0x40
93#define HWMONITOR3_REG_MON_LVL_2 0x41
94#define HWMONITOR3_REG_MON_LVL_3 0x42
95#define HWMONITOR3_REG_MON_LVL_4 0x43
96#define HWMONITOR3_REG_MON_LVL_5 0x44
97#define HWMONITOR3_REG_MON_LVL_6 0x45
98#define HWMONITOR3_REG_SEQ_ON_LOG_1 0x50
99#define HWMONITOR3_REG_SEQ_ON_LOG_2 0x51
100#define HWMONITOR3_REG_SEQ_ON_LOG_3 0x52
101#define HWMONITOR3_REG_SEQ_ON_LOG_4 0x53
102#define HWMONITOR3_REG_SEQ_ON_LOG_5 0x54
103#define HWMONITOR3_REG_SEQ_ON_LOG_6 0x55
104#define HWMONITOR3_REG_SEQ_OFF_LOG_1 0x60
105#define HWMONITOR3_REG_SEQ_OFF_LOG_2 0x61
106#define HWMONITOR3_REG_SEQ_OFF_LOG_3 0x62
107#define HWMONITOR3_REG_SEQ_OFF_LOG_4 0x63
108#define HWMONITOR3_REG_SEQ_OFF_LOG_5 0x64
109#define HWMONITOR3_REG_SEQ_OFF_LOG_6 0x65
110#define HWMONITOR3_REG_SEQ_EXS_LOG_1 0x70
111#define HWMONITOR3_REG_SEQ_EXS_LOG_2 0x71
112#define HWMONITOR3_REG_SEQ_EXS_LOG_3 0x72
113#define HWMONITOR3_REG_SEQ_EXS_LOG_4 0x73
114#define HWMONITOR3_REG_SEQ_EXS_LOG_5 0x74
115#define HWMONITOR3_REG_SEQ_EXS_LOG_6 0x75
116#define HWMONITOR3_REG_SEQ_ENS_LOG_1 0x80
117#define HWMONITOR3_REG_SEQ_ENS_LOG_2 0x81
118#define HWMONITOR3_REG_SEQ_ENS_LOG_3 0x82
119#define HWMONITOR3_REG_SEQ_ENS_LOG_4 0x83
120#define HWMONITOR3_REG_SEQ_ENS_LOG_5 0x84
121#define HWMONITOR3_REG_SEQ_ENS_LOG_6 0x85
122#define HWMONITOR3_REG_SEQ_TIME_MSB_1 0x90
123#define HWMONITOR3_REG_SEQ_TIME_LSB_1 0x91
124#define HWMONITOR3_REG_SEQ_TIME_MSB_2 0x92
125#define HWMONITOR3_REG_SEQ_TIME_LSB_2 0x93
126#define HWMONITOR3_REG_SEQ_TIME_MSB_3 0x94
127#define HWMONITOR3_REG_SEQ_TIME_LSB_3 0x95
128#define HWMONITOR3_REG_SEQ_TIME_MSB_4 0x96
129#define HWMONITOR3_REG_SEQ_TIME_LSB_4 0x97
130#define HWMONITOR3_REG_SEQ_TIME_MSB_5 0x98
131#define HWMONITOR3_REG_SEQ_TIME_LSB_5 0x99
132#define HWMONITOR3_REG_SEQ_TIME_MSB_6 0x9A
133#define HWMONITOR3_REG_SEQ_TIME_LSB_6 0x9B
134#define HWMONITOR3_REG_BANK_SEL 0xF0
135#define HWMONITOR3_REG_PROT1 0xF1
136#define HWMONITOR3_REG_PROT2 0xF2
137#define HWMONITOR3_REG_PROT_MON2 0xF3
138#define HWMONITOR3_REG_I2CADDR 0xF9
139#define HWMONITOR3_REG_DEV_CFG 0xFA
145#define HWMONITOR3_REG_VMON_CTL 0x10
146#define HWMONITOR3_REG_VMON_MISC 0x11
147#define HWMONITOR3_REG_TEST_CFG 0x12
148#define HWMONITOR3_REG_IEN_UVHF 0x13
149#define HWMONITOR3_REG_IEN_UVLF 0x14
150#define HWMONITOR3_REG_IEN_OVHF 0x15
151#define HWMONITOR3_REG_IEN_OVLF 0x16
152#define HWMONITOR3_REG_IEN_SEQ_ON 0x17
153#define HWMONITOR3_REG_IEN_SEQ_OFF 0x18
154#define HWMONITOR3_REG_IEN_SEQ_EXS 0x19
155#define HWMONITOR3_REG_IEN_SEQ_ENS 0x1A
156#define HWMONITOR3_REG_IEN_CONTROL 0x1B
157#define HWMONITOR3_REG_IEN_TEST 0x1C
158#define HWMONITOR3_REG_MON_CH_EN 0x1E
159#define HWMONITOR3_REG_VRANGE_MULT 0x1F
160#define HWMONITOR3_REG_UV_HF_1 0x20
161#define HWMONITOR3_REG_OV_HF_1 0x21
162#define HWMONITOR3_REG_UV_LF_1 0x22
163#define HWMONITOR3_REG_OV_LF_1 0x23
164#define HWMONITOR3_REG_FLT_HF_1 0x24
165#define HWMONITOR3_REG_FC_LF_1 0x25
166#define HWMONITOR3_REG_UV_HF_2 0x30
167#define HWMONITOR3_REG_OV_HF_2 0x31
168#define HWMONITOR3_REG_UV_LF_2 0x32
169#define HWMONITOR3_REG_OV_LF_2 0x33
170#define HWMONITOR3_REG_FLT_HF_2 0x34
171#define HWMONITOR3_REG_FC_LF_2 0x35
172#define HWMONITOR3_REG_UV_HF_3 0x40
173#define HWMONITOR3_REG_OV_HF_3 0x41
174#define HWMONITOR3_REG_UV_LF_3 0x42
175#define HWMONITOR3_REG_OV_LF_3 0x43
176#define HWMONITOR3_REG_FLT_HF_3 0x44
177#define HWMONITOR3_REG_FC_LF_3 0x45
178#define HWMONITOR3_REG_UV_HF_4 0x50
179#define HWMONITOR3_REG_OV_HF_4 0x51
180#define HWMONITOR3_REG_UV_LF_4 0x52
181#define HWMONITOR3_REG_OV_LF_4 0x53
182#define HWMONITOR3_REG_FLT_HF_4 0x54
183#define HWMONITOR3_REG_FC_LF_4 0x55
184#define HWMONITOR3_REG_UV_HF_5 0x60
185#define HWMONITOR3_REG_OV_HF_5 0x61
186#define HWMONITOR3_REG_UV_LF_5 0x62
187#define HWMONITOR3_REG_OV_LF_5 0x63
188#define HWMONITOR3_REG_FLT_HF_5 0x64
189#define HWMONITOR3_REG_FC_LF_5 0x65
190#define HWMONITOR3_REG_UV_HF_6 0x70
191#define HWMONITOR3_REG_OV_HF_6 0x71
192#define HWMONITOR3_REG_UV_LF_6 0x72
193#define HWMONITOR3_REG_OV_LF_6 0x73
194#define HWMONITOR3_REG_FLT_HF_6 0x74
195#define HWMONITOR3_REG_FC_LF_6 0x75
196#define HWMONITOR3_REG_TI_CONTROL 0x9F
197#define HWMONITOR3_REG_SEQ_REC_CTL 0xA0
198#define HWMONITOR3_REG_AMSK_ON 0xA1
199#define HWMONITOR3_REG_AMSK_OFF 0xA2
200#define HWMONITOR3_REG_AMSK_EXS 0xA3
201#define HWMONITOR3_REG_AMSK_ENS 0xA4
202#define HWMONITOR3_REG_SEQ_TOUT_MSB 0xA5
203#define HWMONITOR3_REG_SEQ_TOUT_LSB 0xA6
204#define HWMONITOR3_REG_SEQ_SYNC 0xA7
205#define HWMONITOR3_REG_SEQ_UP_THLD 0xA8
206#define HWMONITOR3_REG_SEQ_DN_THLD 0xA9
207#define HWMONITOR3_REG_SEQ_DN_THLD 0xA9
208#define HWMONITOR3_REG_SEQ_ON_EXP_1 0xB0
209#define HWMONITOR3_REG_SEQ_ON_EXP_2 0xB1
210#define HWMONITOR3_REG_SEQ_ON_EXP_3 0xB2
211#define HWMONITOR3_REG_SEQ_ON_EXP_4 0xB3
212#define HWMONITOR3_REG_SEQ_ON_EXP_5 0xB4
213#define HWMONITOR3_REG_SEQ_ON_EXP_6 0xB5
214#define HWMONITOR3_REG_SEQ_OFF_EXP_1 0xC0
215#define HWMONITOR3_REG_SEQ_OFF_EXP_2 0xC1
216#define HWMONITOR3_REG_SEQ_OFF_EXP_3 0xC2
217#define HWMONITOR3_REG_SEQ_OFF_EXP_4 0xC3
218#define HWMONITOR3_REG_SEQ_OFF_EXP_5 0xC4
219#define HWMONITOR3_REG_SEQ_OFF_EXP_6 0xC5
220#define HWMONITOR3_REG_SEQ_EXS_EXP_1 0xD0
221#define HWMONITOR3_REG_SEQ_EXS_EXP_2 0xD1
222#define HWMONITOR3_REG_SEQ_EXS_EXP_3 0xD2
223#define HWMONITOR3_REG_SEQ_EXS_EXP_4 0xD3
224#define HWMONITOR3_REG_SEQ_EXS_EXP_5 0xD4
225#define HWMONITOR3_REG_SEQ_EXS_EXP_6 0xD5
226#define HWMONITOR3_REG_SEQ_ENS_EXP_1 0xE0
227#define HWMONITOR3_REG_SEQ_ENS_EXP_2 0xE1
228#define HWMONITOR3_REG_SEQ_ENS_EXP_3 0xE2
229#define HWMONITOR3_REG_SEQ_ENS_EXP_4 0xE3
230#define HWMONITOR3_REG_SEQ_ENS_EXP_5 0xE4
231#define HWMONITOR3_REG_SEQ_ENS_EXP_6 0xE5
249#define HWMONITOR3_SCALING_1X 0
250#define HWMONITOR3_SCALING_4X 1
256#define HWMONITOR3_CHANNEL_NONE 0x00
257#define HWMONITOR3_CHANNEL_1 0x01
258#define HWMONITOR3_CHANNEL_2 0x02
259#define HWMONITOR3_CHANNEL_3 0x04
260#define HWMONITOR3_CHANNEL_4 0x08
261#define HWMONITOR3_CHANNEL_5 0x10
262#define HWMONITOR3_CHANNEL_6 0x20
263#define HWMONITOR3_CHANNEL_ALL 0x3F
269#define HWMONITOR3_DATA_RES 0.005
270#define HWMONITOR3_DATA_OFFSET 0.2
271#define HWMONITOR3_DATA_SCALE_4X 4.0
278#define HWMONITOR3_DEVICE_ADDRESS_0 0x33
279#define HWMONITOR3_DEVICE_ADDRESS_1 0x37
297#define HWMONITOR3_MAP_MIKROBUS( cfg, mikrobus ) \
298 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
299 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
300 cfg.sync = MIKROBUS( mikrobus, MIKROBUS_AN ); \
301 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST ); \
302 cfg.sleep = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
303 cfg.irq = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t hwmonitor3_default_cfg(hwmonitor3_t *ctx)
HW Monitor 3 default configuration function.
err_t hwmonitor3_read_reg(hwmonitor3_t *ctx, uint8_t reg, uint8_t *data_out)
HW Monitor 3 read reg function.
err_t hwmonitor3_select_bank1(hwmonitor3_t *ctx)
HW Monitor 3 select bank1 function.
err_t hwmonitor3_read_regs(hwmonitor3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
HW Monitor 3 read regs function.
void hwmonitor3_set_en_pin(hwmonitor3_t *ctx, uint8_t state)
HW Monitor 3 set en pin function.
uint8_t hwmonitor3_get_irq_pin(hwmonitor3_t *ctx)
HW Monitor 3 get irq pin function.
uint8_t hwmonitor3_get_sync_pin(hwmonitor3_t *ctx)
HW Monitor 3 get sync pin function.
void hwmonitor3_cfg_setup(hwmonitor3_cfg_t *cfg)
HW Monitor 3 configuration object setup function.
err_t hwmonitor3_select_bank0(hwmonitor3_t *ctx)
HW Monitor 3 select bank0 function.
err_t hwmonitor3_init(hwmonitor3_t *ctx, hwmonitor3_cfg_t *cfg)
HW Monitor 3 initialization function.
err_t hwmonitor3_check_communication(hwmonitor3_t *ctx)
HW Monitor 3 check communication function.
err_t hwmonitor3_read_voltage(hwmonitor3_t *ctx, hwmonitor3_ch_mon_t *ch_mon)
HW Monitor 3 read voltage function.
err_t hwmonitor3_write_regs(hwmonitor3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
HW Monitor 3 write regs function.
err_t hwmonitor3_enable_channel(hwmonitor3_t *ctx, uint8_t ch_mask)
HW Monitor 3 enable channel function.
err_t hwmonitor3_set_scaling(hwmonitor3_t *ctx, uint8_t scaling, uint8_t ch_mask)
HW Monitor 3 set scaling function.
err_t hwmonitor3_disable_channel(hwmonitor3_t *ctx, uint8_t ch_mask)
HW Monitor 3 disable channel function.
err_t hwmonitor3_write_reg(hwmonitor3_t *ctx, uint8_t reg, uint8_t data_in)
HW Monitor 3 write reg function.
void hwmonitor3_set_sleep_pin(hwmonitor3_t *ctx, uint8_t state)
HW Monitor 3 set sleep pin function.
hwmonitor3_return_value_t
HW Monitor 3 Click return value data.
Definition hwmonitor3.h:371
@ HWMONITOR3_ERROR
Definition hwmonitor3.h:373
@ HWMONITOR3_OK
Definition hwmonitor3.h:372
HW Monitor 3 Click configuration object.
Definition hwmonitor3.h:352
pin_name_t sleep
Definition hwmonitor3.h:358
pin_name_t sync
Definition hwmonitor3.h:356
uint32_t i2c_speed
Definition hwmonitor3.h:361
pin_name_t irq
Definition hwmonitor3.h:359
pin_name_t scl
Definition hwmonitor3.h:353
pin_name_t en
Definition hwmonitor3.h:357
pin_name_t sda
Definition hwmonitor3.h:354
uint8_t i2c_address
Definition hwmonitor3.h:362
HW Monitor 3 Click channel voltage monitor object.
Definition hwmonitor3.h:313
float ch6_v
Definition hwmonitor3.h:319
float ch4_v
Definition hwmonitor3.h:317
float ch5_v
Definition hwmonitor3.h:318
float ch3_v
Definition hwmonitor3.h:316
float ch2_v
Definition hwmonitor3.h:315
float ch1_v
Definition hwmonitor3.h:314
HW Monitor 3 Click context object.
Definition hwmonitor3.h:328
digital_out_t sleep
Definition hwmonitor3.h:331
digital_in_t sync
Definition hwmonitor3.h:334
digital_in_t irq
Definition hwmonitor3.h:335
i2c_master_t i2c
Definition hwmonitor3.h:338
digital_out_t en
Definition hwmonitor3.h:330
uint8_t slave_address
Definition hwmonitor3.h:341
uint8_t scaling
Definition hwmonitor3.h:343