HardFOC Core
API reference
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Pf1550Handler Class Reference

Thread-safe PF1550 PMIC HAL handler. More...

#include <Pf1550Handler.h>

Public Types

using Pf1550Driver = pf1550::PF1550< HalPf1550Comm >
 Alias for the templated driver type.
 

Public Member Functions

 Pf1550Handler (BaseI2c &i2c, BaseGpio *standby_gpio=nullptr, BaseGpio *usb_vbus_en_gpio=nullptr, BaseGpio *usb_otg_en_gpio=nullptr) noexcept
 Construct with required I²C and optional strap pins.
 
 Pf1550Handler (const Pf1550Handler &)=delete
 
Pf1550Handler & operator= (const Pf1550Handler &)=delete
 
bool EnsureInitialized () noexcept
 Idempotent — verify DEVICE_ID and prime the bus adapter.
 
bool IsInitialized () const noexcept
 Has EnsureInitialized ever succeeded?
 
bool ApplyProfile (std::span< const pf1550::profiles::RegisterWrite > profile) noexcept
 Apply an ordered register-write sequence.
 
bool ApplyPortentaH7Profile () noexcept
 Driver-named Arduino Portenta H7 eval sequence (legacy VFR order).
 
bool ApplyPortentaH7CarrierProfile () noexcept
 Driver-named Portenta-H7-on-carrier eval sequence (SW1-first).
 
bool SetPowerMode (pf1550::PowerMode mode) noexcept
 Drive STANDBY strap to RUN or STANDBY.
 
bool SetUsbRails (bool vbus_en, bool otg_en) noexcept
 Drive USB_VBUS_EN / USB_OTG_EN straps.
 
bool ReadPmicStatus (uint8_t &status) noexcept
 Read STATE_INFO (0x67).
 
bool RefreshDiagnosticSnapshot () noexcept
 Refresh the cached snapshot by re-reading the PMIC.
 
bool RefreshStatusSnapshot () noexcept
 Refresh the status part of the cached snapshot only (driver RefreshStatusSnapshot); identity and rail configuration stay from the last full refresh. Falls back to a full read when the cache holds none.
 
bool ReadDiagnosticSnapshot (pf1550::DiagnosticSnapshot &out) noexcept
 Copy the cached snapshot out (zero-copy not provided to keep the API thread-safe).
 
bool RunPowerSelfTest (pf1550::SelfTestResult &out) noexcept
 Run boot-time self-test (uses internal snapshot path).
 
bool ClearLatchedFaults () noexcept
 Clear every RW1C latched fault status register.
 
bool HasMcuAffectingFault () noexcept
 Convenience: are any currently-latched faults of severity kCritical or kMcuKill?
 
Pf1550Driver * GetDriver () noexcept
 Expose raw driver (advanced use only — does not lock).
 
const Pf1550Driver * GetDriver () const noexcept
 Expose raw driver (advanced use only — does not lock).
 

Private Member Functions

bool ensureInitializedLocked () noexcept
 

Private Attributes

BaseI2c & i2c_
 
BaseGpio * standby_gpio_
 
BaseGpio * usb_vbus_en_gpio_
 
BaseGpio * usb_otg_en_gpio_
 
std::unique_ptr< HalPf1550Comm > comm_
 
std::unique_ptr< Pf1550Driver > driver_
 
bool initialized_
 
pf1550::DiagnosticSnapshot cached_snapshot_
 
bool have_full_snapshot_ {false}
 cached_snapshot_ holds a successful full read
 
RtosMutex handler_mutex_
 

Detailed Description

Thread-safe PF1550 PMIC HAL handler.

Owns:

Lifecycle:

  1. Construct with bound BaseI2c and optional strap BaseGpio* pins.
  2. Call EnsureInitialized (idempotent) before any other method.
  3. (Optional) host calls ApplyProfile with a register-write table. ApplyPortentaH7CarrierProfile is a driver-named eval sequence for ESP examples — not a product board bind.
  4. Periodically call RefreshDiagnosticSnapshot from a monitor thread.

Member Typedef Documentation

◆ Pf1550Driver

using Pf1550Handler::Pf1550Driver = pf1550::PF1550<HalPf1550Comm>

Alias for the templated driver type.

Constructor & Destructor Documentation

◆ Pf1550Handler() [1/2]

Pf1550Handler::Pf1550Handler ( BaseI2c &  i2c,
BaseGpio *  standby_gpio = nullptr,
BaseGpio *  usb_vbus_en_gpio = nullptr,
BaseGpio *  usb_otg_en_gpio = nullptr 
)
noexcept

Construct with required I²C and optional strap pins.

Parameters
i2cI²C device whose 7-bit address matches the PF1550.
standby_gpioOptional STANDBY strap; nullptr if unused.
usb_vbus_en_gpioOptional USB_VBUS_EN strap; nullptr if unused.
usb_otg_en_gpioOptional USB_OTG_EN strap; nullptr if unused.

◆ Pf1550Handler() [2/2]

Pf1550Handler::Pf1550Handler ( const Pf1550Handler &  )
delete

