12static const uint8_t SY6970_REG_INPUT_CURRENT_LIMIT = 0x00;
13static const uint8_t SY6970_REG_VINDPM = 0x01;
14static const uint8_t SY6970_REG_ADC_CONTROL = 0x02;
15static const uint8_t SY6970_REG_SYS_CONTROL = 0x03;
16static const uint8_t SY6970_REG_CHARGE_CURRENT = 0x04;
17static const uint8_t SY6970_REG_PRECHARGE_CURRENT = 0x05;
18static const uint8_t SY6970_REG_CHARGE_VOLTAGE = 0x06;
19static const uint8_t SY6970_REG_TIMER_CONTROL = 0x07;
20static const uint8_t SY6970_REG_IR_COMP = 0x08;
21static const uint8_t SY6970_REG_FORCE_DPDM = 0x09;
22static const uint8_t SY6970_REG_BOOST_CONTROL = 0x0A;
23static const uint8_t SY6970_REG_STATUS = 0x0B;
24static const uint8_t SY6970_REG_FAULT = 0x0C;
25static const uint8_t SY6970_REG_VINDPM_STATUS = 0x0D;
26static const uint8_t SY6970_REG_BATV = 0x0E;
27static const uint8_t SY6970_REG_SYSV = 0x0F;
28static const uint8_t SY6970_REG_VBUS_VOLTAGE = 0x11;
29static const uint8_t SY6970_REG_CHARGE_CURRENT_MONITOR = 0x12;
30static const uint8_t SY6970_REG_INPUT_VOLTAGE_LIMIT = 0x13;
31static const uint8_t SY6970_REG_DEVICE_ID = 0x14;
34static const uint16_t VBUS_BASE_MV = 2600;
35static const uint16_t VBUS_STEP_MV = 100;
36static const uint16_t VBAT_BASE_MV = 2304;
37static const uint16_t VBAT_STEP_MV = 20;
38static const uint16_t VSYS_BASE_MV = 2304;
39static const uint16_t VSYS_STEP_MV = 20;
40static const uint16_t CHG_CURRENT_STEP_MA = 50;
41static const uint16_t PRE_CHG_BASE_MA = 64;
42static const uint16_t PRE_CHG_STEP_MA = 64;
43static const uint16_t CHG_VOLTAGE_BASE = 3840;
44static const uint16_t CHG_VOLTAGE_STEP = 16;
45static const uint16_t INPUT_CURRENT_MIN = 100;
46static const uint16_t INPUT_CURRENT_STEP = 50;
84 return (reg & 0x80) != 0 ? VBUS_BASE_MV + (reg & 0x7F) * VBUS_STEP_MV : 0;
93 "Non-Standard Adapter",
"OTG");
95PROGMEM_STRING_TABLE(NtcStatusStrings,
"Normal",
"Unknown",
"Warm",
"Cool",
"Unknown",
"Cold",
"Hot",
"Unknown");
99 SY6970Component(
bool led_enabled, uint16_t input_current_limit, uint16_t charge_voltage, uint16_t charge_current,
100 uint16_t precharge_current,
bool charge_enabled,
bool enable_adc,
110 void setup()
override;
114#ifdef USE_SY6970_DATA_PUBLISHER
119 void set_input_current_limit(uint16_t milliamps);
This class simplifies creating components that periodically check a state.
This Class provides the methods to read/write bytes from/to an i2c device.
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
void set_charge_target_voltage(uint16_t millivolts)
void set_enable_adc_measure(bool enabled=true)
void set_charge_enabled(bool enabled)
uint16_t input_current_limit_
SY6970Component(bool led_enabled, uint16_t input_current_limit, uint16_t charge_voltage, uint16_t charge_current, uint16_t precharge_current, bool charge_enabled, bool enable_adc, I2CWatchdogTimeout i2c_watchdog_timeout)
I2CWatchdogTimeout i2c_watchdog_timeout_
void set_precharge_current(uint16_t milliamps)
bool write_register_(uint8_t reg, uint8_t value)
uint16_t precharge_current_
void set_led_enabled(bool enabled)
bool reset_i2c_watchdog()
Kick the I2C watchdog (REG03 bit 6); runs on its own interval while enabled. Returns false when not w...
void set_charge_current(uint16_t milliamps)
void set_i2c_watchdog_timeout(I2CWatchdogTimeout timeout)
HUB_PUBLISHER(data, const SY6970Data &) void set_input_current_limit(uint16_t milliamps)
bool read_all_registers_()
bool update_register_(uint8_t reg, uint8_t mask, uint8_t value)
void dump_config() override
uint16_t vbus_voltage_mv(uint8_t reg)
VBUS voltage in mV from REG11; 0 while VBUS_GD (bit 7) shows no input, as the ADC then reads its 2....
@ CHARGE_STATUS_CHARGE_DONE
@ CHARGE_STATUS_PRE_CHARGE
@ CHARGE_STATUS_NOT_CHARGING
@ CHARGE_STATUS_FAST_CHARGE
@ BUS_STATUS_NO_STD_ADAPTER
PROGMEM_STRING_TABLE(I2CWatchdogTimeoutStrings, "Disabled", "40s", "80s", "160s", "Unknown")
bool is_charging(uint8_t charge_status)