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 CHARGER6_REGISTER_00 0x00
74#define CHARGER6_REGISTER_01 0x01
75#define CHARGER6_REGISTER_02 0x02
76#define CHARGER6_REGISTER_03 0x03
77#define CHARGER6_REGISTER_04 0x04
78#define CHARGER6_REGISTER_05 0x05
79#define CHARGER6_REGISTER_06 0x06
80#define CHARGER6_REGISTER_07 0x07
81#define CHARGER6_REGISTER_08 0x08
82#define CHARGER6_REGISTER_09 0x09
83#define CHARGER6_REGISTER_0A 0x0A
84#define CHARGER6_REGISTER_0B 0x0B
103#define CHARGER6_PSEL_SW_MANUAL 0x00
104#define CHARGER6_PSEL_500_mA 0x01
123#define CHARGER6_SYS_MIN_VTG_2600mV 2600
124#define CHARGER6_SYS_MIN_VTG_2800mV 2800
125#define CHARGER6_SYS_MIN_VTG_3000mV 3000
126#define CHARGER6_SYS_MIN_VTG_3200mV 3200
127#define CHARGER6_SYS_MIN_VTG_3400mV 3400
128#define CHARGER6_SYS_MIN_VTG_3500mV 3500
129#define CHARGER6_SYS_MIN_VTG_3600mV 3600
130#define CHARGER6_SYS_MIN_VTG_3700mV 3700
149#define CHARGER6_TOPOFF_TIMER_DISABLE 0
150#define CHARGER6_TOPOFF_TIMER_15_MINUTES 15
151#define CHARGER6_TOPOFF_TIMER_30_MINUTES 30
152#define CHARGER6_TOPOFF_TIMER_45_MINUTES 45
176#define CHARGER6_R00_EN_HIZ_DISABLE 0x00
177#define CHARGER6_R00_EN_HIZ_ENABLE 0x80
178#define CHARGER6_R00_EN_ICHG_MON_ENABLE 0x00
179#define CHARGER6_R00_EN_ICHG_MON_DISABLE_STAT 0x60
180#define CHARGER6_R00_IINDPM_1600mA 0x10
181#define CHARGER6_R00_IINDPM_800mA 0x08
182#define CHARGER6_R00_IINDPM_400mA 0x04
183#define CHARGER6_R00_IINDPM_200mA 0x02
184#define CHARGER6_R00_IINDPM_100mA 0x01
191#define CHARGER6_R01_PFM_ENABLE 0x00
192#define CHARGER6_R01_PFM_DISABLE 0x80
193#define CHARGER6_R01_WD_RST_NORMAL 0x00
194#define CHARGER6_R01_WD_RST_RESET 0x40
195#define CHARGER6_R01_OTG_DISABLE 0x00
196#define CHARGER6_R01_OTG_ENABLE 0x20
197#define CHARGER6_R01_CHARGE_DISABLE 0x00
198#define CHARGER6_R01_CHARGE_ENABLE 0x10
199#define CHARGER6_R01_SYS_MIN_2600mV 0x00
200#define CHARGER6_R01_SYS_MIN_2800mV 0x02
201#define CHARGER6_R01_SYS_MIN_3000mV 0x04
202#define CHARGER6_R01_SYS_MIN_3200mV 0x06
203#define CHARGER6_R01_SYS_MIN_3400mV 0x08
204#define CHARGER6_R01_SYS_MIN_3500mV 0x0A
205#define CHARGER6_R01_SYS_MIN_3600mV 0x0C
206#define CHARGER6_R01_SYS_MIN_3700mV 0x0E
207#define CHARGER6_R01_MIN_VBAT_SEL_2800mV 0x00
208#define CHARGER6_R01_MIN_VBAT_SEL_2500mV 0x01
215#define CHARGER6_R02_BOOST_LIM_500mA 0x00
216#define CHARGER6_R02_BOOST_LIM_1200mA 0x80
217#define CHARGER6_R02_Q1_FULLON_BETTER_ACCURACY 0x00
218#define CHARGER6_R02_Q1_FULLON_BETTER_EFFICIENCY 0x40
219#define CHARGER6_R02_ICHG_1920mA 0x20
220#define CHARGER6_R02_ICHG_960mA 0x10
221#define CHARGER6_R02_ICHG_480mA 0x08
222#define CHARGER6_R02_ICHG_240mA 0x04
223#define CHARGER6_R02_ICHG_120mA 0x02
224#define CHARGER6_R02_ICHG_60mA 0x01
231#define CHARGER6_R03_IPRECHG_480mA 0x80
232#define CHARGER6_R03_IPRECHG_240mA 0x40
233#define CHARGER6_R03_IPRECHG_120mA 0x20
234#define CHARGER6_R03_IPRECHG_60mA 0x10
235#define CHARGER6_R03_ITERM_480mA 0x08
236#define CHARGER6_R03_ITERM_240mA 0x04
237#define CHARGER6_R03_ITERM_120mA 0x02
238#define CHARGER6_R03_ITERM_60mA 0x01
245#define CHARGER6_R04_VREG_512mV 0x80
246#define CHARGER6_R04_VREG_256mV 0x40
247#define CHARGER6_R04_VREG_128mV 0x20
248#define CHARGER6_R04_VREG_64mV 0x10
249#define CHARGER6_R04_VREG_32mV 0x08
250#define CHARGER6_R04_TOPOFF_TIMER_DISABLED 0x00
251#define CHARGER6_R04_TOPOFF_TIMER_15_MIN 0x02
252#define CHARGER6_R04_TOPOFF_TIMER_30_MIN 0x04
253#define CHARGER6_R04_TOPOFF_TIMER_45_MIN 0x06
254#define CHARGER6_R04_VRECHG_100mV 0x00
255#define CHARGER6_R04_VRECHG_200mV 0x01
262#define CHARGER6_R05_TERMINATION_DISABLE 0x00
263#define CHARGER6_R05_TERMINATION_ENABLE 0x80
264#define CHARGER6_R05_WATCHDOG_DISABLE 0x00
265#define CHARGER6_R05_WATCHDOG_TIMER_40_SEC 0x10
266#define CHARGER6_R05_WATCHDOG_TIMER_80_SEC 0x20
267#define CHARGER6_R05_WATCHDOG_TIMER_160_SEC 0x30
268#define CHARGER6_R05_TIMER_DISABLE 0x00
269#define CHARGER6_R05_TIMER_ENABLE 0x08
270#define CHARGER6_R05_CHG_TIMER_5_HOURS 0x00
271#define CHARGER6_R05_CHG_TIMER_10_HOURS 0x04
272#define CHARGER6_R05_TREG_90_C 0x00
273#define CHARGER6_R05_TREG_110_C 0x02
274#define CHARGER6_R05_JEITA_ISET_50 0x00
275#define CHARGER6_R05_JEITA_ISET_20 0x01
282#define CHARGER6_R06_OVP_TSH_5500mV 0x00
283#define CHARGER6_R06_OVP_TSH_6500mV 0x40
284#define CHARGER6_R06_OVP_TSH_10500mV 0x80
285#define CHARGER6_R06_OVP_TSH_14000mV 0xC0
286#define CHARGER6_R06_BOOSTV_4850mV 0x00
287#define CHARGER6_R06_BOOSTV_5000mV 0x10
288#define CHARGER6_R06_BOOSTV_5150mV 0x20
289#define CHARGER6_R06_BOOSTV_5300mV 0x30
290#define CHARGER6_R06_VINDPM_800mV 0x08
291#define CHARGER6_R06_VINDPM_400mV 0x04
292#define CHARGER6_R06_VINDPM_200mV 0x02
293#define CHARGER6_R06_VINDPM_100mV 0x01
300#define CHARGER6_R07_NOT_IN_INPUT_CURRENT_LIMIT 0x00
301#define CHARGER6_R07_FORCE_INPUT_CURRENT_LIMIT 0x80
302#define CHARGER6_R07_TMR2X_DISABLE 0x00
303#define CHARGER6_R07_TMR2X_ENABLE 0x40
304#define CHARGER6_R07_BATFET_ALLOW_Q4_TURN_ON 0x00
305#define CHARGER6_R07_BATFET_TURN_OFF_Q4 0x20
306#define CHARGER6_R07_JEITA_VSET_TO_4100mV 0x00
307#define CHARGER6_R07_JEITA_VSET_TO_VREG 0x10
308#define CHARGER6_R07_BATFET_IMMEDIATELY 0x00
309#define CHARGER6_R07_BATFET_AFTER_10_SEC 0x08
310#define CHARGER6_R07_BATFET_RST_DISABLE 0x00
311#define CHARGER6_R07_BATFET_RST_ENABLE 0x04
312#define CHARGER6_R07_VDPM_BAT_TRACK_DISABLE 0x00
313#define CHARGER6_R07_VDPM_BAT_TRACK_VBAT_PLUS_200mV 0x01
314#define CHARGER6_R07_VDPM_BAT_TRACK_VBAT_PLUS_250mV 0x02
315#define CHARGER6_R07_VDPM_BAT_TRACK_VBAT_PLUS_300mV 0x03
322#define CHARGER6_R08_VBUS_BIT_MASK 0xE0
323#define CHARGER6_R08_VBUS_STAT_NO_INPUT 0x00
324#define CHARGER6_R08_VBUS_STAT_USB_HOST_SDP 0x20
325#define CHARGER6_R08_VBUS_STAT_ADAPTER_2_4_A 0x40
326#define CHARGER6_R08_VBUS_OTG 0xE0
327#define CHARGER6_R08_CHRG_STAT_BIT_MASK 0x18
328#define CHARGER6_R08_CHRG_STAT_NOT_CHARGING 0x00
329#define CHARGER6_R08_CHRG_STAT_PRE_CHARGE 0x08
330#define CHARGER6_R08_CHRG_STAT_FAST_CHARGING 0x10
331#define CHARGER6_R08_CHRG_STAT_CHARGE_TERMINATION 0x18
332#define CHARGER6_R08_PG_STAT_BIT_MASK 0x04
333#define CHARGER6_R08_PG_STAT_POWER_NOT_GOOD 0x00
334#define CHARGER6_R08_PG_STAT_POWER_GOOD 0x04
335#define CHARGER6_R08_THERM_STAT_BIT_MASK 0x02
336#define CHARGER6_R08_THERM_STAT_NOT_mAl 0x00
337#define CHARGER6_R08_THERM_STAT_mAl 0x02
338#define CHARGER6_R08_VSYS_BIT_MASK 0x01
339#define CHARGER6_R08_VSYS_STAT_NOT 0x00
340#define CHARGER6_R08_VSYS_STAT_VSYSM 0x01
347#define CHARGER6_R09_WATCHDOG_FAULT_BIT_MASK 0x80
348#define CHARGER6_R09_WATCHDOG_FAULT_NORMAL 0x00
349#define CHARGER6_R09_WATCHDOG_FAULT_TIMER_EXPIRATION 0x80
350#define CHARGER6_R09_BOOST_FAULT_BIT_MASK 0x40
351#define CHARGER6_R09_BOOST_FAULT_NORMAL 0x00
352#define CHARGER6_R09_BOOST_FAULT_VBUS_OVERLOADED 0x40
353#define CHARGER6_R09_CHRG_FAULT_BIT_MASK 0x30
354#define CHARGER6_R09_CHRG_FAULT_NORMAL 0x00
355#define CHARGER6_R09_CHRG_FAULT_INPUT_FAULT 0x10
356#define CHARGER6_R09_CHRG_FAULT_THERMAL_SHUTDOWN 0x20
357#define CHARGER6_R09_CHRG_FAULT_CHG_SAFETY_TIMER_EXP 0x30
358#define CHARGER6_R09_BAT_FAULT_BIT_MASK 0x08
359#define CHARGER6_R09_BAT_FAULT_NORMAL 0x00
360#define CHARGER6_R09_BAT_FAULT_BATOVP 0x08
361#define CHARGER6_R09_NTC_FAULT_BIT_MASK 0x07
362#define CHARGER6_R09_NTC_FAULT_NORMAL 0x00
363#define CHARGER6_R09_NTC_FAULT_WARM 0x02
364#define CHARGER6_R09_NTC_FAULT_COOL 0x03
365#define CHARGER6_R09_NTC_FAULT_COLD 0x05
366#define CHARGER6_R09_NTC_FAULT_HOT 0x06
373#define CHARGER6_R0A_VBUS_GD_BIT_MASK 0x80
374#define CHARGER6_R0A_VBUS_GD_NOT_VBUS 0x00
375#define CHARGER6_R0A_VBUS_GD_VBUS_ATTACHED 0x80
376#define CHARGER6_R0A_VBUS_GD_VINDPM_BIT_MASK 0x40
377#define CHARGER6_R0A_VBUS_GD_NOT_IN_VINDPM 0x00
378#define CHARGER6_R0A_VBUS_GD_IN_VINDPM 0x40
379#define CHARGER6_R0A_VBUS_GD_IINDPM_BIT_MASK 0x20
380#define CHARGER6_R0A_VBUS_GD_NOT_IN_IINDPM 0x00
381#define CHARGER6_R0A_VBUS_GD_IN_IINDPM 0x20
382#define CHARGER6_R0A_TOP_OFF_BIT_MASK 0x08
383#define CHARGER6_R0A_TOP_OFF_TIMER_NOT_COUNTING 0x00
384#define CHARGER6_R0A_TOP_OFF_TIMER_COUNTING 0x08
385#define CHARGER6_R0A_ACOV_STAT_BIT_MASK 0x04
386#define CHARGER6_R0A_ACOV_STAT_NOT_IN_ACOV 0x00
387#define CHARGER6_R0A_ACOV_STAT_IN_ACOV 0x04
388#define CHARGER6_R0A_VINDPM_INT_MASK_ALLOW 0x00
389#define CHARGER6_R0A_VINDPM_INT_MASK_MASK 0x02
390#define CHARGER6_R0A_IINDPM_INT_MASK_ALLOW 0x00
391#define CHARGER6_R0A_IINDPM_INT_MASK_MASK 0x01
398#define CHARGER6_R0B_DEV_ID_BIT_MASK 0x78
399#define CHARGER6_R0B_DEV_REV_BIT_MASK 0x03
407#define CHARGER6_SET_DEV_ADDR 0x6B
425#define CHARGER6_MAP_MIKROBUS( cfg, mikrobus ) \
426 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
427 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
428 cfg.ce = MIKROBUS( mikrobus, MIKROBUS_CS ); \
429 cfg.qon = MIKROBUS( mikrobus, MIKROBUS_RST ); \
430 cfg.psel = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
431 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
charger6_return_value_t
Charger 6 Click return value data.
Definition charger6.h:514
@ CHARGER6_ERROR
Definition charger6.h:516
@ CHARGER6_OK
Definition charger6.h:515
err_t charger6_get_status(charger6_t *ctx, charger6_status_t *chg_status)
Charger 6 get status function.
void charger6_disable_battery_charging(charger6_t *ctx)
Charger 6 charge disable function.
err_t charger6_set_charge_voltage(charger6_t *ctx, uint16_t charge_voltage)
Charger 6 set charge voltage function.
uint16_t charger6_get_fast_charge_current(charger6_t *ctx)
Charger 6 get fast charge current function.
err_t charger6_set_input_current_limit(charger6_t *ctx, uint16_t current_limit)
Charger 6 set input current limit function.
err_t charger6_generic_read(charger6_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Charger 6 I2C reading function.
err_t charger6_set_top_off_timer(charger6_t *ctx, uint8_t top_off_time)
Charger 6 set top OFF timer function.
err_t charger6_default_cfg(charger6_t *ctx)
Charger 6 default configuration function.
err_t charger6_set_system_minimum_voltage(charger6_t *ctx, uint16_t sys_min_voltage)
Charger 6 set system minimum voltage function.
err_t charger6_init(charger6_t *ctx, charger6_cfg_t *cfg)
Charger 6 initialization function.
void charger6_hw_reset(charger6_t *ctx)
Charger 6 hw reset function.
void charger6_enable_battery_charging(charger6_t *ctx)
Charger 6 charge enable function.
err_t charger6_set_precharge_current(charger6_t *ctx, uint16_t precharge_current)
Charger 6 set precharge current function.
uint8_t charger6_check_interrupt(charger6_t *ctx)
Charger 6 check interrupt function.
err_t charger6_set_termination_current(charger6_t *ctx, uint16_t termination_current)
Charger 6 set termination current function.
void charger6_power_source_selection(charger6_t *ctx, uint8_t pwr_sel)
Charger 6 power source selection function.
err_t charger6_generic_write(charger6_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Charger 6 I2C writing function.
err_t charger6_set_fast_charge_current(charger6_t *ctx, uint16_t fast_chg_current)
Charger 6 set fast charge current function.
void charger6_cfg_setup(charger6_cfg_t *cfg)
Charger 6 configuration object setup function.
charger6_status_t chg_status
Definition main.c:36
Charger 6 Click configuration object.
Definition charger6.h:467
uint32_t i2c_speed
Definition charger6.h:476
pin_name_t ce
Definition charger6.h:471
pin_name_t scl
Definition charger6.h:468
pin_name_t int_pin
Definition charger6.h:474
pin_name_t psel
Definition charger6.h:473
pin_name_t qon
Definition charger6.h:472
pin_name_t sda
Definition charger6.h:469
uint8_t i2c_address
Definition charger6.h:477
Charger 6 Click data status structure definition.
Definition charger6.h:486
uint8_t watchdog_fault
Definition charger6.h:492
uint8_t bat_fault
Definition charger6.h:495
uint8_t vindpm_int
Definition charger6.h:502
uint8_t dev_id
Definition charger6.h:504
uint8_t iindpm_int
Definition charger6.h:503
uint8_t therm_stat
Definition charger6.h:490
uint8_t ntc_fault
Definition charger6.h:496
uint8_t chrg_fault
Definition charger6.h:494
uint8_t vsys_stat
Definition charger6.h:491
uint8_t vbus_gd
Definition charger6.h:497
uint8_t dev_rev
Definition charger6.h:505
uint8_t vbus_stat
Definition charger6.h:487
uint8_t iindpm_stat
Definition charger6.h:499
uint8_t acov_stat
Definition charger6.h:501
uint8_t chrg_stat
Definition charger6.h:488
uint8_t vindpm_stat
Definition charger6.h:498
uint8_t pg_stat
Definition charger6.h:489
uint8_t boost_fault
Definition charger6.h:493
uint8_t topoff_active
Definition charger6.h:500
Charger 6 Click context object.
Definition charger6.h:441
digital_in_t int_pin
Definition charger6.h:450
i2c_master_t i2c
Definition charger6.h:454
digital_out_t qon
Definition charger6.h:445
uint8_t slave_address
Definition charger6.h:458
digital_out_t psel
Definition charger6.h:446
digital_out_t ce
Definition charger6.h:444