ESPHome 2025.5.0
Loading...
Searching...
No Matches
aic3204.h
Go to the documentation of this file.
1#pragma once
2
7#include "esphome/core/hal.h"
8
9namespace esphome {
10namespace aic3204 {
11
12// TLV320AIC3204 Register Addresses
13// Page 0
14static const uint8_t AIC3204_PAGE_CTRL = 0x00; // Register 0 - Page Control
15static const uint8_t AIC3204_SW_RST = 0x01; // Register 1 - Software Reset
16static const uint8_t AIC3204_CLK_PLL1 = 0x04; // Register 4 - Clock Setting Register 1, Multiplexers
17static const uint8_t AIC3204_CLK_PLL2 = 0x05; // Register 5 - Clock Setting Register 2, P and R values
18static const uint8_t AIC3204_CLK_PLL3 = 0x06; // Register 6 - Clock Setting Register 3, J values
19static const uint8_t AIC3204_NDAC = 0x0B; // Register 11 - NDAC Divider Value
20static const uint8_t AIC3204_MDAC = 0x0C; // Register 12 - MDAC Divider Value
21static const uint8_t AIC3204_DOSR = 0x0E; // Register 14 - DOSR Divider Value (LS Byte)
22static const uint8_t AIC3204_NADC = 0x12; // Register 18 - NADC Divider Value
23static const uint8_t AIC3204_MADC = 0x13; // Register 19 - MADC Divider Value
24static const uint8_t AIC3204_AOSR = 0x14; // Register 20 - AOSR Divider Value
25static const uint8_t AIC3204_CODEC_IF = 0x1B; // Register 27 - CODEC Interface Control
26static const uint8_t AIC3204_AUDIO_IF_4 = 0x1F; // Register 31 - Audio Interface Setting Register 4
27static const uint8_t AIC3204_AUDIO_IF_5 = 0x20; // Register 32 - Audio Interface Setting Register 5
28static const uint8_t AIC3204_SCLK_MFP3 = 0x38; // Register 56 - SCLK/MFP3 Function Control
29static const uint8_t AIC3204_DAC_SIG_PROC = 0x3C; // Register 60 - DAC Sig Processing Block Control
30static const uint8_t AIC3204_ADC_SIG_PROC = 0x3D; // Register 61 - ADC Sig Processing Block Control
31static const uint8_t AIC3204_DAC_CH_SET1 = 0x3F; // Register 63 - DAC Channel Setup 1
32static const uint8_t AIC3204_DAC_CH_SET2 = 0x40; // Register 64 - DAC Channel Setup 2
33static const uint8_t AIC3204_DACL_VOL_D = 0x41; // Register 65 - DAC Left Digital Vol Control
34static const uint8_t AIC3204_DACR_VOL_D = 0x42; // Register 66 - DAC Right Digital Vol Control
35static const uint8_t AIC3204_DRC_ENABLE = 0x44;
36static const uint8_t AIC3204_ADC_CH_SET = 0x51; // Register 81 - ADC Channel Setup
37static const uint8_t AIC3204_ADC_FGA_MUTE = 0x52; // Register 82 - ADC Fine Gain Adjust/Mute
38
39// Page 1
40static const uint8_t AIC3204_PWR_CFG = 0x01; // Register 1 - Power Config
41static const uint8_t AIC3204_LDO_CTRL = 0x02; // Register 2 - LDO Control
42static const uint8_t AIC3204_PLAY_CFG1 = 0x03; // Register 3 - Playback Config 1
43static const uint8_t AIC3204_PLAY_CFG2 = 0x04; // Register 4 - Playback Config 2
44static const uint8_t AIC3204_OP_PWR_CTRL = 0x09; // Register 9 - Output Driver Power Control
45static const uint8_t AIC3204_CM_CTRL = 0x0A; // Register 10 - Common Mode Control
46static const uint8_t AIC3204_HPL_ROUTE = 0x0C; // Register 12 - HPL Routing Select
47static const uint8_t AIC3204_HPR_ROUTE = 0x0D; // Register 13 - HPR Routing Select
48static const uint8_t AIC3204_LOL_ROUTE = 0x0E; // Register 14 - LOL Routing Selection
49static const uint8_t AIC3204_LOR_ROUTE = 0x0F; // Register 15 - LOR Routing Selection
50static const uint8_t AIC3204_HPL_GAIN = 0x10; // Register 16 - HPL Driver Gain
51static const uint8_t AIC3204_HPR_GAIN = 0x11; // Register 17 - HPR Driver Gain
52static const uint8_t AIC3204_LOL_DRV_GAIN = 0x12; // Register 18 - LOL Driver Gain Setting
53static const uint8_t AIC3204_LOR_DRV_GAIN = 0x13; // Register 19 - LOR Driver Gain Setting
54static const uint8_t AIC3204_HP_START = 0x14; // Register 20 - Headphone Driver Startup
55static const uint8_t AIC3204_LPGA_P_ROUTE = 0x34; // Register 52 - Left PGA Positive Input Route
56static const uint8_t AIC3204_LPGA_N_ROUTE = 0x36; // Register 54 - Left PGA Negative Input Route
57static const uint8_t AIC3204_RPGA_P_ROUTE = 0x37; // Register 55 - Right PGA Positive Input Route
58static const uint8_t AIC3204_RPGA_N_ROUTE = 0x39; // Register 57 - Right PGA Negative Input Route
59static const uint8_t AIC3204_LPGA_VOL = 0x3B; // Register 59 - Left PGA Volume
60static const uint8_t AIC3204_RPGA_VOL = 0x3C; // Register 60 - Right PGA Volume
61static const uint8_t AIC3204_ADC_PTM = 0x3D; // Register 61 - ADC Power Tune Config
62static const uint8_t AIC3204_AN_IN_CHRG = 0x47; // Register 71 - Analog Input Quick Charging Config
63static const uint8_t AIC3204_REF_STARTUP = 0x7B; // Register 123 - Reference Power Up Config
64
65class AIC3204 : public audio_dac::AudioDac, public Component, public i2c::I2CDevice {
66 public:
67 void setup() override;
68 void dump_config() override;
69 float get_setup_priority() const override { return setup_priority::DATA; }
70
71 bool set_mute_off() override;
72 bool set_mute_on() override;
73 bool set_auto_mute_mode(uint8_t auto_mute_mode);
74 bool set_volume(float volume) override;
75
76 bool is_muted() override;
77 float volume() override;
78
79 protected:
80 bool write_mute_();
81 bool write_volume_();
82
83 uint8_t auto_mute_mode_{0};
84 float volume_{0};
85};
86
87} // namespace aic3204
88} // namespace esphome
float get_setup_priority() const override
Definition aic3204.h:69
bool set_volume(float volume) override
Definition aic3204.cpp:136
bool is_muted() override
Definition aic3204.cpp:141
void dump_config() override
Definition aic3204.cpp:111
bool set_auto_mute_mode(uint8_t auto_mute_mode)
Definition aic3204.cpp:130
bool set_mute_off() override
Definition aic3204.cpp:120
bool set_mute_on() override
Definition aic3204.cpp:125
float volume() override
Definition aic3204.cpp:143
void setup() override
Definition aic3204.cpp:19
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
const float DATA
For components that import data from directly connected sensors like DHT.
Definition component.cpp:19
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7