PF1550 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Enumerations | Functions | Variables
pf1550_types.hpp File Reference

Public types of the PF1550 driver: errors, Result<T>, enumerations, units, status and interrupt types. More...

#include <array>
#include <cstddef>
#include <cstdint>
#include "pf1550_detail.hpp"
#include "pf1550_version.h"

Go to the source code of this file.

Classes

struct  pf1550::Result< T >
 The value of a call, or why there is none. More...
 
struct  pf1550::Result< void >
 The result of a call that returns no value. More...
 
struct  pf1550::Microvolts
 A voltage in microvolts, so that grids such as 12.5 mV steps stay exact. More...
 
struct  pf1550::VariantInfo
 What ReadVariant() reports. More...
 
struct  pf1550::VbusFlags
 VBUS flags of VBUS_SNS (Table 153). More...
 
struct  pf1550::ChargerStatus
 The charger status of one ReadChargerStatus() pass (separate reads, not atomic). More...
 
struct  pf1550::IrqMask
 Interrupt masks, one byte per group; a set bit masks the source. The default masks every source, as the chip does after power-up (section 9.4). More...
 
struct  pf1550::InterruptEvents
 Interrupt events returned by ServiceInterrupts(), one status byte per group. More...
 
struct  pf1550::Categories
 Which category-summary bits are set in INT_CATEGORY (Table 89). More...
 
struct  pf1550::PowerDownSequence
 The registers of the power-down sequence (Tables 139 to 145). More...
 
struct  pf1550::RailReadout
 One rail as the chip holds it. More...
 
struct  pf1550::ChargerAsFound
 Charger registers as found at start-up (the as-found check). More...
 
struct  pf1550::Snapshot
 A read-only view of the chip for diagnostics (ReadSnapshot()). More...
 
struct  pf1550::SelfCheckReport
 Result of SelfCheck(): what is wrong, if anything. More...
 
struct  pf1550::ShipConfirm
 Token: the caller confirms that EnterShip() cuts all supplies, VSNVS included. More...
 
struct  pf1550::CoreOffConfirm
 Token: the caller confirms that EnterCoreOff() turns the PMIC core off. More...
 
struct  pf1550::LoadSwitchConfirm
 Token: the caller confirms that a load switch has no current limit and cannot go back, and states the voltage of the LDO's input rail. The call refuses when that voltage is outside the rail's Limits window: in switch mode the output is the input voltage (section 7.2.6). More...
 

Namespaces

namespace  pf1550
 The PF1550 driver: everything it declares lives here; internals in detail.
 

Enumerations

enum class  pf1550::Error : uint8_t {
  pf1550::Error::Ok = 0 , pf1550::Error::NotInitialized = 1 , pf1550::Error::InvalidArgument = 2 , pf1550::Error::Bus = 3 ,
  pf1550::Error::Timeout = 4 , pf1550::Error::DeviceIdMismatch = 5 , pf1550::Error::Crc = 6 , pf1550::Error::Busy = 7 ,
  pf1550::Error::DeviceFault = 8 , pf1550::Error::Unsupported = 9 , pf1550::Error::OutOfLimits = 16 , pf1550::Error::ReadOnlyRail = 17 ,
  pf1550::Error::Unsafe = 18 , pf1550::Error::Refused = 19 , pf1550::Error::ChargerFault = 20 , pf1550::Error::VerifyFailed = 21 ,
  pf1550::Error::NoDevice = 22 , pf1550::Error::DeviceReset = 23
}
 Why a call failed. Every call of the driver returns one of these in its Result. More...
 
enum class  pf1550::LogLevel : uint8_t { pf1550::LogLevel::Error = 0 , pf1550::LogLevel::Warning , pf1550::LogLevel::Info , pf1550::LogLevel::Debug }
 Severity passed to the optional Log() hook. More...
 
enum class  pf1550::Option : uint8_t {
  pf1550::Option::A0 = 0 , pf1550::Option::A1 = 1 , pf1550::Option::A2 = 2 , pf1550::Option::A3 = 3 ,
  pf1550::Option::A4 = 4 , pf1550::Option::A5 = 5 , pf1550::Option::A6 = 6 , pf1550::Option::A7 = 7 ,
  pf1550::Option::A8 = 8 , pf1550::Option::A9 = 9 , pf1550::Option::Unknown = 10
}
 The start-up option of the part (OTP_FLAVOR, Table 87; ordering codes A0 to A9). More...
 
