PF1550 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Classes | Namespaces | Concepts | Enumerations
pf1550_i2c_interface.hpp File Reference

The I2C port of the PF1550 driver: the CRTP base, its pin enums, the I2cPort concept and the register framing. More...

#include <array>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <span>
#include "pf1550_detail.hpp"
#include "pf1550_types.hpp"

Go to the source code of this file.

Classes

class  pf1550::I2cInterface< Derived >
 CRTP base of the platform I2C port. More...
 

Namespaces

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

Concepts

concept  pf1550::I2cPort
 Satisfied by a class that derives from I2cInterface<Port> and implements the required hooks with exactly the types above, noexcept and returning bool.
 

Enumerations

enum class  pf1550::CtrlPin : uint8_t { pf1550::Standby = 0 , pf1550::Intb = 1 }
 Control pins the port may reach through the optional GpioSet() and GpioGet() hooks. More...
 
enum class  pf1550::GpioSignal : uint8_t { pf1550::INACTIVE = 0 , pf1550::ACTIVE = 1 }
 Logical level of a control pin; the port maps it to the physical polarity. More...
 
enum class  pf1550::I2cFailure : uint8_t { pf1550::None = 0 , pf1550::AddressNack = 1 , pf1550::DataNack = 2 , pf1550::Bus = 3 }
 Why the last transfer failed, reported by the optional GetLastFailure() hook. More...
 

Variables

Bus requirements

What the PF1550 needs from the I2C bus (datasheet sections 9.7.1, 9.7.2). A port and a board configuration check their settings against these with static_assert (handbook KB-CPP-123).

constexpr uint8_t pf1550::kI2cAddress = 0x08
 Default 7-bit I2C address (section 9.7.1).
 
constexpr uint8_t pf1550::kMinI2cAddress = 0x08
 Lowest address OTP can select (I2C_ADDR[2:0] = 000).
 
constexpr uint8_t pf1550::kMaxI2cAddress = 0x0F
 Highest address OTP can select (I2C_ADDR[2:0] = 111).
 
constexpr uint32_t pf1550::kMaxClockHz = 400'000
 Highest SCL frequency: fast mode (section 9.7.2).
 
constexpr uint32_t pf1550::kMinEdgeNs = 20
 Shortest SCL and SDA rise and fall time the chip accepts, in nanoseconds (section 9.7).
 
constexpr bool pf1550::kRepeatedStart = true
 true: a register read is a combined write-read with a repeated START (Figure 25).
 

Detailed Description

The I2C port of the PF1550 driver: the CRTP base, its pin enums, the I2cPort concept and the register framing.

The driver never calls an SDK. It calls hooks on a class you derive from pf1550::I2cInterface<Self>:

Hook Contract
bool EnsureInitialized() noexcept Bring the bus up on the first call; true at once afterwards
bool Write(uint8_t addr, const uint8_t* data, std::size_t len) noexcept START, addr + W, len bytes, STOP; false on a NACK or bus error
bool WriteRead(uint8_t addr, const uint8_t* tx, std::size_t tx_len, uint8_t* rx, std::size_t rx_len) noexcept START, addr + W, tx, repeated START, addr + R, rx_len bytes, STOP
void DelayUs(uint32_t us) noexcept Wait; needed by the DVS and charger waits
bool GpioSet(CtrlPin pin, GpioSignal level) noexcept (optional) Drive CtrlPin::Standby
bool GpioGet(CtrlPin pin, bool& asserted) noexcept (optional) Read CtrlPin::Intb (asserted = low)
bool GetLastFailure(I2cFailure& why) noexcept (optional) Address NACK, data NACK or bus error
void Log(LogLevel level, const char* message) noexcept (optional) One line per event

addr is the 7-bit address. The port moves raw bytes: the register address travels in the payload, and the port never retries or configures the chip. What the chip needs from the bus is below as constexpr values (kI2cAddress, kMaxClockHz, kRepeatedStart); a port checks its settings against them with static_assert.