13#ifndef PF1550_TYPES_HPP
14#define PF1550_TYPES_HPP
21#include "pf1550_version.h"
38enum class [[nodiscard]]
Error : uint8_t {
73 return "NotInitialized";
75 return "InvalidArgument";
81 return "DeviceIdMismatch";
93 return "ReadOnlyRail";
99 return "ChargerFault";
101 return "VerifyFailed";
105 return "DeviceReset";
128 [[nodiscard]]
constexpr bool ok() const noexcept {
129 return error == Error::Ok;
132 constexpr explicit operator bool() const noexcept {
142 return {v, Error::Ok};
160 [[nodiscard]]
constexpr bool ok() const noexcept {
161 return error == Error::Ok;
164 constexpr explicit operator bool() const noexcept {
363enum class Cold : uint8_t { C0 = 0, CMinus10 = 1 };
365enum class Hot : uint8_t { C60 = 0, C55 = 1 };
367enum class Cool : uint8_t { C15 = 0, C10 = 1 };
369enum class Warm : uint8_t { C45 = 0, C50 = 1 };
374enum class CcAdjust : uint8_t { Pct25 = 0, Pct50 = 1, Pct75 = 2, Pct100 = 3 };
399enum class WakeupDelay : uint8_t { Ms8 = 0, Ms16 = 1, Ms32 = 2, Ms100 = 3 };
408enum class LedFrequency : uint8_t { Hz1 = 0, Hz0p5 = 1, Hz256 = 2, Hz8 = 3 };
427enum class GlobalReset : uint8_t { S4 = 0, S8 = 1, S12 = 2, S16 = 3 };
430enum class Uvdet : uint8_t { Mv2650 = 0, Mv2800 = 1, Mv3000 = 2, Mv3100 = 3 };
557 std::array<uint8_t, kIrqGroups>
masked{0xFF, 0xFF, 0xFF, 0xFF,
558 0xFF, 0xFF, 0xFF, 0xFF};
563 std::array<uint8_t, kIrqGroups>
status{};
585 std::array<uint8_t, kRailCount>
order{};
617 std::array<uint8_t, kIrqGroups>
sense{};
618 std::array<RailReadout, kRailCount>
rails{};
653struct EnumLast<
Rail> {
658struct EnumLast<
Dvs> {
723struct EnumLast<
Cold> {
724 static constexpr Cold kValue = Cold::CMinus10;
728struct EnumLast<
Hot> {
729 static constexpr Hot kValue = Hot::C55;
733struct EnumLast<
Cool> {
734 static constexpr Cool kValue = Cool::C10;
738struct EnumLast<
Warm> {
739 static constexpr Warm kValue = Warm::C50;
744 static constexpr CvAdjust kValue = CvAdjust::Mv200;
749 static constexpr CcAdjust kValue = CcAdjust::Pct100;
759 static constexpr DpmStop kValue = DpmStop::Mv250;
769 static constexpr WakeupDelay kValue = WakeupDelay::Ms100;
784 static constexpr LedFrequency kValue = LedFrequency::Hz8;
794 static constexpr StandbyDelay kValue = StandbyDelay::Cycles3;
804 static constexpr GlobalReset kValue = GlobalReset::S16;
808struct EnumLast<
Uvdet> {
809 static constexpr Uvdet kValue = Uvdet::Mv3100;
814 static constexpr LowSysWarn kValue = LowSysWarn::Mv3900;
830 return PF1550_VERSION_STRING;
834 return PF1550_VERSION_MAJOR;
838 return PF1550_VERSION_MINOR;
842 return PF1550_VERSION_PATCH;
Error
Why a call failed. Every call of the driver returns one of these in its Result.
Definition pf1550_types.hpp:38
Uvdet
VSYS undervoltage detect, rising threshold (UVDET, Table 137).
Definition pf1550_types.hpp:430
Vbus2SysThreshold
VBUS to VSYS comparator threshold (VBUS2SYS_THRSH).
Definition pf1550_types.hpp:402
ThermalRegTemp
Junction temperature where charge current folds back (REGTEMP, Table 162).
Definition pf1550_types.hpp:342
BatteryState
Battery state (BATT_SNS[2:0], Table 155).
Definition pf1550_types.hpp:458
UsbPhyVoltage
USBPHY LDO voltage (USBPHY, Table 165).
Definition pf1550_types.hpp:405
constexpr uint32_t GetDriverVersionMinor() noexcept
Definition pf1550_types.hpp:837
BatfetOc
Battery discharge overcurrent threshold (BATFET_OC, Table 161).
Definition pf1550_types.hpp:355
Debounce
Button debounce (PWRONDBNC, ONKEYDBNC; codes 00 and 01 are equal, ambiguity C41).
Definition pf1550_types.hpp:420
constexpr std::size_t kRailCount
Number of rails.
Definition pf1550_types.hpp:259
ShortDebounce
Short debounce times (VBUS_OV_TDB, VBUS2SYS_TDB; code 0 is reserved and not offered).
Definition pf1550_types.hpp:392
ChargerMode
Charger operating mode (CHG_OPER, Table 156).
Definition pf1550_types.hpp:282
Option
The start-up option of the part (OTP_FLAVOR, Table 87; ordering codes A0 to A9).
Definition pf1550_types.hpp:215
constexpr uint8_t kDefaultAddress
Default 7-bit I2C address (section 9.7.1); OTP selects 0x08 to 0x0F.
Definition pf1550_types.hpp:205
LedMode
LED mode (LED_CFG).
Definition pf1550_types.hpp:411
StandbyDelay
STANDBY pin delay in 32 kHz cycles (STANDBYDLY, Table 135).
Definition pf1550_types.hpp:417
Restart
Charge restart threshold below CHGCV (CHG_RESTART, Table 158).
Definition pf1550_types.hpp:319
CvAdjust
JEITA charge voltage reduction (CV_ADJ, Table 168).
Definition pf1550_types.hpp:372
GlobalReset
ONKEY hold time for a global reset (TGRESET, Table 135).
Definition pf1550_types.hpp:427
Fault
The fault the charger reports, classified from the state and flag registers.
Definition pf1550_types.hpp:469
SwCurrentLimit
Buck current limit, typical (SWx_ILIM, Tables 116, 121, 126).
Definition pf1550_types.hpp:268
Warm
Warm threshold (THM_WARM).
Definition pf1550_types.hpp:369
WatchdogTime
Charger watchdog period (WD_TIME, Table 161; the table prints 0 twice, ambiguity C8).
Definition pf1550_types.hpp:349
AsFoundPolicy
What to do when the charger is found on and unsafe at start-up.
Definition pf1550_types.hpp:436
FastChargeTimer
Fast-charge timer (FCHGTIME, Table 157).
Definition pf1550_types.hpp:289
Dvs
Whether the OTP configured a buck for dynamic voltage scaling (OTP_SWx_DVS_SEL).
Definition pf1550_types.hpp:262
Thermistor
Thermistor behaviour (THM_CNFG, Table 162).
Definition pf1550_types.hpp:334
constexpr std::size_t kIrqSourceCount
Number of interrupt sources.
Definition pf1550_types.hpp:550
Cold
Cold threshold (THM_COLD).
Definition pf1550_types.hpp:363
constexpr uint32_t kWatchdogServiceMaxS
Definition pf1550_types.hpp:210
LowSysWarn
Low system voltage warning, rising threshold (LOW_SYS_WARN, Table 137).
Definition pf1550_types.hpp:433
DvsSpeed
DVS slew rate (SWx_DVSSPEED).
Definition pf1550_types.hpp:276
constexpr uint32_t GetDriverVersionMajor() noexcept
Definition pf1550_types.hpp:833
Rail
The power rails the driver configures.
Definition pf1550_types.hpp:249
constexpr const char * ToString(Error error) noexcept
The name of an error, for logs.
Definition pf1550_types.hpp:68
LedFrequency
LED PWM frequency (LED_FREQ, Table 172).
Definition pf1550_types.hpp:408
CcAdjust
JEITA charge current as a share of IFC (CC_ADJ, Table 168).
Definition pf1550_types.hpp:374
constexpr uint32_t kDvsWaitMaxUs
The longest the driver waits for one DVS step sequence, in microseconds (64 steps x 4 us).
Definition pf1550_types.hpp:207
constexpr uint32_t GetDriverVersionPatch() noexcept
Definition pf1550_types.hpp:841
IrqGroup
Interrupt groups, one status/mask/sense register triple each.
Definition pf1550_types.hpp:504
ChargerState
Charger state (CHG_SNS[3:0], Table 154).
Definition pf1550_types.hpp:442
EocTimer
End-of-charge timer (EOCTIME, Table 157): 0 is a 16 s debounce, then 10 min steps.
Definition pf1550_types.hpp:301
SystemMin
Minimum system voltage (VSYSMIN, Table 160).
Definition pf1550_types.hpp:327
PowerState
STATE_INFO decoded (Table 146).
Definition pf1550_types.hpp:239
constexpr Microvolts FromMillivolts(uint32_t mv) noexcept
Microvolts from millivolts.
Definition pf1550_types.hpp:200
Hot
Hot threshold (THM_HOT).
Definition pf1550_types.hpp:365
WakeupDelay
System wake-up delay (SYS_WKUP_DLY, Table 166).
Definition pf1550_types.hpp:399
DpmVoltage
VBUS input regulation (DPM) voltage (VBUS_DPM_REG, Table 164): 3.9 V + 100 mV x code.
Definition pf1550_types.hpp:377
IrqSource
Every interrupt source of Tables 90 to 110 and 150 (31 sources).
Definition pf1550_types.hpp:516
LogLevel
Severity passed to the optional Log() hook.
Definition pf1550_types.hpp:183
constexpr std::size_t kIrqGroups
Number of interrupt groups.
Definition pf1550_types.hpp:212
Cool
Cool threshold (THM_COOL).
Definition pf1550_types.hpp:367
PrechargeTimer
Precharge timer (TPRECHG, Table 157).
Definition pf1550_types.hpp:313
DpmStop
DPM panic stop threshold (VIN_DPM_STOP).
Definition pf1550_types.hpp:389
constexpr const char * GetDriverVersion() noexcept
Definition pf1550_types.hpp:829
@ NoDevice
Nothing acknowledged the address: no chip, or it is unpowered.
@ OutOfLimits
A valid value outside the caller's Limits; nothing was sent.
@ DeviceIdMismatch
DEVICE_ID did not read 0x7C: wrong chip, no chip or a wiring fault.
@ ReadOnlyRail
SW3, or SW1 or SW2 not declared in DVS mode: its voltage is not written.
@ Crc
Not returned by this driver (I2C transfers carry no CRC).
@ Bus
A port hook returned false.
@ VerifyFailed
A register read back differently from what was just written.
@ ChargerFault
The charger reports a fault state; charging is not enabled.
@ DeviceFault
Not returned by this driver (faults are reported as ChargerFault).
@ NotInitialized
EnsureInitialized() has not succeeded yet.
@ Unsupported
The optional port hook this call needs is absent.
@ Timeout
A wait for the chip (a DVS step) did not end in the allowed time.
@ Unsafe
A safety downgrade without its acknowledgement; nothing was sent.
@ Busy
Not returned by this driver (the chip has no busy state).
@ Refused
A precondition of a dangerous call is not met (state, VBUS, ONKEY).
@ C95
95 degC (reset value).
@ CannotChargePastPrecharge
Timer fault in precharge.
@ BelowPrecharge
VBATT below VPRECHG.LB.
@ Unknown
A reserved code.
@ NotDetected
No battery with a valid input after wake-up.
@ Overvoltage
Battery overvoltage with a valid input.
@ AbovePrecharge
Above the precharge threshold.
@ NoValidVbus
No valid input.
@ Disabled
No protection: needs the acknowledgement allow_batfet_oc_off.
@ A3p2
3.2 A typical (reset value).
@ Ms31
31.25 ms falling, 31.25 ms rising (register code 0).
@ Ms750
750 ms falling (register code 3).
@ Ms125
125 ms falling (register code 2).
@ Ms1
1 ms (register code 2).
@ Us100
100 us (register code 1).
@ Ms10
10 ms (register code 3).
@ LinearOnly
Linear regulator on, no battery charging (reset value).
@ Off
Charger and linear regulator off.
@ Unknown
A flavour byte the data sheet does not list (ambiguity C10).
@ A0
Not programmed: internal validation only; nothing is assumed about it.
@ A8
Option A8 (edge-sensitive PWRON).
@ FlashWhileCharging
Flashing while charging, on on a fault, off when done.
@ OnWhileCharging
On while charging, flashing on a fault, off when done.
@ Mv150
150 mV (reset value).
@ BatteryMissing
BATT_SNS 6.
@ BatteryOvercurrent
BATTOC_SNS.
@ UnknownState
A reserved CHG_SNS or BATT_SNS code.
@ WatchdogExpired
WDT_SNS.
@ Report
Return the error and write nothing (default).
@ MakeSafe
Write CHG_OPER = linear only, then verify.
@ Disabled
No timer: needs the acknowledgement allow_untimed_charge.
@ Hours4
4 hours (reset value).
@ Enabled
DVS: voltage is 0.6 V + 12.5 mV x code.
@ Disabled
Non-DVS: the voltage registers are read only and hold the fixed table.
@ Jeita1
Current and voltage reduced in cool and warm.
@ Jeita2
Current reduced in cool and warm.
@ Suspend
Charging stops outside cold and hot (reset value).
@ Ignore
Not in control: needs the acknowledgement battery_has_own_ntc_protection.
@ Ldo3
LDO3, 300 mA, load switch capable.
@ VrefDdr
DDR reference, 10 mA, fixed voltage.
@ Sw3
Buck 3, 1.0 A, voltage read only.
@ Ldo1
LDO1, 300 mA, load switch capable.
@ SwHighSide
SW_INT_STAT1.
@ ThermalShutdown
Junction above TSHDN.
@ Precharge
Battery below VPRECHG.LB.
@ ThermistorSuspend
Battery temperature outside the window.
@ Unknown
A reserved code: reported as a fault, never as charging.
@ BatteryOvervoltage
Battery overvoltage.
@ FastChargeCv
Constant voltage.
@ EndOfCharge
Current below IEOC, tEOC running.
@ TimerFault
Timer fault: only off then on exits it.
@ FastChargeCc
Constant current.
@ Min10
10 min (reset value).
@ Mv4300
4.3 V (recommended, section 8.1).
@ Mv3500
3.5 V (reset value).
@ Mv3900
3.9 V (reset value).
@ Sw3LowSideLimit
SW3_LS_I.
@ Sw1LowSideLimit
SW1_LS_I.
@ Sw2LowSideLimit
SW2_LS_I.
@ Sw1DvsDone
SW1_DVS_DONE_I.
@ Sw1HighSideLimit
SW1_HS_I.
@ Sw2DvsDone
SW2_DVS_DONE_I.
@ Sw3HighSideLimit
SW3_HS_I.
@ LowSysWarning
LOW_SYS_WARN_I.
@ SysOvervoltage
SYS_OVLO_I.
@ Sw2HighSideLimit
SW2_HS_I.
@ Warning
Something unexpected that the driver recovered from.
@ Debug
Detail for bring-up.
The PF1550 driver: everything it declares lives here; internals in detail.
Definition pf1550.hpp:39
@ None
The last transfer succeeded.
@ Bus
Arbitration lost, a stuck line or a timeout.
Compile-time helpers of the PF1550 driver: typed integer literals, exact hook matching,...
Which category-summary bits are set in INT_CATEGORY (Table 89).
Definition pf1550_types.hpp:570
bool ldo
LDO_INT.
Definition pf1550_types.hpp:575
bool sw1
SW1_INT.
Definition pf1550_types.hpp:572
bool charger
CHG_INT.
Definition pf1550_types.hpp:571
bool misc
MISC_INT.
Definition pf1550_types.hpp:578
bool sw3
SW3_INT.
Definition pf1550_types.hpp:574
bool temp
TEMP_INT.
Definition pf1550_types.hpp:577
bool sw2
SW2_INT.
Definition pf1550_types.hpp:573
bool onkey
ONKEY_INT.
Definition pf1550_types.hpp:576
Charger registers as found at start-up (the as-found check).
Definition pf1550_types.hpp:599
BatfetOc batfet_oc
BATFET_OC.
Definition pf1550_types.hpp:607
uint32_t charge_voltage_mv
CHGCV decoded.
Definition pf1550_types.hpp:602
uint8_t chg_oper
CHG_OPER raw.
Definition pf1550_types.hpp:600
Thermistor thermistor
THM_CNFG.
Definition pf1550_types.hpp:606
bool safe
Within limits and acknowledged.
Definition pf1550_types.hpp:609
uint32_t input_limit_ma
VBUS_LIN_ILIM decoded (0 for a reserved code).
Definition pf1550_types.hpp:604
ChargerMode mode
Decoded mode.
Definition pf1550_types.hpp:601
uint32_t charge_current_ma
CHG_CC decoded (0 for a reserved code).
Definition pf1550_types.hpp:603
bool disbatfet
DISBATFET: the battery path is off.
Definition pf1550_types.hpp:608
FastChargeTimer fast_timer
FCHGTIME.
Definition pf1550_types.hpp:605
The charger status of one ReadChargerStatus() pass (separate reads, not atomic).
Definition pf1550_types.hpp:491
bool consistent
CHG_SNS read twice with equal values.
Definition pf1550_types.hpp:500
Fault fault
The classified fault.
Definition pf1550_types.hpp:499
ChargerState state
CHG_SNS[3:0].
Definition pf1550_types.hpp:492
BatteryState battery
BATT_SNS[2:0].
Definition pf1550_types.hpp:493
bool thermal_regulation
TREG_SNS: charge current is folded back.
Definition pf1550_types.hpp:496
VbusFlags vbus
VBUS_SNS.
Definition pf1550_types.hpp:498
bool battery_overcurrent
BATTOC_SNS.
Definition pf1550_types.hpp:497
bool thermistor_outside
THM_SNS.
Definition pf1550_types.hpp:495
bool watchdog_expired
WDT_SNS.
Definition pf1550_types.hpp:494
Token: the caller confirms that EnterCoreOff() turns the PMIC core off.
Definition pf1550_types.hpp:635
Interrupt events returned by ServiceInterrupts(), one status byte per group.
Definition pf1550_types.hpp:562
uint8_t categories
INT_CATEGORY as read first.
Definition pf1550_types.hpp:564
uint8_t passes
Passes made (at most 3).
Definition pf1550_types.hpp:565
std::array< uint8_t, kIrqGroups > status
The status bytes as read, before any clear.
Definition pf1550_types.hpp:563
bool fault_class
A fault-class source is set (see HasFault()).
Definition pf1550_types.hpp:566
Interrupt masks, one byte per group; a set bit masks the source. The default masks every source,...
Definition pf1550_types.hpp:556
std::array< uint8_t, kIrqGroups > masked
Per group.
Definition pf1550_types.hpp:557
Token: the caller confirms that a load switch has no current limit and cannot go back,...
Definition pf1550_types.hpp:641
uint32_t input_mv
The input rail voltage of the LDO, millivolts.
Definition pf1550_types.hpp:642
A voltage in microvolts, so that grids such as 12.5 mV steps stay exact.
Definition pf1550_types.hpp:191
uint32_t value
The voltage in microvolts; 0 means "leave as it is" in a configuration.
Definition pf1550_types.hpp:192
The registers of the power-down sequence (Tables 139 to 145).
Definition pf1550_types.hpp:582
std::array< uint8_t, kRailCount > order
Definition pf1550_types.hpp:585
One rail as the chip holds it.
Definition pf1550_types.hpp:589
bool enabled_sleep
OMODE.
Definition pf1550_types.hpp:592
bool enabled_run
EN.
Definition pf1550_types.hpp:590
Microvolts volt
The run-mode voltage; 0 for VREFDDR or a non-DVS buck of unknown mode.
Definition pf1550_types.hpp:595
bool enabled_standby
STBY_EN.
Definition pf1550_types.hpp:591
bool load_switch
LS_EN (LDO1 and LDO3).
Definition pf1550_types.hpp:594
bool low_power
LPWR.
Definition pf1550_types.hpp:593
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition pf1550_types.hpp:177
constexpr bool ok() const noexcept
Definition pf1550_types.hpp:160
static constexpr Result Success() noexcept
Definition pf1550_types.hpp:169
The value of a call, or why there is none.
Definition pf1550_types.hpp:123
static constexpr Result Failure(Error e) noexcept
A failed result.
Definition pf1550_types.hpp:149
static constexpr Result Success(T v) noexcept
A successful result.
Definition pf1550_types.hpp:141
constexpr bool ok() const noexcept
Definition pf1550_types.hpp:128
Result of SelfCheck(): what is wrong, if anything.
Definition pf1550_types.hpp:624
bool rails_as_configured
Every configured rail reads enabled as configured.
Definition pf1550_types.hpp:627
bool no_latched_fault
No fault-class interrupt status and the charger reports none.
Definition pf1550_types.hpp:628
bool input_limit_ok
VBUS_LIN_ILIM is valid, within Limits and as configured.
Definition pf1550_types.hpp:629
bool state_run
STATE_INFO is Run.
Definition pf1550_types.hpp:626
bool identity_ok
DEVICE_ID read 0x7C.
Definition pf1550_types.hpp:625
Token: the caller confirms that EnterShip() cuts all supplies, VSNVS included.
Definition pf1550_types.hpp:633
A read-only view of the chip for diagnostics (ReadSnapshot()).
Definition pf1550_types.hpp:613
PowerState state
STATE_INFO.
Definition pf1550_types.hpp:615
std::array< uint8_t, kIrqGroups > sense
SENSE registers (live, not latched).
Definition pf1550_types.hpp:617
PowerDownSequence power_down
PWRDN_SEQ registers.
Definition pf1550_types.hpp:619
std::array< RailReadout, kRailCount > rails
The rails.
Definition pf1550_types.hpp:618
uint8_t por_delay_code
PWRCTRL0.POR_DLY (RESETBMCU delay).
Definition pf1550_types.hpp:620
ChargerStatus charger
Charger status.
Definition pf1550_types.hpp:616
VariantInfo variant
Identity.
Definition pf1550_types.hpp:614
What ReadVariant() reports.
Definition pf1550_types.hpp:230
uint8_t flavor_raw
OTP_FLAVOR as read.
Definition pf1550_types.hpp:232
uint8_t device_id
DEVICE_ID (0x7C).
Definition pf1550_types.hpp:231
uint8_t i2c_slave_addr_code
I2C_ADDR[2:0]: the address is 0x08 plus this.
Definition pf1550_types.hpp:235
uint8_t silicon_rev_raw
SILICON_REV as read; no decision is made on it (C22).
Definition pf1550_types.hpp:234
Option option
The named option for listed values.
Definition pf1550_types.hpp:233
VBUS flags of VBUS_SNS (Table 153).
Definition pf1550_types.hpp:482
bool dpm
VBUS_DPM_SNS.
Definition pf1550_types.hpp:487
bool in2sys
VBUS_IN2SYS_SNS.
Definition pf1550_types.hpp:486
bool ovlo
VBUS_OVLO_SNS.
Definition pf1550_types.hpp:484
bool uvlo
VBUS_UVLO_SNS.
Definition pf1550_types.hpp:485
bool valid
VBUS_VALID.
Definition pf1550_types.hpp:483