enum class  pf1550::PowerState : uint8_t {
  pf1550::PowerState::Wait = 0 , pf1550::PowerState::Run = 1 , pf1550::PowerState::Standby = 2 , pf1550::PowerState::Sleep = 3 ,
  pf1550::PowerState::RegsDisable = 4 , pf1550::PowerState::Unknown = 5
}
 STATE_INFO decoded (Table 146). More...
 
enum class  pf1550::Rail : uint8_t {
  pf1550::Rail::Sw1 = 0 , pf1550::Rail::Sw2 = 1 , pf1550::Rail::Sw3 = 2 , pf1550::Rail::Ldo1 = 3 ,
  pf1550::Rail::Ldo2 = 4 , pf1550::Rail::Ldo3 = 5 , pf1550::Rail::VrefDdr = 6
}
 The power rails the driver configures. More...
 
enum class  pf1550::Dvs : uint8_t { pf1550::Dvs::Disabled = 0 , pf1550::Dvs::Enabled = 1 }
 Whether the OTP configured a buck for dynamic voltage scaling (OTP_SWx_DVS_SEL). More...
 
enum class  pf1550::SwCurrentLimit : uint8_t { pf1550::SwCurrentLimit::A1p0 = 0 , pf1550::SwCurrentLimit::A1p2 = 1 , pf1550::SwCurrentLimit::A1p5 = 2 , pf1550::SwCurrentLimit::A2p0 = 3 }
 Buck current limit, typical (SWx_ILIM, Tables 116, 121, 126). More...
 
enum class  pf1550::DvsSpeed : uint8_t { pf1550::DvsSpeed::Us2 = 0 , pf1550::DvsSpeed::Us4 = 1 }
 DVS slew rate (SWx_DVSSPEED). More...
 
enum class  pf1550::ChargerMode : uint8_t { pf1550::ChargerMode::Off = 0 , pf1550::ChargerMode::LinearOnly = 1 , pf1550::ChargerMode::Charge = 2 }
 Charger operating mode (CHG_OPER, Table 156). More...
 
enum class  pf1550::FastChargeTimer : uint8_t {
  pf1550::FastChargeTimer::Disabled = 0 , pf1550::FastChargeTimer::Hours2 = 1 , pf1550::FastChargeTimer::Hours4 = 2 , pf1550::FastChargeTimer::Hours6 = 3 ,
  pf1550::FastChargeTimer::Hours8 = 4 , pf1550::FastChargeTimer::Hours10 = 5 , pf1550::FastChargeTimer::Hours12 = 6 , pf1550::FastChargeTimer::Hours14 = 7
}
 Fast-charge timer (FCHGTIME, Table 157). More...
 
enum class  pf1550::EocTimer : uint8_t {
  pf1550::EocTimer::Debounce16s = 0 , pf1550::EocTimer::Min10 = 1 , pf1550::EocTimer::Min20 = 2 , pf1550::EocTimer::Min30 = 3 ,
  pf1550::EocTimer::Min40 = 4 , pf1550::EocTimer::Min50 = 5 , pf1550::EocTimer::Min60 = 6 , pf1550::EocTimer::Min70 = 7
}
 End-of-charge timer (EOCTIME, Table 157): 0 is a 16 s debounce, then 10 min steps. More...
 
enum class  pf1550::PrechargeTimer : uint8_t { pf1550::PrechargeTimer::Min30 = 0 , pf1550::PrechargeTimer::Min45 = 1 }
 Precharge timer (TPRECHG, Table 157). More...
 
enum class  pf1550::Restart : uint8_t { pf1550::Restart::Mv100 = 0 , pf1550::Restart::Mv150 = 1 , pf1550::Restart::Mv200 = 2 , pf1550::Restart::Disabled = 3 }
 Charge restart threshold below CHGCV (CHG_RESTART, Table 158). More...
 
