TB2026-YDS Firmware
Loading...
Searching...
No Matches
sink_i2s_dac.c File Reference
#include "audio_sink.h"
#include "audio_dac.h"
#include "sink_i2s_dac.h"
#include "gpio_expander.h"
#include "board_pins.h"
#include "i2s_bus.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"

Functions

esp_err_t sink_i2s_dac_output_enable (bool enable)
 Enable or mute the DAC analog output via the PCM5242 XSMT pin.
esp_err_t sink_i2s_dac_amp_enable (bool enable)
 Enable or shut down the MAX97220 headphone amplifier via its SHDN pin.
esp_err_t sink_i2s_dac_init (void)
 Bring up the wired path's I2S bus; the sink owns the channel handle.
const audio_sink_tsink_i2s_dac_get (void)
 Get the wired-DAC sink (I2S → PCM5242 → MAX97220 → jack).

Detailed Description

Note
Développé avec l'assistance de Claude Opus 4.8 (Anthropic), sous la direction de Y. Dos Santos : spécification, revue et validation sur cible par l'auteur.

Function Documentation

◆ sink_i2s_dac_amp_enable()

esp_err_t sink_i2s_dac_amp_enable ( bool enable)

Enable or shut down the MAX97220 headphone amplifier via its SHDN pin.

SHDN is expander IO1, active-low. Requires gpio_expander_init() to have run first.

Parameters
enabletrue = drive SHDN high (amp on), false = SHDN low (shutdown).
Returns
ESP_OK on success, or the expander I2C error.

◆ sink_i2s_dac_get()

const audio_sink_t * sink_i2s_dac_get ( void )

Get the wired-DAC sink (I2S → PCM5242 → MAX97220 → jack).

Returns
Pointer to the static sink vtable (never NULL). Requires sink_i2s_dac_init().

◆ sink_i2s_dac_init()

esp_err_t sink_i2s_dac_init ( void )

Bring up the wired path's I2S bus; the sink owns the channel handle.

Mounts I2S0 (BCK/WS/DOUT, no MCLK) and keeps the TX handle inside the sink, so upper layers never touch it. Call once at startup. The PCM5242 I2C control port and the expander mute/amp lines are initialised by their own drivers (audio_dac_init, gpio_expander_init), not here.

Returns
ESP_OK on success, or the I2S driver error.

◆ sink_i2s_dac_output_enable()

esp_err_t sink_i2s_dac_output_enable ( bool enable)

Enable or mute the DAC analog output via the PCM5242 XSMT pin.

XSMT is expander IO0, active-low. Requires gpio_expander_init() to have run first.

Parameters
enabletrue = drive XSMT high (output on), false = XSMT low (muted).
Returns
ESP_OK on success, or the expander I2C error.