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 BATTBOOST_REG_STATUS 0x00
74#define BATTBOOST_REG_CHENERGY_3 0x01
75#define BATTBOOST_REG_CHENERGY_2 0x02
76#define BATTBOOST_REG_CHENERGY_1 0x03
77#define BATTBOOST_REG_CHENERGY_0 0x04
78#define BATTBOOST_REG_VCAP 0x05
79#define BATTBOOST_REG_VCHEND 0x06
80#define BATTBOOST_REG_PROFILE_MSB 0x07
81#define BATTBOOST_REG_COMMAND 0x08
82#define BATTBOOST_REG_SET1 0x09
83#define BATTBOOST_REG_SET2 0x0A
84#define BATTBOOST_REG_SET3 0x0B
85#define BATTBOOST_REG_SET4 0x0C
86#define BATTBOOST_REG_SET5 0x0D
104#define BATTBOOST_STATUS_LOWBAT 0x80
105#define BATTBOOST_STATUS_EW 0x40
106#define BATTBOOST_STATUS_ALRM 0x20
107#define BATTBOOST_STATUS_RDY 0x01
113#define BATTBOOST_VCAP_BIT_MASK 0x1F
119#define BATTBOOST_VCHEND_BIT_MASK 0x1F
125#define BATTBOOST_SET2_VMIN_2_4V 2.4f
126#define BATTBOOST_SET2_VMIN_2_6V 2.6f
127#define BATTBOOST_SET2_VMIN_2_8V 2.8f
128#define BATTBOOST_SET2_VMIN_3_0V 3.0f
129#define BATTBOOST_SET2_VMIN_3_2V 3.2f
130#define BATTBOOST_SET2_VMIN_BIT_MASK 0xF8
131#define BATTBOOST_SET2_ICH_BIT_MASK 0x1F
132#define BATTBOOST_SET2_SET_VDH_VBT 0x10
138#define BATTBOOST_SET3_VEW_2_4V 0
139#define BATTBOOST_SET3_VEW_2_6V 1
140#define BATTBOOST_SET3_VEW_2_8V 2
141#define BATTBOOST_SET3_VEW_3_0V 3
142#define BATTBOOST_SET3_VEW_3_2V 4
143#define BATTBOOST_SET3_VEW_3_4V 5
144#define BATTBOOST_SET3_VEW_3_6V 6
145#define BATTBOOST_SET3_VEW_3_84V 7
146#define BATTBOOST_SET3_VEW_4_1V 8
147#define BATTBOOST_SET3_VEW_4_3V 9
148#define BATTBOOST_SET3_VEW_BIT_MASK 0x0F
149#define BATTBOOST_SET3_EEW_DISABLE 0
150#define BATTBOOST_SET3_EEW_ENABLE 1
156#define BATTBOOST_SET5_OPT_MARG_MIN 0
157#define BATTBOOST_SET5_OPT_MARG_NORMAL 1
158#define BATTBOOST_SET5_OPT_MARG_SAFE 2
159#define BATTBOOST_SET5_OPT_MARG_EXTRA_SAFE 3
165#define BATTBOOST_SET4_VCAPMAX_4_95V 0
166#define BATTBOOST_SET4_VCAPMAX_5_54V 1
167#define BATTBOOST_SET4_VCAPMAX_BIT_MASK 0xEF
174#define BATTBOOST_CMD_PROF_0_FIXED_MODE 0
175#define BATTBOOST_CMD_PROF_BIT_MASK 0xFC
176#define BATTBOOST_CMD_BIT_MASK 0x0F
177#define BATTBOOST_PROF_MSB_BIT_MASK 0x03
178#define BATTBOOST_PROF_BIT_MASK 0xF0
184#define BATTBOOST_OP_MODE_STANDBY 0
185#define BATTBOOST_OP_MODE_STBY_BIT_MASK 0x06
186#define BATTBOOST_OP_MODE_CHARGE 1
187#define BATTBOOST_OP_MODE_CHG_BIT_MASK 0xF0
188#define BATTBOOST_OP_MODE_SET_CHARGE 0x02
189#define BATTBOOST_OP_MODE_ACTIVE 2
190#define BATTBOOST_OP_MODE_SET_ACT_ACTIVE 0x04
196#define BATTBOOST_CMD_RESET_BIT_MASK 0x08
202#define BATTBOOST_CMD_AUTOMODE_ENABLE 0x80
208#define BATTBOOST_SET1_VSET_1_8V 1.8f
209#define BATTBOOST_SET1_VSET_2_0V 2.0f
210#define BATTBOOST_SET1_VSET_2_2V 2.2f
211#define BATTBOOST_SET1_VSET_2_4V 2.4f
212#define BATTBOOST_SET1_VSET_2_5V 2.5f
213#define BATTBOOST_SET1_VSET_2_6V 2.6f
214#define BATTBOOST_SET1_VSET_2_7V 2.7f
215#define BATTBOOST_SET1_VSET_2_8V 2.8f
216#define BATTBOOST_SET1_VSET_2_9V 2.9f
217#define BATTBOOST_SET1_VSET_3_0V 3.0f
218#define BATTBOOST_SET1_VSET_3_1V 3.1f
219#define BATTBOOST_SET1_VSET_3_2V 3.2f
220#define BATTBOOST_SET1_VSET_3_3V 3.3f
221#define BATTBOOST_SET1_VSET_3_4V 3.4f
222#define BATTBOOST_SET1_VSET_3_5V 3.5f
223#define BATTBOOST_SET1_VSET_3_6V 3.6f
224#define BATTBOOST_SET1_VSET_BIT_MASK 0xF0
225#define BATTBOOST_SET1_VFIX_BIT_MASK 0x0F
231#define BATTBOOST_CONDITION_STOP 0
232#define BATTBOOST_CONDITION_START 1
238#define BATTBOOST_STATUS_NOT_READY 0
239#define BATTBOOST_STATUS_READY 1
246#define BATTBOOST_DEVICE_ADDRESS_0 0x2E
247#define BATTBOOST_DEVICE_ADDRESS_1 0x2F
265#define BATTBOOST_MAP_MIKROBUS( cfg, mikrobus ) \
266 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
267 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
268 cfg.on = MIKROBUS( mikrobus, MIKROBUS_RST ); \
269 cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
battboost_vfix_t
BATT Boost Click capacitor end-of-charge voltage.
Definition battboost.h:327
@ BATTBOOST_VFIX_3_27V
Definition battboost.h:330
@ BATTBOOST_VFIX_4_55V
Definition battboost.h:335
@ BATTBOOST_VFIX_3_84V
Definition battboost.h:332
@ BATTBOOST_VFIX_3_57V
Definition battboost.h:331
@ BATTBOOST_VFIX_2_60V
Definition battboost.h:328
@ BATTBOOST_VFIX_5_34V
Definition battboost.h:339
@ BATTBOOST_VFIX_4_10V
Definition battboost.h:333
@ BATTBOOST_VFIX_4_33V
Definition battboost.h:334
@ BATTBOOST_VFIX_5_16V
Definition battboost.h:338
@ BATTBOOST_VFIX_2_95V
Definition battboost.h:329
@ BATTBOOST_VFIX_4_95V
Definition battboost.h:337
@ BATTBOOST_VFIX_4_76V
Definition battboost.h:336
@ BATTBOOST_VFIX_5_54V
Definition battboost.h:340
battboost_ich_t
BATT Boost Click capacitor charge current.
Definition battboost.h:349
@ BATTBOOST_ICH_50_MA
Definition battboost.h:354
@ BATTBOOST_ICH_8_MA
Definition battboost.h:352
@ BATTBOOST_ICH_2_MA
Definition battboost.h:350
@ BATTBOOST_ICH_4_MA
Definition battboost.h:351
@ BATTBOOST_ICH_16_MA
Definition battboost.h:353
battboost_return_value_t
BATT Boost Click return value data.
Definition battboost.h:316
@ BATTBOOST_OK
Definition battboost.h:317
@ BATTBOOST_ERROR
Definition battboost.h:318
err_t battboost_generic_write(battboost_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
BATT Boost I2C writing function.
err_t battboost_reset_optimizer(battboost_t *ctx)
BATT Boost reset optimizer result function.
err_t battboost_set_vcapmax(battboost_t *ctx, uint8_t vcapmax)
BATT Boost sets the capacitor maximum storage voltage function.
err_t battboost_generic_read(battboost_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
BATT Boost I2C reading function.
err_t battboost_set_ich(battboost_t *ctx, battboost_ich_t ich)
BATT Boost sets the charge current function.
err_t battboost_get_vcap(battboost_t *ctx, float *vcap)
BATT Boost gets the storage capacitor voltage status function.
err_t battboost_high_impedance_mode(battboost_t *ctx)
BATT Boost sets the high-impedance mode function.
err_t battboost_set_op_mode(battboost_t *ctx, uint8_t op_mode)
BATT Boost sets the operating mode function.
err_t battboost_init(battboost_t *ctx, battboost_cfg_t *cfg)
BATT Boost initialization function.
err_t battboost_get_vchend(battboost_t *ctx, uint8_t *vchend)
BATT Boost gets the target charge voltage function.
void battboost_set_on_pin_state(battboost_t *ctx, uint8_t start)
BATT Boost sets the ON pin state function.
err_t battboost_set_vfix(battboost_t *ctx, battboost_vfix_t vfix)
BATT Boost sets the end-of-charge voltage function.
err_t battboost_get_status(battboost_t *ctx, uint8_t *status)
BATT Boost gets the status function.
err_t battboost_set_vew(battboost_t *ctx, uint8_t vew, uint8_t eew)
BATT Boost sets the early warning voltage function.
err_t battboost_set_opt_marg(battboost_t *ctx, uint8_t opt_marg)
BATT Boost sets the optimization margin voltage function.
err_t battboost_set_automode(battboost_t *ctx)
BATT Boost sets the auto mode function.
err_t battboost_set_prof(battboost_t *ctx, uint8_t prof)
BATT Boost sets optimizer profile number function.
err_t battboost_default_cfg(battboost_t *ctx)
BATT Boost default configuration function.
err_t battboost_set_vmin(battboost_t *ctx, float vmin)
BATT Boost sets the input threshold voltage function.
void battboost_cfg_setup(battboost_cfg_t *cfg)
BATT Boost configuration object setup function.
err_t battboost_get_chenergy(battboost_t *ctx, uint32_t *chenergy)
BATT Boost gets the charge cycle count function.
err_t battboost_set_vset(battboost_t *ctx, float vset)
BATT Boost sets the output voltage function.
uint8_t battboost_get_ready(battboost_t *ctx)
BATT Boost gets ready state function.
err_t battboost_vdh_vbt_mode(battboost_t *ctx)
BATT Boost sets the Vvdh Vvbt mode function.
err_t battboost_get_prof(battboost_t *ctx, uint8_t *prof)
BATT Boost gets optimizer profile number function.
BATT Boost Click configuration object.
Definition battboost.h:299
uint32_t i2c_speed
Definition battboost.h:306
pin_name_t on
Definition battboost.h:303
pin_name_t scl
Definition battboost.h:300
pin_name_t rdy
Definition battboost.h:304
pin_name_t sda
Definition battboost.h:301
uint8_t i2c_address
Definition battboost.h:307
BATT Boost Click context object.
Definition battboost.h:279
digital_out_t on
Definition battboost.h:281
i2c_master_t i2c
Definition battboost.h:287
uint8_t slave_address
Definition battboost.h:290
digital_in_t rdy
Definition battboost.h:284