Add DAB ANTCAP calibration and fix BT1035 boot banner timing
Extend the FM-only ANTCAP antenna-varactor override to DAB, mirroring the existing mechanism end to end (driver, tuner, service, EEPROM storage, HTTP API). Live sweep on real hardware found no ANTCAP value beating auto-tune on the ensembles tested, so DAB stays on auto-tune by default. Also fix BT1035 boot: the module's real boot banner doesn't appear until ~18-24s after RESET# releases, not the 3.5s previously waited; add a 2-attempt retry and a baud-rate probe fallback for diagnostics. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,27 +13,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/IDeviceIdentitySource.hpp"
|
||||
#include "core/IdentityError.hpp"
|
||||
|
||||
#include "driver/i2c_master.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <expected>
|
||||
#include <optional>
|
||||
|
||||
namespace eeprom24aa {
|
||||
|
||||
/**
|
||||
* @brief Eeprom24aa — reads the factory EUI-48 from Microchip 24AA025E48.
|
||||
* @brief Eeprom24aa — reads the factory EUI-48 from Microchip 24AA025E48;
|
||||
* also stores one board-specific calibration byte in the chip's
|
||||
* user-writable region.
|
||||
*
|
||||
* @dname Eeprom24aa
|
||||
* @return n/a (type)
|
||||
* @pubstate Borrows an existing I2C master bus (shared with ADAU1701). The
|
||||
* EUI-48 lives at word address 0xFA..0xFF per the 24AA025E48
|
||||
* datasheet (DS20001191).
|
||||
* EUI-48 lives at word address 0xFA..0xFF (read-only, factory
|
||||
* programmed) per the 24AA025E48 datasheet (DS20001191); the FM
|
||||
* ANTCAP calibration byte lives at word address 0x00, and the
|
||||
* DAB ANTCAP calibration byte at word address 0x01, both in the
|
||||
* remaining user-writable 250 bytes.
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-07-07
|
||||
*/
|
||||
class Eeprom24aa : public core::IDeviceIdentitySource {
|
||||
public:
|
||||
/** Valid ANTCAP calibration values (FM or DAB) are 0-128 (AN649/AN851);
|
||||
* any stored byte above this, including the EEPROM's blank/erased
|
||||
* 0xFF, reads back as "never calibrated" — no separate sentinel write
|
||||
* needed for a fresh chip. */
|
||||
static constexpr std::uint8_t kFmAntCapMax = 128U;
|
||||
/** Same range as kFmAntCapMax; kept as a separate name for the DAB
|
||||
* calibration byte's own doc comments below. */
|
||||
static constexpr std::uint8_t kDabAntCapMax = 128U;
|
||||
|
||||
/**
|
||||
* @brief Eeprom24aa — bind to a running I2C master bus and 7-bit addr.
|
||||
*
|
||||
@@ -60,6 +77,69 @@ public:
|
||||
[[nodiscard]] std::expected<core::DeviceIdentity, core::IdentityError>
|
||||
readDeviceIdentity() override;
|
||||
|
||||
/**
|
||||
* @brief readFmAntCap — read the stored FM antenna calibration byte.
|
||||
*
|
||||
* @dname readFmAntCap
|
||||
* @return Calibrated ANTCAP (0-kFmAntCapMax) if one was ever saved via
|
||||
* writeFmAntCap(), nullopt if the byte is blank/out of range,
|
||||
* or IdentityError on an I2C failure.
|
||||
* @pubstate performs one I2C read of one byte at word address 0x00.
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-08-19
|
||||
*/
|
||||
[[nodiscard]] std::expected<std::optional<std::uint8_t>, core::IdentityError>
|
||||
readFmAntCap();
|
||||
|
||||
/**
|
||||
* @brief writeFmAntCap — persist an FM antenna calibration value.
|
||||
*
|
||||
* @dname writeFmAntCap
|
||||
* @param value ANTCAP to store, 0-kFmAntCapMax (AN851 Appendix A
|
||||
* calibration procedure; found via a sweep, not
|
||||
* computed).
|
||||
* @return Ok on success, or IdentityError::I2cFailed.
|
||||
* @pubstate performs one I2C byte write at word address 0x00, then
|
||||
* blocks for the chip's write-cycle time before returning.
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-08-19
|
||||
*/
|
||||
[[nodiscard]] std::expected<void, core::IdentityError>
|
||||
writeFmAntCap(std::uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief readDabAntCap — read the stored DAB antenna calibration byte.
|
||||
*
|
||||
* @dname readDabAntCap
|
||||
* @return Calibrated ANTCAP (0-kDabAntCapMax) if one was ever saved via
|
||||
* writeDabAntCap(), nullopt if the byte is blank/out of range,
|
||||
* or IdentityError on an I2C failure.
|
||||
* @pubstate performs one I2C read of one byte at word address 0x01.
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-08-20
|
||||
*/
|
||||
[[nodiscard]] std::expected<std::optional<std::uint8_t>, core::IdentityError>
|
||||
readDabAntCap();
|
||||
|
||||
/**
|
||||
* @brief writeDabAntCap — persist a DAB antenna calibration value.
|
||||
*
|
||||
* @dname writeDabAntCap
|
||||
* @param value ANTCAP to store, 0-kDabAntCapMax (AN649 Command
|
||||
* 0xB0 ARG4; found via a sweep, not computed).
|
||||
* @return Ok on success, or IdentityError::I2cFailed.
|
||||
* @pubstate performs one I2C byte write at word address 0x01, then
|
||||
* blocks for the chip's write-cycle time before returning.
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-08-20
|
||||
*/
|
||||
[[nodiscard]] std::expected<void, core::IdentityError>
|
||||
writeDabAntCap(std::uint8_t value);
|
||||
|
||||
private:
|
||||
i2c_master_bus_handle_t bus_;
|
||||
std::uint8_t addr7_;
|
||||
|
||||
Reference in New Issue
Block a user