Skip to content

Namespace OpenSkyhawk::Pdu

Namespace List > OpenSkyhawk > Pdu

Classes

Type Name
class CalStore
The reserved flash page holding the calibration log.
struct CalValues
Calibration values the conversions need. Defaults = uncalibrated.
struct Latch
A condition that must hold setMs to raise and its clear condition holdclearMs to drop.
class TelemSchedule

Public Types

Type Name
enum uint8_t CalFlag
CalRecord.calFlags bits — which calibrations this record holds.

Public Static Attributes

Type Name
constexpr uint32_t ADC_FULL = 1UL << 16
analogReadResolution(16), set by STM32Board __
constexpr uint32_t CAL_MAGIC = 0x4C414350
'PCAL' little-endian
constexpr uint32_t CAL_PAGE_SIZE = 1024
constexpr uint8_t CAL_SLOTS = [**CAL\_PAGE\_SIZE**](namespaceOpenSkyhawk_1_1Pdu.md#variable-cal_page_size) / sizeof(CalRecord)
constexpr uint8_t CAL_VERSION = 1
constexpr uint16_t GAIN_UNITY = 10000
cal gain trims: 10000 = ×1.0000
constexpr uint32_t I_MA_PER_MV = 2
INA180A2 (gain 50 V/V) on a 10 mΩ shunt: I = Vout / (50 × 0.010 Ω) → mA = 2 × mV.
constexpr float NTC_BETA_K = 3450.0f
constexpr float NTC_BIAS_OHM = 10000.0f
constexpr float NTC_R0_OHM = 10000.0f
NTC: 10 kΩ ±1 % B3450 to GND, 10 kΩ bias from +3V3 (same rail as VDDA → ratiometric).
constexpr float NTC_T0_K = 298.15f
constexpr uint32_t V12_DIV_DEN = 10
constexpr uint32_t V12_DIV_NUM = 43
Rail = ADC × num / den. 12 V: (33k + 10k) / 10k. 5 V: (10k + 13k) / 13k.
constexpr uint32_t V5_DIV_DEN = 13
constexpr uint32_t V5_DIV_NUM = 23
constexpr uint16_t VDDA_NOMINAL_MV = 3300
assumed VDDA until CAL VDDA anchors Vrefint
constexpr uint16_t VREFINT_TYP_MV = 1200
F103 Vrefint typical (untrimmed, ±~3 %)

Public Functions

Type Name
struct __attribute__ ((packed))
One stored calibration — 32 bytes, little-endian, CRC-32 over bytes 0–27.
CalRecord calDefaults ()
An uncalibrated record: unity gains, zero offsets, no flags.
void calSeal (CalRecord & rec)
Fill magic/version/crc for rec (seq left as set).
bool calValid (const CalRecord & rec)
True when rec has the right magic, version and CRC.
CalValues calValues (const CalRecord & rec)
The conversion values a record carries.
int16_t clampI16 (int32_t v)
Clamp an int32 into int16 range.
uint16_t clampU16 (int32_t v)
Clamp an int32 into uint16 range.
uint32_t countsToMv (uint16_t counts, uint16_t vddaMv)
ADC pin voltage in mV for a 16-bit count at the given VDDA.
uint32_t crc32 (const uint8_t * data, size_t len)
CRC-32 (IEEE 802.3, reflected 0xEDB88320) over len bytes.
int32_t currentMa (uint32_t adcMv, int16_t zeroDmA, uint16_t iGain)
Rail current in mA from the INA180 output voltage.
int16_t ntcTempDC (uint16_t counts, int16_t offsetDC, bool & fault)
Board temperature in 0.1 °C from the NTC channel (ratiometric — VDDA cancels).
void putLe16 (uint8_t * p, uint16_t v)
Store v little-endian atp[0..1] — a multi-byte TELEM page field.
uint16_t rail12Mv (uint32_t adcMv, uint16_t vGain)
12 V rail in mV from the ADC pin voltage, after the divider and gain trim.
uint16_t rail5Mv (uint32_t adcMv, uint16_t vGain)
5 V rail in mV from the ADC pin voltage, after the divider and gain trim.
bool railed (uint16_t counts)
True when a 16-bit count is at the top rail (≥ 99.5 % FS) — the channel can't measure.
int32_t rawCurrentDmA (uint32_t adcMv)
Uncorrected current in 0.1 mA (no zero, unity gain) — what CAL ZERO measures.
uint16_t vddaMv (uint16_t vrefintRaw, uint16_t vrefintMv)
VDDA in mV from a raw Vrefint reading.

Public Static Functions

Type Name
bool slotEmpty (const CalRecord * s)
uint16_t trimmed (uint32_t mv, uint16_t gain)

Public Types Documentation

enum CalFlag

CalRecord.calFlags bits — which calibrations this record holds.

enum OpenSkyhawk::Pdu::CalFlag {
    CAL_VDDA = 0x01,
    CAL_ZERO = 0x02,
    CAL_GAIN = 0x04,
    CAL_NTC = 0x08
};


Public Static Attributes Documentation

variable ADC_FULL

analogReadResolution(16), set by STM32Board __

constexpr uint32_t OpenSkyhawk::Pdu::ADC_FULL;


variable CAL_MAGIC

'PCAL' little-endian

constexpr uint32_t OpenSkyhawk::Pdu::CAL_MAGIC;


variable CAL_PAGE_SIZE

constexpr uint32_t OpenSkyhawk::Pdu::CAL_PAGE_SIZE;

variable CAL_SLOTS

constexpr uint8_t OpenSkyhawk::Pdu::CAL_SLOTS;

variable CAL_VERSION

constexpr uint8_t OpenSkyhawk::Pdu::CAL_VERSION;

variable GAIN_UNITY

cal gain trims: 10000 = ×1.0000

constexpr uint16_t OpenSkyhawk::Pdu::GAIN_UNITY;


variable I_MA_PER_MV

INA180A2 (gain 50 V/V) on a 10 mΩ shunt: I = Vout / (50 × 0.010 Ω) → mA = 2 × mV.

constexpr uint32_t OpenSkyhawk::Pdu::I_MA_PER_MV;


variable NTC_BETA_K

constexpr float OpenSkyhawk::Pdu::NTC_BETA_K;

variable NTC_BIAS_OHM

constexpr float OpenSkyhawk::Pdu::NTC_BIAS_OHM;

variable NTC_R0_OHM

NTC: 10 kΩ ±1 % B3450 to GND, 10 kΩ bias from +3V3 (same rail as VDDA → ratiometric).

constexpr float OpenSkyhawk::Pdu::NTC_R0_OHM;


variable NTC_T0_K

constexpr float OpenSkyhawk::Pdu::NTC_T0_K;

variable V12_DIV_DEN

constexpr uint32_t OpenSkyhawk::Pdu::V12_DIV_DEN;

variable V12_DIV_NUM

Rail = ADC × num / den. 12 V: (33k + 10k) / 10k. 5 V: (10k + 13k) / 13k.

constexpr uint32_t OpenSkyhawk::Pdu::V12_DIV_NUM;


variable V5_DIV_DEN

constexpr uint32_t OpenSkyhawk::Pdu::V5_DIV_DEN;

variable V5_DIV_NUM

constexpr uint32_t OpenSkyhawk::Pdu::V5_DIV_NUM;

variable VDDA_NOMINAL_MV

assumed VDDA until CAL VDDA anchors Vrefint

constexpr uint16_t OpenSkyhawk::Pdu::VDDA_NOMINAL_MV;


variable VREFINT_TYP_MV

F103 Vrefint typical (untrimmed, ±~3 %)

constexpr uint16_t OpenSkyhawk::Pdu::VREFINT_TYP_MV;


Public Functions Documentation

function __attribute__

One stored calibration — 32 bytes, little-endian, CRC-32 over bytes 0–27.

struct OpenSkyhawk::Pdu::__attribute__ (
    (packed)
) 


function calDefaults

An uncalibrated record: unity gains, zero offsets, no flags.

CalRecord OpenSkyhawk::Pdu::calDefaults () 


function calSeal

Fill magic/version/crc for rec (seq left as set).

void OpenSkyhawk::Pdu::calSeal (
    CalRecord & rec
) 


function calValid

True when rec has the right magic, version and CRC.

bool OpenSkyhawk::Pdu::calValid (
    const CalRecord & rec
) 


function calValues

The conversion values a record carries.

CalValues OpenSkyhawk::Pdu::calValues (
    const CalRecord & rec
) 


function clampI16

Clamp an int32 into int16 range.

int16_t OpenSkyhawk::Pdu::clampI16 (
    int32_t v
) 


function clampU16

Clamp an int32 into uint16 range.

uint16_t OpenSkyhawk::Pdu::clampU16 (
    int32_t v
) 


function countsToMv

ADC pin voltage in mV for a 16-bit count at the given VDDA.

uint32_t OpenSkyhawk::Pdu::countsToMv (
    uint16_t counts,
    uint16_t vddaMv
) 


function crc32

CRC-32 (IEEE 802.3, reflected 0xEDB88320) over len bytes.

uint32_t OpenSkyhawk::Pdu::crc32 (
    const uint8_t * data,
    size_t len
) 


function currentMa

Rail current in mA from the INA180 output voltage.

int32_t OpenSkyhawk::Pdu::currentMa (
    uint32_t adcMv,
    int16_t zeroDmA,
    uint16_t iGain
) 

Parameters:

  • adcMv INA180 output at the ADC pin, mV.
  • zeroDmA Zero offset to subtract, 0.1 mA (from CAL ZERO).
  • iGain Gain trim, 10000 = ×1.

Returns:

Signed mA — a small negative value is residual offset, kept so it stays visible.


function ntcTempDC

Board temperature in 0.1 °C from the NTC channel (ratiometric — VDDA cancels).

int16_t OpenSkyhawk::Pdu::ntcTempDC (
    uint16_t counts,
    int16_t offsetDC,
    bool & fault
) 

Parameters:

  • counts 16-bit ADC count of the NTC node.
  • offsetDC One-point offset, 0.1 °C.
  • fault Set true when the reading is outside 2–98 % of full scale (open / shorted NTC).

Returns:

Temperature in 0.1 °C, or NTC_TEMP_UNAVAILABLE (NodeStatus.h) when fault.


function putLe16

Store v little-endian atp[0..1] — a multi-byte TELEM page field.

inline void OpenSkyhawk::Pdu::putLe16 (
    uint8_t * p,
    uint16_t v
) 


function rail12Mv

12 V rail in mV from the ADC pin voltage, after the divider and gain trim.

uint16_t OpenSkyhawk::Pdu::rail12Mv (
    uint32_t adcMv,
    uint16_t vGain
) 


function rail5Mv

5 V rail in mV from the ADC pin voltage, after the divider and gain trim.

uint16_t OpenSkyhawk::Pdu::rail5Mv (
    uint32_t adcMv,
    uint16_t vGain
) 


function railed

True when a 16-bit count is at the top rail (≥ 99.5 % FS) — the channel can't measure.

bool OpenSkyhawk::Pdu::railed (
    uint16_t counts
) 


function rawCurrentDmA

Uncorrected current in 0.1 mA (no zero, unity gain) — what CAL ZERO measures.

int32_t OpenSkyhawk::Pdu::rawCurrentDmA (
    uint32_t adcMv
) 


function vddaMv

VDDA in mV from a raw Vrefint reading.

uint16_t OpenSkyhawk::Pdu::vddaMv (
    uint16_t vrefintRaw,
    uint16_t vrefintMv
) 

Parameters:

  • vrefintRaw 16-bit ADC count of the internal reference (0 = unreadable).
  • vrefintMv This chip's calibrated Vrefint, or 0 when uncalibrated.

Returns:

VDDA in mV: Vrefint-tracked when calibrated, VDDA_NOMINAL_MV otherwise (the untrimmed F103 Vrefint is a worse reference than the regulator's nominal until anchored).


Public Static Functions Documentation

function slotEmpty

static bool OpenSkyhawk::Pdu::slotEmpty (
    const CalRecord * s
) 

function trimmed

static uint16_t OpenSkyhawk::Pdu::trimmed (
    uint32_t mv,
    uint16_t gain
) 


The documentation for this class was generated from the following file Firmware/Libraries/PowerMonitor/PduCalStore.cpp