ESPHome 2025.5.0
Loading...
Searching...
No Matches
es8311_const.h
Go to the documentation of this file.
1#pragma once
2
3#include "es8311.h"
4
5namespace esphome {
6namespace es8311 {
7
8// ES8311 register addresses
9static const uint8_t ES8311_REG00_RESET = 0x00; // Reset
10static const uint8_t ES8311_REG01_CLK_MANAGER = 0x01; // Clock Manager: select clk src for mclk, enable clock for codec
11static const uint8_t ES8311_REG02_CLK_MANAGER = 0x02; // Clock Manager: clk divider and clk multiplier
12static const uint8_t ES8311_REG03_CLK_MANAGER = 0x03; // Clock Manager: adc fsmode and osr
13static const uint8_t ES8311_REG04_CLK_MANAGER = 0x04; // Clock Manager: dac osr
14static const uint8_t ES8311_REG05_CLK_MANAGER = 0x05; // Clock Manager: clk divider for adc and dac
15static const uint8_t ES8311_REG06_CLK_MANAGER = 0x06; // Clock Manager: bclk inverter BIT(5) and divider
16static const uint8_t ES8311_REG07_CLK_MANAGER = 0x07; // Clock Manager: tri-state, lrck divider
17static const uint8_t ES8311_REG08_CLK_MANAGER = 0x08; // Clock Manager: lrck divider
18static const uint8_t ES8311_REG09_SDPIN = 0x09; // Serial Digital Port: DAC
19static const uint8_t ES8311_REG0A_SDPOUT = 0x0A; // Serial Digital Port: ADC
20static const uint8_t ES8311_REG0B_SYSTEM = 0x0B; // System
21static const uint8_t ES8311_REG0C_SYSTEM = 0x0C; // System
22static const uint8_t ES8311_REG0D_SYSTEM = 0x0D; // System: power up/down
23static const uint8_t ES8311_REG0E_SYSTEM = 0x0E; // System: power up/down
24static const uint8_t ES8311_REG0F_SYSTEM = 0x0F; // System: low power
25static const uint8_t ES8311_REG10_SYSTEM = 0x10; // System
26static const uint8_t ES8311_REG11_SYSTEM = 0x11; // System
27static const uint8_t ES8311_REG12_SYSTEM = 0x12; // System: Enable DAC
28static const uint8_t ES8311_REG13_SYSTEM = 0x13; // System
29static const uint8_t ES8311_REG14_SYSTEM = 0x14; // System: select DMIC, select analog pga gain
30static const uint8_t ES8311_REG15_ADC = 0x15; // ADC: adc ramp rate, dmic sense
31static const uint8_t ES8311_REG16_ADC = 0x16; // ADC
32static const uint8_t ES8311_REG17_ADC = 0x17; // ADC: volume
33static const uint8_t ES8311_REG18_ADC = 0x18; // ADC: alc enable and winsize
34static const uint8_t ES8311_REG19_ADC = 0x19; // ADC: alc maxlevel
35static const uint8_t ES8311_REG1A_ADC = 0x1A; // ADC: alc automute
36static const uint8_t ES8311_REG1B_ADC = 0x1B; // ADC: alc automute, adc hpf s1
37static const uint8_t ES8311_REG1C_ADC = 0x1C; // ADC: equalizer, hpf s2
38static const uint8_t ES8311_REG1D_ADCEQ = 0x1D; // ADCEQ: equalizer B0
39static const uint8_t ES8311_REG1E_ADCEQ = 0x1E; // ADCEQ: equalizer B0
40static const uint8_t ES8311_REG1F_ADCEQ = 0x1F; // ADCEQ: equalizer B0
41static const uint8_t ES8311_REG20_ADCEQ = 0x20; // ADCEQ: equalizer B0
42static const uint8_t ES8311_REG21_ADCEQ = 0x21; // ADCEQ: equalizer A1
43static const uint8_t ES8311_REG22_ADCEQ = 0x22; // ADCEQ: equalizer A1
44static const uint8_t ES8311_REG23_ADCEQ = 0x23; // ADCEQ: equalizer A1
45static const uint8_t ES8311_REG24_ADCEQ = 0x24; // ADCEQ: equalizer A1
46static const uint8_t ES8311_REG25_ADCEQ = 0x25; // ADCEQ: equalizer A2
47static const uint8_t ES8311_REG26_ADCEQ = 0x26; // ADCEQ: equalizer A2
48static const uint8_t ES8311_REG27_ADCEQ = 0x27; // ADCEQ: equalizer A2
49static const uint8_t ES8311_REG28_ADCEQ = 0x28; // ADCEQ: equalizer A2
50static const uint8_t ES8311_REG29_ADCEQ = 0x29; // ADCEQ: equalizer B1
51static const uint8_t ES8311_REG2A_ADCEQ = 0x2A; // ADCEQ: equalizer B1
52static const uint8_t ES8311_REG2B_ADCEQ = 0x2B; // ADCEQ: equalizer B1
53static const uint8_t ES8311_REG2C_ADCEQ = 0x2C; // ADCEQ: equalizer B1
54static const uint8_t ES8311_REG2D_ADCEQ = 0x2D; // ADCEQ: equalizer B2
55static const uint8_t ES8311_REG2E_ADCEQ = 0x2E; // ADCEQ: equalizer B2
56static const uint8_t ES8311_REG2F_ADCEQ = 0x2F; // ADCEQ: equalizer B2
57static const uint8_t ES8311_REG30_ADCEQ = 0x30; // ADCEQ: equalizer B2
58static const uint8_t ES8311_REG31_DAC = 0x31; // DAC: mute
59static const uint8_t ES8311_REG32_DAC = 0x32; // DAC: volume
60static const uint8_t ES8311_REG33_DAC = 0x33; // DAC: offset
61static const uint8_t ES8311_REG34_DAC = 0x34; // DAC: drc enable, drc winsize
62static const uint8_t ES8311_REG35_DAC = 0x35; // DAC: drc maxlevel, minilevel
63static const uint8_t ES8311_REG36_DAC = 0x36; // DAC
64static const uint8_t ES8311_REG37_DAC = 0x37; // DAC: ramprate
65static const uint8_t ES8311_REG38_DACEQ = 0x38; // DACEQ: equalizer B0
66static const uint8_t ES8311_REG39_DACEQ = 0x39; // DACEQ: equalizer B0
67static const uint8_t ES8311_REG3A_DACEQ = 0x3A; // DACEQ: equalizer B0
68static const uint8_t ES8311_REG3B_DACEQ = 0x3B; // DACEQ: equalizer B0
69static const uint8_t ES8311_REG3C_DACEQ = 0x3C; // DACEQ: equalizer B1
70static const uint8_t ES8311_REG3D_DACEQ = 0x3D; // DACEQ: equalizer B1
71static const uint8_t ES8311_REG3E_DACEQ = 0x3E; // DACEQ: equalizer B1
72static const uint8_t ES8311_REG3F_DACEQ = 0x3F; // DACEQ: equalizer B1
73static const uint8_t ES8311_REG40_DACEQ = 0x40; // DACEQ: equalizer A1
74static const uint8_t ES8311_REG41_DACEQ = 0x41; // DACEQ: equalizer A1
75static const uint8_t ES8311_REG42_DACEQ = 0x42; // DACEQ: equalizer A1
76static const uint8_t ES8311_REG43_DACEQ = 0x43; // DACEQ: equalizer A1
77static const uint8_t ES8311_REG44_GPIO = 0x44; // GPIO: dac2adc for test
78static const uint8_t ES8311_REG45_GP = 0x45; // GPIO: GP control
79static const uint8_t ES8311_REGFA_I2C = 0xFA; // I2C: reset registers
80static const uint8_t ES8311_REGFC_FLAG = 0xFC; // Flag
81static const uint8_t ES8311_REGFD_CHD1 = 0xFD; // Chip: ID1
82static const uint8_t ES8311_REGFE_CHD2 = 0xFE; // Chip: ID2
83static const uint8_t ES8311_REGFF_CHVER = 0xFF; // Chip: Version
84
85// ES8311 clock divider coefficients
86static const ES8311Coefficient ES8311_COEFFICIENTS[] = {
87 // clang-format off
88
89 // mclk, rate, pre_ pre_ adc_ dac_ fs_ lrck lrck bclk_ adc_ dac_
90 // div, mult, div, div, mode, _h, _l, div, osr, osr
91
92 // 8k
93 {12288000, 8000, 0x06, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
94 {18432000, 8000, 0x03, 0x02, 0x03, 0x03, 0x00, 0x05, 0xff, 0x18, 0x10, 0x20},
95 {16384000, 8000, 0x08, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
96 { 8192000, 8000, 0x04, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
97 { 6144000, 8000, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
98 { 4096000, 8000, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
99 { 3072000, 8000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
100 { 2048000, 8000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
101 { 1536000, 8000, 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
102 { 1024000, 8000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
103
104 // 11.025k
105 {11289600, 11025, 0x04, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
106 { 5644800, 11025, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
107 { 2822400, 11025, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
108 { 1411200, 11025, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
109
110 // 12k
111 {12288000, 12000, 0x04, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
112 { 6144000, 12000, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
113 { 3072000, 12000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
114 { 1536000, 12000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
115
116 // 16k
117 {12288000, 16000, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
118 {18432000, 16000, 0x03, 0x02, 0x03, 0x03, 0x00, 0x02, 0xff, 0x0c, 0x10, 0x20},
119 {16384000, 16000, 0x04, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
120 { 8192000, 16000, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
121 { 6144000, 16000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
122 { 4096000, 16000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
123 { 3072000, 16000, 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
124 { 2048000, 16000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
125 { 1536000, 16000, 0x03, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
126 { 1024000, 16000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x20},
127
128 // 22.05k
129 {11289600, 22050, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
130 { 5644800, 22050, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
131 { 2822400, 22050, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
132 { 1411200, 22050, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
133
134 // 24k
135 {12288000, 24000, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
136 {18432000, 24000, 0x03, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
137 { 6144000, 24000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
138 { 3072000, 24000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
139 { 1536000, 24000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
140
141 // 32k
142 {12288000, 32000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
143 {18432000, 32000, 0x03, 0x04, 0x03, 0x03, 0x00, 0x02, 0xff, 0x0c, 0x10, 0x10},
144 {16384000, 32000, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
145 { 8192000, 32000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
146 { 6144000, 32000, 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
147 { 4096000, 32000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
148 { 3072000, 32000, 0x03, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
149 { 2048000, 32000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
150 { 1536000, 32000, 0x03, 0x08, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
151 { 1024000, 32000, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
152
153 // 44.1k
154 {11289600, 44100, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
155 { 5644800, 44100, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
156 { 2822400, 44100, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
157 { 1411200, 44100, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
158
159 // 48k
160 {12288000, 48000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
161 {18432000, 48000, 0x03, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
162 { 6144000, 48000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
163 { 3072000, 48000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
164 { 1536000, 48000, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
165
166 // 64k
167 {12288000, 64000, 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
168 {18432000, 64000, 0x03, 0x04, 0x03, 0x03, 0x01, 0x01, 0x7f, 0x06, 0x10, 0x10},
169 {16384000, 64000, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
170 { 8192000, 64000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
171 { 6144000, 64000, 0x01, 0x04, 0x03, 0x03, 0x01, 0x01, 0x7f, 0x06, 0x10, 0x10},
172 { 4096000, 64000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
173 { 3072000, 64000, 0x01, 0x08, 0x03, 0x03, 0x01, 0x01, 0x7f, 0x06, 0x10, 0x10},
174 { 2048000, 64000, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
175 { 1536000, 64000, 0x01, 0x08, 0x01, 0x01, 0x01, 0x00, 0xbf, 0x03, 0x18, 0x18},
176 { 1024000, 64000, 0x01, 0x08, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
177
178 // 88.2k
179 {11289600, 88200, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
180 { 5644800, 88200, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
181 { 2822400, 88200, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
182 { 1411200, 88200, 0x01, 0x08, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
183
184 // 96k
185 {12288000, 96000, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
186 {18432000, 96000, 0x03, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
187 { 6144000, 96000, 0x01, 0x04, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
188 { 3072000, 96000, 0x01, 0x08, 0x01, 0x01, 0x00, 0x00, 0xff, 0x04, 0x10, 0x10},
189 { 1536000, 96000, 0x01, 0x08, 0x01, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x10, 0x10},
190
191 // clang-format on
192};
193
194} // namespace es8311
195} // namespace esphome
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7