Files
DigiRadio/Software/Firmware/ADAU1701-Firmware/SigmaStudioFW.h
T
micheleandClaude Sonnet 5 6f7b6dd12c Add internet radio streaming with runtime API, modernize web UI, remove auto-tune/beep at boot
Streaming (main feature this session):
- New WebRadioConfig/WebRadioJson core types, ISecureStore-backed persistence
- New webradio::WebRadioService (thread-safe live config) + GET/POST /api/streaming
- web_radio_stream task now runtime-toggleable (no reboot), no hardcoded URL
- Content-Type diagnostic: warns clearly when a URL is a webpage, not an audio stream

Boot cleanup:
- Removed boot-time auto FM/DAB tune, auto-beep, and the (now-concluded) Si4684
  crystal IBIAS/CTUN empirical sweep from main.cpp — tuning/beep are on-demand
  via the existing REST API only

Web UI:
- Modernized styling (cards, gradients, toggle switches, light/dark theme)
- New Stream tab wired to /api/streaming

Fixes found via real idf.py build (not just clangd):
- Restored wrongly-removed si4684/Si4684Tuner.hpp include in main.cpp
- Fixed MP3Decode() argument types in web_radio_stream.cpp (unsigned char**/int*)

Quality-gate fixes:
- Host-test stub headers (esp_log.h, freertos/*) so TunerService.cpp's
  scanForStation logging/pacing compiles for station_service_test /
  integration_service_test instead of running stale binaries
- Added WifiScanner and WebRadioService manual sections; filled in missing
  Doxygen docs on BluetoothService, i2s_sdata_probe, test_firmware, Bt1035At
- Ignore clangd's .cache/ index directory

Also includes prior uncommitted work carried in the tree: Wi-Fi/Bluetooth
device scan REST API and UI (WifiScanner, BT scan), SigmaStudio TCP bridge,
and the current ADAU1701 SigmaStudio DSP program export.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-08 21:15:22 +02:00

120 lines
4.1 KiB
C

/**
* @file SigmaStudioFW.h
* @brief Minimal SigmaStudio download helpers for ADAU1701 RAM boot.
*
* DigiRadio firmware — https://github.com/manvalan/DigiRadio
*
* Copyright 2026 Michele Bigi
* SPDX-License-Identifier: Apache-2.0
*
* Subset of the Analog Devices SigmaStudio export support library.
*
* @author Michele Bigi
* @date 2026-07-06
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned char ADI_REG_TYPE;
/**
* @brief Bind the I2C port used by SIGMA_WRITE_REGISTER_BLOCK.
*
* @param port ESP-IDF I2C master port number.
* @param addr7 ADAU1701 7-bit I2C address (0x34 on DigiRadio).
*/
void sigma_studio_bind_i2c(int port, unsigned char addr7);
/** @brief Attach the I2C device handle created by Adau1701Driver. */
void sigma_studio_set_device(void* i2cDevHandle);
/**
* @brief Acquire the process-wide ADAU1701 I2C lock.
*
* Guards a logical multi-transaction operation (e.g. a safeload burst)
* against interleaving from another FreeRTOS task — individual
* i2c_master_transmit calls are already serialised by the ESP-IDF I2C
* driver, but a sequence of several transactions is not atomic without
* this. Callers: Adau1701Driver safeload paths and the SigmaStudio TCP
* bridge (components/net/SigmaStudioTcpServer).
*/
void sigma_studio_lock(void);
/** @brief Release the lock acquired by sigma_studio_lock(). */
void sigma_studio_unlock(void);
/**
* @brief Write a contiguous register/data block to the ADAU1701.
*
* @param devAddress SigmaStudio device address (0x68 write addr).
* @param address 16-bit target address in DSP memory map.
* @param length Payload length in bytes (may exceed 255).
* @param pData Payload bytes.
*/
void SIGMA_WRITE_REGISTER_BLOCK(unsigned char devAddress,
unsigned int address,
unsigned int length,
ADI_REG_TYPE* pData);
/**
* @brief Read a contiguous register/data block from the ADAU1701.
*
* @param reg 16-bit source address in DSP memory map.
* @param data Destination buffer.
* @param length Number of bytes to read.
* @return 0 on success, non-zero on I2C failure.
*/
int sigma_i2c_read(unsigned int reg, unsigned char* data, unsigned int length);
/** Safeload data register base (0x0810..0x0814). */
#define ADAU1701_SAFELOAD_DATA_BASE 0x0810U
/** Safeload address register base (0x0815..0x0819). */
#define ADAU1701_SAFELOAD_ADDR_BASE 0x0815U
/** DSP core control register (IST bit triggers safeload). */
#define ADAU1701_CORE_CONTROL_REG 0x081CU
/** IST bit value OR-ed into core control to commit safeload. */
#define ADAU1701_CORE_IST_TRIGGER 0x003CU
/**
* @brief Safeload one 8.23 fixpoint parameter (click-free update).
*
* @param paramAddr Parameter RAM address from DigiRadio_IC_1_PARAM.h.
* @param fixpoint 32-bit SigmaStudio fixpoint value.
* @return 0 on success, non-zero on I2C failure.
*/
int sigma_safeload_param(unsigned int paramAddr, int fixpoint);
/**
* @brief Safeload up to five parameters in one IST transfer (e.g. biquad).
*
* @param count Number of pairs (1..5).
* @param paramAddrs Parameter RAM addresses.
* @param fixpoints 32-bit fixpoint values.
* @return 0 on success, non-zero on I2C failure.
*/
int sigma_safeload_block(unsigned char count, const unsigned int* paramAddrs,
const int* fixpoints);
/**
* @brief Safeload up to five parameters from raw wire bytes (pass-through).
*
* Used by the SigmaStudio TCP bridge: unlike sigma_safeload_block(), which
* reconstructs the 4-byte payload from a host int, this forwards each
* 4-byte word exactly as received over the network — no endianness
* reinterpretation.
*
* @param count Number of words (1..5).
* @param paramAddrs Parameter RAM addresses.
* @param rawWords count*4 raw bytes, one 4-byte word per address.
* @return 0 on success, non-zero on I2C failure.
*/
int sigma_safeload_raw_block(unsigned char count, const unsigned int* paramAddrs,
const unsigned char* rawWords);
#ifdef __cplusplus
}
#endif