38#include "pf1550_version.h"
61template <
typename BusType>
152 bool ApplyProfile(std::span<const profiles::RegisterWrite> profile) noexcept;
180 bool SetUsbRails(
bool vbus_en,
bool otg_en) noexcept;
200 bool ReadOtpByte(uint8_t otp_addr, uint8_t& value) noexcept;
317 error_flags_ &=
static_cast<uint16_t
>(~mask);
333 if (sw_index == 1U || sw_index == 2U) {
334 sw_dvs_enabled_[sw_index - 1U] = enabled;
342 bool writeReg8(uint8_t reg, uint8_t value)
noexcept;
343 bool readReg8(uint8_t reg, uint8_t& value)
noexcept;
344 void setError(
Error e)
noexcept { error_flags_ |=
static_cast<uint16_t
>(e); }
347 bool fillRailSnapshot(DiagnosticSnapshot& snap)
noexcept;
348 bool fillFaultSnapshot(DiagnosticSnapshot& snap)
noexcept;
353 uint16_t error_flags_;
354 bool sw_dvs_enabled_[2]{
false,
false};
359#include "../src/pf1550.ipp"
CRTP-based PF1550 PMIC driver.
Definition pf1550.hpp:62
bool SetPowerMode(PowerMode mode) noexcept
Drive the STANDBY strap pin to RUN or STANDBY.
Definition pf1550.ipp:120
bool ReadOtpByte(uint8_t otp_addr, uint8_t &value) noexcept
Read a single OTP byte via FMRADDR/FMRDATA indirection.
Definition pf1550.ipp:181
bool ReadDeviceId(uint8_t &id) noexcept
Read DEVICE_ID (Reg 0x00).
Definition pf1550.ipp:59
bool ReadRegister(Register reg, uint8_t &value) noexcept
Read any PF1550 register by enumerated address.
Definition pf1550.ipp:81
bool ReadPmicStatus(uint8_t &status) noexcept
Read STATE_INFO (Reg 0x67) and return the raw byte.
Definition pf1550.ipp:151
bool RefreshStatusSnapshot(DiagnosticSnapshot &snap) noexcept
Refresh only the status part of a snapshot (≈14 register reads).
Definition pf1550.ipp:465
bool ReadPmicState(PmicState &state) noexcept
Decoded variant of ReadPmicStatus.
Definition pf1550.ipp:156
bool ClearLatchedFaults() noexcept
Write 0xFF to every category STAT register to clear all RW1C bits.
Definition pf1550.ipp:317
bool ReadLatchedFaults(FaultFlags &faults) noexcept
Read every category STAT register and aggregate latched faults.
Definition pf1550.ipp:276
bool ApplyPortentaH7CarrierProfile() noexcept
Apply the Portenta-H7-on-carrier profile.
Definition pf1550.ipp:115
void SetSwDvsEnabled(uint8_t sw_index, bool enabled) noexcept
Declare the SW1 / SW2 voltage encoding the part's OTP selects.
Definition pf1550.hpp:332
bool ReadChargerState(ChargerState &state, uint8_t *raw_reg=nullptr) noexcept
Read CHG_SNS (Reg 0x87) — charger sub-state. Returns decoded enum.
Definition pf1550.ipp:167
bool ReadDiagnosticSnapshot(DiagnosticSnapshot &out) noexcept
Build a full diagnostic snapshot (≈30 register reads).
Definition pf1550.ipp:430
bool SetSwVoltageMv(uint8_t sw_index, uint16_t mv) noexcept
Set the RUN voltage of a DVS-enabled SW1 or SW2 in millivolts.
Definition pf1550.ipp:220
bool WriteRegister(Register reg, uint8_t value) noexcept
Write any PF1550 register by enumerated address.
Definition pf1550.ipp:86
bool ApplyPortentaH7DefaultProfile() noexcept
Apply the legacy VFR-heritage Portenta H7 default profile.
Definition pf1550.ipp:110
bool ReadInterruptCategory(uint8_t &category) noexcept
Read INT_CATEGORY (Reg 0x06).
Definition pf1550.ipp:271
bool RunPowerSelfTest(SelfTestResult &out) noexcept
Boot-time self-test.
Definition pf1550.ipp:487
void ClearErrorFlags(uint16_t mask=0xFFFF) noexcept
Clear sticky error bits matching mask.
Definition pf1550.hpp:316
uint8_t GetI2cAddress() const noexcept
Currently configured 7-bit I²C address.
Definition pf1550.hpp:106
bool SetSwVoltage(uint8_t sw_index, SwVoltageCode run_code) noexcept
Set the RUN voltage of SW1 or SW2 from a SwVoltageCode.
Definition pf1550.ipp:215
uint16_t GetErrorFlags() const noexcept
Read all sticky error bits (see Error).
Definition pf1550.hpp:313
bool IsInitialized() const noexcept
Idempotently initialise the bus and verify the device. — query without re-running the bus init.
Definition pf1550.hpp:103
bool VerifyDevice() noexcept
Read DEVICE_ID and assert it matches kExpectedDeviceId.
Definition pf1550.ipp:67
Error
Bitmask error codes accumulated in error_flags_.
Definition pf1550.hpp:65
@ DiagnosticRead
One or more reads while building a snapshot failed.
@ SelfTestFailed
RunPowerSelfTest() reported a non-Info severity.
@ ProfileApply
At least one write in the last applied profile failed.
@ I2cRead
Last I²C read transaction failed.
@ NotInitialized
Called before EnsureInitialized() succeeded.
@ WrongDeviceId
Returned DEVICE_ID ≠ kExpectedDeviceId (0x7C).
@ DeviceNotFound
DEVICE_ID read returned NACK / wrong address.
@ InvalidParam
Caller-side argument validation failed.
@ I2cWrite
Last I²C write transaction failed.
bool SetLdoVoltage(uint8_t ldo_index, LdoVoltageCode code) noexcept
Write LDOn_VOLT for n=1..3. Returns false if ldo_index is invalid.
Definition pf1550.ipp:237
bool EnsureInitialized() noexcept
Idempotently initialise the bus and verify the device.
Definition pf1550.ipp:42
bool SetVbusCurrentLimitMa(uint16_t limit_ma) noexcept
Convenience: write VBUS_IN_LIM_CNFG (0x94) from a mA value.
Definition pf1550.ipp:257
bool ApplyProfile(std::span< const profiles::RegisterWrite > profile) noexcept
Apply an arbitrary profile (sequence of register writes).
Definition pf1550.ipp:91
bool ReadOtpRegion(uint8_t *buffer, size_t len, uint8_t start=OtpRegion::kStart) noexcept
Read a contiguous region of OTP memory (default: full 0x1C..0x36 range).
Definition pf1550.ipp:196
bool SetInterruptMaskAll(bool masked) noexcept
Mask (1) or unmask (0) all interrupt categories at once.
Definition pf1550.ipp:332
static constexpr const char * GetDriverVersion() noexcept
Driver version (string).
Definition pf1550.hpp:339
bool SetUsbRails(bool vbus_en, bool otg_en) noexcept
Drive USB_VBUS_EN and USB_OTG_EN straps (HIGH = enabled on Portenta).
Definition pf1550.ipp:140
Register
Symbolic register addresses used by the PF1550 driver.
Definition pf1550_registers.hpp:51
LdoVoltageCode
Common LDO output voltage codes used on Portenta H7 (Table 41).
Definition pf1550_registers.hpp:274
constexpr uint8_t kDefaultI2cAddress
Default 7-bit I²C slave address (settable via OTP — see Table 147).
Definition pf1550_registers.hpp:32
PmicState
STATE_INFO[5:0] values (Reg 0x67) describing the PMIC state machine.
Definition pf1550_registers.hpp:226
ChargerState
CHG_SNS[3:0] values (Reg 0x87) describing the charger sub-state.
Definition pf1550_registers.hpp:236
SwVoltageCode
Common SW buck output voltage codes (RUN mode).
Definition pf1550_registers.hpp:265
PowerMode
Definition pf1550_i2c_interface.hpp:35
PF1550 diagnostic / fault-classification types and snapshot containers.
CRTP I2C + GPIO interface for PF1550 driver.
Named PF1550 register-write sequences (eval / reference hosts).
NXP PF1550 family I2C register map, bit-field constants, and OTP keys.
PF1550 SW / LDO voltage-code ↔ millivolt conversion helpers.
Full diagnostic snapshot returned by PF1550::ReadDiagnosticSnapshot().
Definition pf1550_diagnostics.hpp:140
Bitset of latched fault flags.
Definition pf1550_diagnostics.hpp:79
OTP memory indirect address range (via FMRADDR/FMRDATA).
Definition pf1550_registers.hpp:325
Result of a power self-test pass.
Definition pf1550_diagnostics.hpp:162