enum class  pf1550::SystemMin : uint8_t { pf1550::SystemMin::Mv3500 = 0 , pf1550::SystemMin::Mv3700 = 1 , pf1550::SystemMin::Mv4300 = 2 }
 Minimum system voltage (VSYSMIN, Table 160). More...
 
enum class  pf1550::Thermistor : uint8_t { pf1550::Thermistor::Ignore = 0 , pf1550::Thermistor::Suspend = 1 , pf1550::Thermistor::Jeita1 = 2 , pf1550::Thermistor::Jeita2 = 3 }
 Thermistor behaviour (THM_CNFG, Table 162). More...
 
enum class  pf1550::ThermalRegTemp : uint8_t { pf1550::ThermalRegTemp::C80 = 0 , pf1550::ThermalRegTemp::C95 = 1 , pf1550::ThermalRegTemp::C110 = 2 }
 Junction temperature where charge current folds back (REGTEMP, Table 162). More...
 
enum class  pf1550::WatchdogTime : uint8_t { pf1550::WatchdogTime::S80 = 0 , pf1550::WatchdogTime::S32 = 1 }
 Charger watchdog period (WD_TIME, Table 161; the table prints 0 twice, ambiguity C8). More...
 
enum class  pf1550::BatfetOc : uint8_t { pf1550::BatfetOc::Disabled = 0 , pf1550::BatfetOc::A2p2 = 1 , pf1550::BatfetOc::A2p8 = 2 , pf1550::BatfetOc::A3p2 = 3 }
 Battery discharge overcurrent threshold (BATFET_OC, Table 161). More...
 
enum class  pf1550::Cold : uint8_t { C0 = 0 , CMinus10 = 1 }
 Cold threshold (THM_COLD).
 
enum class  pf1550::Hot : uint8_t { C60 = 0 , C55 = 1 }
 Hot threshold (THM_HOT).
 
enum class  pf1550::Cool : uint8_t { C15 = 0 , C10 = 1 }
 Cool threshold (THM_COOL).
 
enum class  pf1550::Warm : uint8_t { C45 = 0 , C50 = 1 }
 Warm threshold (THM_WARM).
 
enum class  pf1550::CvAdjust : uint8_t { Mv60 = 0 , Mv100 = 1 , Mv160 = 2 , Mv200 = 3 }
 JEITA charge voltage reduction (CV_ADJ, Table 168).
 
enum class  pf1550::CcAdjust : uint8_t { Pct25 = 0 , Pct50 = 1 , Pct75 = 2 , Pct100 = 3 }
 JEITA charge current as a share of IFC (CC_ADJ, Table 168).
 
enum class  pf1550::DpmVoltage : uint8_t {
  pf1550::DpmVoltage::Mv3900 = 0 , pf1550::DpmVoltage::Mv4000 = 1 , pf1550::DpmVoltage::Mv4100 = 2 , pf1550::DpmVoltage::Mv4200 = 3 ,
  pf1550::DpmVoltage::Mv4300 = 4 , pf1550::DpmVoltage::Mv4400 = 5 , pf1550::DpmVoltage::Mv4500 = 6 , pf1550::DpmVoltage::Mv4600 = 7
}
 VBUS input regulation (DPM) voltage (VBUS_DPM_REG, Table 164): 3.9 V + 100 mV x code. More...
 
enum class  pf1550::DpmStop : uint8_t { Mv200 = 0 , Mv250 = 1 }
 DPM panic stop threshold (VIN_DPM_STOP).
 
enum class  pf1550::ShortDebounce : uint8_t { pf1550::ShortDebounce::Us100 = 0 , pf1550::ShortDebounce::Ms1 = 1 , pf1550::ShortDebounce::Ms10 = 2 }
 Short debounce times (VBUS_OV_TDB, VBUS2SYS_TDB; code 0 is reserved and not offered). More...
 
enum class  pf1550::WakeupDelay : uint8_t { Ms8 = 0 , Ms16 = 1 , Ms32 = 2 , Ms100 = 3 }
 System wake-up delay (SYS_WKUP_DLY, Table 166).
 
