12#ifndef PF1550_CODEC_HPP
13#define PF1550_CODEC_HPP
46inline constexpr std::array<uint16_t, kInputLimitCodes>
kInputLimitMa = {
47 10, 15, 20, 25, 30, 35, 40, 45, 50, 100, 150,
48 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1500};
51inline constexpr std::array<uint32_t, 7>
kBuckFixedUv = {1100000, 1200000, 1350000, 1500000,
52 1800000, 2500000, 3000000};
112 constexpr std::array<uint32_t, 5> kTable = {5, 10, 20, 30, 50};
113 for (std::size_t i = 0U; i < kTable.size(); ++i) {
114 if (kTable[i] == ma) {
127 constexpr std::array<uint32_t, 5> kTable = {5, 10, 20, 30, 50};
128 if (code >= kTable.size()) {
196constexpr uint32_t
Sw3Uv(uint32_t code)
noexcept {
197 return 1800000U + (100000U * (code & 0x0FU));
208 if ((uv >= 1800000U) && (uv <= 3300000U) && (((uv - 1800000U) % 100000U) == 0U)) {
216 if ((uv >= 750000U) && (uv <= 1500000U) && (((uv - 750000U) % 50000U) == 0U)) {
219 if ((uv >= 1800000U) && (uv <= 3300000U) && (((uv - 1800000U) % 100000U) == 0U)) {
231constexpr uint32_t
LdoUv(
Rail rail, uint32_t code)
noexcept {
233 return 1800000U + (100000U * (code & 0x0FU));
238 const uint32_t c = code & 0x1FU;
239 return (c < 16U) ? (750000U + (50000U * c)) : (1800000U + (100000U * (c - 16U)));
248 if ((mv < 1800U) || (mv > 3300U) || (((mv - 1800U) % 100U) != 0U)) {
308static_assert((
Sw3Uv(0_u32) == 1800000U) && (
Sw3Uv(15_u32) == 3300000U));
constexpr std::array< uint16_t, kInputLimitCodes > kInputLimitMa
The VBUS_LIN_ILIM table, mA, indexed by code (Table 163, Table 58).
Definition pf1550_codec.hpp:46
constexpr uint32_t kChargeCurrentMaxMa
Highest charge current, mA.
Definition pf1550_codec.hpp:37
constexpr uint32_t BuckDvsUv(uint32_t code) noexcept
The voltage of a DVS-mode buck code.
Definition pf1550_codec.hpp:178
constexpr uint32_t kChargeCurrentMinMa
Charge current range, mA (Table 159: codes 0 to 18).
Definition pf1550_codec.hpp:35
constexpr Result< uint8_t > LdoCode(Rail rail, uint32_t uv) noexcept
LDO voltage code.
Definition pf1550_codec.hpp:206
constexpr uint32_t kBuckDvsStepUv
DVS buck step, uV.
Definition pf1550_codec.hpp:41
constexpr Result< uint8_t > CoinVoltageCode(uint32_t mv) noexcept
VCOIN code for a coin cell charge voltage (1.8 V + 100 mV x code, ambiguity C40).
Definition pf1550_codec.hpp:247
constexpr Result< uint32_t > TerminationMa(uint32_t code) noexcept
The termination current of an IEOC code.
Definition pf1550_codec.hpp:126
constexpr uint32_t BuckFixedUvOf(uint32_t code) noexcept
The voltage of a buck code in the non-DVS table (Table 31): codes 0 to 6, 3.3 V above.
Definition pf1550_codec.hpp:187
constexpr PowerState DecodePowerState(uint32_t code) noexcept
The 4-bit power-state code of STATE_INFO (Table 146) as a PowerState.
Definition pf1550_codec.hpp:259
constexpr Result< uint8_t > ChargeCurrentCode(uint32_t ma) noexcept
CHG_CC code for a charge current.
Definition pf1550_codec.hpp:87
constexpr Result< uint8_t > ChargeVoltageCode(uint32_t mv) noexcept
CHGCV code for a charge voltage.
Definition pf1550_codec.hpp:59
constexpr Result< uint8_t > BuckDvsCode(uint32_t uv) noexcept
DVS-mode buck code for a voltage (SW1, SW2: 0.6 V + 12.5 mV x code).
Definition pf1550_codec.hpp:165
constexpr Result< uint8_t > InputLimitCode(uint32_t ma) noexcept
VBUS_LIN_ILIM code for an input current limit.
Definition pf1550_codec.hpp:139
constexpr uint32_t kChargeVoltageMinMv
Lowest charge voltage (CHGCV code 8), mV (Table 160).
Definition pf1550_codec.hpp:31
constexpr uint32_t ChargeVoltageMv(uint32_t code) noexcept
The charge voltage a CHGCV code stands for.
Definition pf1550_codec.hpp:72
constexpr Result< uint32_t > InputLimitMa(uint32_t code) noexcept
The limit of a VBUS_LIN_ILIM code.
Definition pf1550_codec.hpp:153
constexpr Result< uint8_t > TerminationCode(uint32_t ma) noexcept
IEOC code for a termination current.
Definition pf1550_codec.hpp:111
constexpr Option DecodeOption(uint32_t flavor) noexcept
The option an OTP_FLAVOR byte names (Table 87 lists 0 to 3 and then "continues": a larger byte is Unk...
Definition pf1550_codec.hpp:283
constexpr std::array< uint32_t, 7 > kBuckFixedUv
The fixed (DVS disabled) buck table, uV, codes 0 to 6; every code above is 3.3 V (Table 31).
Definition pf1550_codec.hpp:51
constexpr std::size_t kInputLimitCodes
Number of VBUS_LIN_ILIM codes the data sheet defines (Table 163).
Definition pf1550_codec.hpp:43
constexpr Result< uint32_t > ChargeCurrentMa(uint32_t code) noexcept
The current of a CHG_CC code.
Definition pf1550_codec.hpp:99
constexpr uint32_t kBuckDvsMinUv
DVS buck lowest voltage, uV (Table 31).
Definition pf1550_codec.hpp:39
constexpr uint32_t Sw3Uv(uint32_t code) noexcept
The voltage of an SW3 code (1.80 V + 100 mV x code, Table 37).
Definition pf1550_codec.hpp:196
constexpr uint32_t kChargeVoltageMaxMv
Highest charge voltage (CHGCV code 55), mV.
Definition pf1550_codec.hpp:33
constexpr uint32_t LdoUv(Rail rail, uint32_t code) noexcept
The voltage of an LDO code.
Definition pf1550_codec.hpp:231
Option
The start-up option of the part (OTP_FLAVOR, Table 87; ordering codes A0 to A9).
Definition pf1550_types.hpp:215
Rail
The power rails the driver configures.
Definition pf1550_types.hpp:249
PowerState
STATE_INFO decoded (Table 146).
Definition pf1550_types.hpp:239
@ Unknown
A flavour byte the data sheet does not list (ambiguity C10).
@ Ldo3
LDO3, 300 mA, load switch capable.
@ Ldo1
LDO1, 300 mA, load switch capable.
The PF1550 driver: everything it declares lives here; internals in detail.
Definition pf1550.hpp:39
Compile-time helpers of the PF1550 driver: typed integer literals, exact hook matching,...
Public types of the PF1550 driver: errors, Result<T>, enumerations, units, status and interrupt types...
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