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