enum class  pf1550::Vbus2SysThreshold : uint8_t { Mv50 = 0 , Mv175 = 1 }
 VBUS to VSYS comparator threshold (VBUS2SYS_THRSH).
 
enum class  pf1550::UsbPhyVoltage : uint8_t { V3p3 = 0 , V4p9 = 1 }
 USBPHY LDO voltage (USBPHY, Table 165).
 
enum class  pf1550::LedFrequency : uint8_t { Hz1 = 0 , Hz0p5 = 1 , Hz256 = 2 , Hz8 = 3 }
 LED PWM frequency (LED_FREQ, Table 172).
 
enum class  pf1550::LedMode : uint8_t { pf1550::LedMode::OnWhileCharging = 0 , pf1550::LedMode::FlashWhileCharging = 1 }
 LED mode (LED_CFG). More...
 
enum class  pf1550::StandbyDelay : uint8_t { None = 0 , Cycles1 = 1 , Cycles2 = 2 , Cycles3 = 3 }
 STANDBY pin delay in 32 kHz cycles (STANDBYDLY, Table 135).
 
enum class  pf1550::Debounce : uint8_t { pf1550::Debounce::Ms31 = 0 , pf1550::Debounce::Ms125 = 1 , pf1550::Debounce::Ms750 = 2 }
 Button debounce (PWRONDBNC, ONKEYDBNC; codes 00 and 01 are equal, ambiguity C41). More...
 
enum class  pf1550::GlobalReset : uint8_t { S4 = 0 , S8 = 1 , S12 = 2 , S16 = 3 }
 ONKEY hold time for a global reset (TGRESET, Table 135).
 
enum class  pf1550::Uvdet : uint8_t { Mv2650 = 0 , Mv2800 = 1 , Mv3000 = 2 , Mv3100 = 3 }
 VSYS undervoltage detect, rising threshold (UVDET, Table 137).
 
enum class  pf1550::LowSysWarn : uint8_t { Mv3300 = 0 , Mv3500 = 1 , Mv3700 = 2 , Mv3900 = 3 }
 Low system voltage warning, rising threshold (LOW_SYS_WARN, Table 137).
 
enum class  pf1550::AsFoundPolicy : uint8_t { pf1550::AsFoundPolicy::Report = 0 , pf1550::AsFoundPolicy::MakeSafe = 1 }
 What to do when the charger is found on and unsafe at start-up. More...
 
enum class  pf1550::ChargerState : uint8_t {
  pf1550::ChargerState::Precharge = 0 , pf1550::ChargerState::FastChargeCc = 1 , pf1550::ChargerState::FastChargeCv = 2 , pf1550::ChargerState::EndOfCharge = 3 ,
  pf1550::ChargerState::Done = 4 , pf1550::ChargerState::TimerFault = 6 , pf1550::ChargerState::ThermistorSuspend = 7 , pf1550::ChargerState::Off = 8 ,
  pf1550::ChargerState::BatteryOvervoltage = 9 , pf1550::ChargerState::ThermalShutdown = 10 , pf1550::ChargerState::LinearOnly = 12 , pf1550::ChargerState::Unknown = 255
}
 Charger state (CHG_SNS[3:0], Table 154). More...
 
enum class  pf1550::BatteryState : uint8_t {
  pf1550::BatteryState::NoValidVbus = 0 , pf1550::BatteryState::BelowPrecharge = 1 , pf1550::BatteryState::CannotChargePastPrecharge = 2 , pf1550::BatteryState::AbovePrecharge = 4 ,
  pf1550::BatteryState::Overvoltage = 5 , pf1550::BatteryState::NotDetected = 6 , pf1550::BatteryState::Unknown = 255
}
 Battery state (BATT_SNS[2:0], Table 155). More...
 
enum class  pf1550::Fault : uint8_t {
  pf1550::Fault::None = 0 , pf1550::Fault::TimerFault = 1 , pf1550::Fault::ThermistorSuspend = 2 , pf1550::Fault::ThermalShutdown = 3 ,
  pf1550::Fault::BatteryOvervoltage = 4 , pf1550::Fault::BatteryOvercurrent = 5 , pf1550::Fault::WatchdogExpired = 6 , pf1550::Fault::BatteryMissing = 7 ,
  pf1550::Fault::UnknownState = 8
}
 The fault the charger reports, classified from the state and flag registers. More...
 