Member Function Documentation

◆ ApplyPortentaH7CarrierProfile()

bool Pf1550Handler::ApplyPortentaH7CarrierProfile ( )
noexcept

Driver-named Portenta-H7-on-carrier eval sequence (SW1-first).

Note
Hosts that are not that eval board skip this and pass their own table to ApplyProfile.

◆ ApplyPortentaH7Profile()

bool Pf1550Handler::ApplyPortentaH7Profile ( )
noexcept

Driver-named Arduino Portenta H7 eval sequence (legacy VFR order).

Note
Hosts that are not that eval board skip this and pass their own table to ApplyProfile.

◆ ApplyProfile()

bool Pf1550Handler::ApplyProfile ( std::span< const pf1550::profiles::RegisterWrite >  profile)
noexcept

Apply an ordered register-write sequence.

Parameters
profileWrites applied in order; each entry may delay after the write.

◆ ClearLatchedFaults()

bool Pf1550Handler::ClearLatchedFaults ( )
noexcept

Clear every RW1C latched fault status register.

◆ EnsureInitialized()

bool Pf1550Handler::EnsureInitialized ( )
noexcept

Idempotent — verify DEVICE_ID and prime the bus adapter.

◆ ensureInitializedLocked()

bool Pf1550Handler::ensureInitializedLocked ( )
privatenoexcept

◆ GetDriver() [1/2]

const Pf1550Handler::Pf1550Driver * Pf1550Handler::GetDriver ( ) const
noexcept

Expose raw driver (advanced use only — does not lock).

◆ GetDriver() [2/2]

Pf1550Handler::Pf1550Driver * Pf1550Handler::GetDriver ( )
noexcept

Expose raw driver (advanced use only — does not lock).

◆ HasMcuAffectingFault()

bool Pf1550Handler::HasMcuAffectingFault ( )
noexcept

Convenience: are any currently-latched faults of severity kCritical or kMcuKill?

◆ IsInitialized()

bool Pf1550Handler::IsInitialized ( ) const
inlinenoexcept

Has EnsureInitialized ever succeeded?

◆ operator=()

Pf1550Handler & Pf1550Handler::operator= ( const Pf1550Handler &  )
delete

◆ ReadDiagnosticSnapshot()

bool Pf1550Handler::ReadDiagnosticSnapshot ( pf1550::DiagnosticSnapshot &  out)
noexcept

Copy the cached snapshot out (zero-copy not provided to keep the API thread-safe).

◆ ReadPmicStatus()

bool Pf1550Handler::ReadPmicStatus ( uint8_t &  status)
noexcept

Read STATE_INFO (0x67).

◆ RefreshDiagnosticSnapshot()

bool Pf1550Handler::RefreshDiagnosticSnapshot ( )
noexcept

Refresh the cached snapshot by re-reading the PMIC.

Safe to call from any thread; serialised by the handler mutex.

Returns
true if all I²C transactions completed.

◆ RefreshStatusSnapshot()

bool Pf1550Handler::RefreshStatusSnapshot ( )
noexcept

Refresh the status part of the cached snapshot only (driver RefreshStatusSnapshot); identity and rail configuration stay from the last full refresh. Falls back to a full read when the cache holds none.

◆ RunPowerSelfTest()

bool Pf1550Handler::RunPowerSelfTest ( pf1550::SelfTestResult &  out)
noexcept

Run boot-time self-test (uses internal snapshot path).

On success out.worst_severity == FaultSeverity::kInfo. Failures are classified into Warning / Critical / McuKill via pf1550::FaultSeverityPortentaH7 (board-profile severity table).

◆ SetPowerMode()

bool Pf1550Handler::SetPowerMode ( pf1550::PowerMode  mode)
noexcept

Drive STANDBY strap to RUN or STANDBY.

◆ SetUsbRails()

bool Pf1550Handler::SetUsbRails ( bool  vbus_en,
bool  otg_en 
)
noexcept

Drive USB_VBUS_EN / USB_OTG_EN straps.

Member Data Documentation

◆ cached_snapshot_

pf1550::DiagnosticSnapshot Pf1550Handler::cached_snapshot_
private

◆ comm_

std::unique_ptr<HalPf1550Comm> Pf1550Handler::comm_
private

◆ driver_

std::unique_ptr<Pf1550Driver> Pf1550Handler::driver_
private

◆ handler_mutex_

RtosMutex Pf1550Handler::handler_mutex_
mutableprivate

◆ have_full_snapshot_

bool Pf1550Handler::have_full_snapshot_ {false}
private

cached_snapshot_ holds a successful full read

◆ i2c_

BaseI2c& Pf1550Handler::i2c_
private

◆ initialized_

bool Pf1550Handler::initialized_
private

◆ standby_gpio_

BaseGpio* Pf1550Handler::standby_gpio_
private

◆ usb_otg_en_gpio_

BaseGpio* Pf1550Handler::usb_otg_en_gpio_
private

◆ usb_vbus_en_gpio_

BaseGpio* Pf1550Handler::usb_vbus_en_gpio_
private

The documentation for this class was generated from the following files: