Skip to content

radio_esp32::phy_init

The PHY’s initialisation parameters.

esp_phy_init_data_t — uint8_t params[128] — the first argument to register_chipv7_phy. Espressif’s recommended defaults, transcribed from esp-idf components/esp_phy/esp32/include/phy_init_data.h at tag v4.4, the revision tools/fetch-blobs.sh pins the archives to.

The archives are fetched because they are eight megabytes of binaries. This is 128 bytes of documented constants from an Apache-2.0 header, and fetching it would need a parser and a generated file in the build — more machinery than it saves. The provenance is recorded instead, and the regeneration recipe is in the tests.

The C initialiser lists 107 entries and lets the compiler zero the rest. That is easy to miss and invisible from the header, so the tail is an explicit zero fill here and a test pins it: a table 21 bytes short would be handed to the PHY along with whatever followed it in memory.

Six entries are LIMIT(CONFIG_ESP_PHY_MAX_TX_POWER * 4, 40, n) in the header — a Kconfig value FlintOS has no equivalent of. It is a regulatory and thermal choice rather than a chip fact, so it is a parameter here and the clamping happens exactly as the macro does it.

Units are quarter-dBm, which is the multiply by four. The six cover different modulations and their ceilings differ (78, 72, 66, 60, 56, 52) because the higher-rate ones cannot be driven as hard.

const fn init_data(max_tx_power_dbm: i32) -> [u8; 128]

Build the init data for a maximum transmit power, in dBm.

const fn, so a board’s table is computed at build time and costs nothing at boot.

const PHY_INIT_DATA_LEN: usize;

sizeof(esp_phy_init_data_t).

const TX_POWER_CEILINGS: [u8; 6];

The per-modulation ceilings, in quarter-dBm, in slot order.

const TX_POWER_FLOOR: u8;

The floor every entry is clamped up to.

const TX_POWER_SLOTS: [usize; 6];

Where the six transmit-power entries sit, from the header’s ordering.

Named so the tests can check the knob reaches them, rather than inferring the positions by differencing two tables and hoping.