enum class  pf1550::IrqGroup : uint8_t {
  pf1550::IrqGroup::Charger = 0 , pf1550::IrqGroup::SwLowSide = 1 , pf1550::IrqGroup::SwHighSide = 2 , pf1550::IrqGroup::SwDvs = 3 ,
  pf1550::IrqGroup::Ldo = 4 , pf1550::IrqGroup::Temp = 5 , pf1550::IrqGroup::Onkey = 6 , pf1550::IrqGroup::Misc = 7
}
 Interrupt groups, one status/mask/sense register triple each. More...
 
enum class  pf1550::IrqSource : uint8_t {
  pf1550::IrqSource::ChgSupplement = 0 , pf1550::IrqSource::ChgBat2Soc , pf1550::IrqSource::ChgBattery , pf1550::IrqSource::ChgCharger ,
  pf1550::IrqSource::ChgVbus , pf1550::IrqSource::ChgVbusDpm , pf1550::IrqSource::ChgThermistor , pf1550::IrqSource::Sw1LowSideLimit ,
  pf1550::IrqSource::Sw2LowSideLimit , pf1550::IrqSource::Sw3LowSideLimit , pf1550::IrqSource::Sw1HighSideLimit , pf1550::IrqSource::Sw2HighSideLimit ,
  pf1550::IrqSource::Sw3HighSideLimit , pf1550::IrqSource::Sw1DvsDone , pf1550::IrqSource::Sw2DvsDone , pf1550::IrqSource::Ldo1Fault ,
  pf1550::IrqSource::Ldo2Fault , pf1550::IrqSource::Ldo3Fault , pf1550::IrqSource::Temp110 , pf1550::IrqSource::Temp125 ,
  pf1550::IrqSource::OnkeyPush , pf1550::IrqSource::Onkey1s , pf1550::IrqSource::Onkey2s , pf1550::IrqSource::Onkey3s ,
  pf1550::IrqSource::Onkey4s , pf1550::IrqSource::Onkey8s , pf1550::IrqSource::PowerUp , pf1550::IrqSource::PowerDown ,
  pf1550::IrqSource::PwronChange , pf1550::IrqSource::LowSysWarning , pf1550::IrqSource::SysOvervoltage
}
 Every interrupt source of Tables 90 to 110 and 150 (31 sources). More...
 

Functions

constexpr const char * pf1550::ToString (Error error) noexcept
 The name of an error, for logs.
 
constexpr Microvolts pf1550::FromMillivolts (uint32_t mv) noexcept
 Microvolts from millivolts.
 
constexpr const char * pf1550::GetDriverVersion () noexcept
 
constexpr uint32_t pf1550::GetDriverVersionMajor () noexcept
 
constexpr uint32_t pf1550::GetDriverVersionMinor () noexcept
 
constexpr uint32_t pf1550::GetDriverVersionPatch () noexcept
 

Variables

constexpr uint8_t pf1550::kDefaultAddress = 0x08
 Default 7-bit I2C address (section 9.7.1); OTP selects 0x08 to 0x0F.
 
constexpr uint32_t pf1550::kDvsWaitMaxUs = 256
 The longest the driver waits for one DVS step sequence, in microseconds (64 steps x 4 us).
 
constexpr uint32_t pf1550::kWatchdogServiceMaxS = 16
 
constexpr std::size_t pf1550::kIrqGroups = 8
 Number of interrupt groups.
 
constexpr std::size_t pf1550::kRailCount = 7
 Number of rails.
 
constexpr std::size_t pf1550::kIrqSourceCount = 31
 Number of interrupt sources.
 

Detailed Description

Public types of the PF1550 driver: errors, Result<T>, enumerations, units, status and interrupt types.

Everything here is plain data with no platform dependency. The configuration lives in pf1550_config.hpp, the register codecs in pf1550_codec.hpp. Enumerator values equal the register codes of the data sheet tables (section 12) wherever the table is contiguous, and every enumeration that a caller can hand in has an EnumLast specialisation for IsEnumerator().