ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
es7210_const.h
Go to the documentation of this file.
1#pragma once
2
3#include <cinttypes>
4
5namespace esphome::es7210 {
6
7// ES7210 register addresses
8static const uint8_t ES7210_RESET_REG00 = 0x00; /* Reset control */
9static const uint8_t ES7210_CLOCK_OFF_REG01 = 0x01; /* Used to turn off the ADC clock */
10static const uint8_t ES7210_MAINCLK_REG02 = 0x02; /* Set ADC clock frequency division */
11
12static const uint8_t ES7210_MASTER_CLK_REG03 = 0x03; /* MCLK source $ SCLK division */
13static const uint8_t ES7210_LRCK_DIVH_REG04 = 0x04; /* lrck_divh */
14static const uint8_t ES7210_LRCK_DIVL_REG05 = 0x05; /* lrck_divl */
15static const uint8_t ES7210_POWER_DOWN_REG06 = 0x06; /* power down */
16static const uint8_t ES7210_OSR_REG07 = 0x07;
17static const uint8_t ES7210_MODE_CONFIG_REG08 = 0x08; /* Set primary/secondary & channels */
18static const uint8_t ES7210_TIME_CONTROL0_REG09 = 0x09; /* Set Chip intial state period*/
19static const uint8_t ES7210_TIME_CONTROL1_REG0A = 0x0A; /* Set Power up state period */
20static const uint8_t ES7210_SDP_INTERFACE1_REG11 = 0x11; /* Set sample & fmt */
21static const uint8_t ES7210_SDP_INTERFACE2_REG12 = 0x12; /* Pins state */
22static const uint8_t ES7210_ADC_AUTOMUTE_REG13 = 0x13; /* Set mute */
23static const uint8_t ES7210_ADC34_MUTERANGE_REG14 = 0x14; /* Set mute range */
24static const uint8_t ES7210_ADC12_MUTERANGE_REG15 = 0x15; /* Set mute range */
25static const uint8_t ES7210_ADC34_HPF2_REG20 = 0x20; /* HPF */
26static const uint8_t ES7210_ADC34_HPF1_REG21 = 0x21; /* HPF */
27static const uint8_t ES7210_ADC12_HPF1_REG22 = 0x22; /* HPF */
28static const uint8_t ES7210_ADC12_HPF2_REG23 = 0x23; /* HPF */
29static const uint8_t ES7210_ANALOG_REG40 = 0x40; /* ANALOG Power */
30static const uint8_t ES7210_MIC12_BIAS_REG41 = 0x41;
31static const uint8_t ES7210_MIC34_BIAS_REG42 = 0x42;
32static const uint8_t ES7210_MIC1_GAIN_REG43 = 0x43;
33static const uint8_t ES7210_MIC2_GAIN_REG44 = 0x44;
34static const uint8_t ES7210_MIC3_GAIN_REG45 = 0x45;
35static const uint8_t ES7210_MIC4_GAIN_REG46 = 0x46;
36static const uint8_t ES7210_MIC1_POWER_REG47 = 0x47;
37static const uint8_t ES7210_MIC2_POWER_REG48 = 0x48;
38static const uint8_t ES7210_MIC3_POWER_REG49 = 0x49;
39static const uint8_t ES7210_MIC4_POWER_REG4A = 0x4A;
40static const uint8_t ES7210_MIC12_POWER_REG4B = 0x4B; /* MICBias & ADC & PGA Power */
41static const uint8_t ES7210_MIC34_POWER_REG4C = 0x4C;
42
43/*
44 * Clock coefficient structure
45 */
47 uint32_t mclk; // mclk frequency
49 uint8_t ss_ds;
50 uint8_t adc_div;
51 uint8_t dll; // dll_bypass
52 uint8_t doubler; // doubler_enable
53 uint8_t osr; // adc osr
54 uint8_t mclk_src; // sselect mclk source
55 uint8_t lrck_h; // High 4 bits of lrck
56 uint8_t lrck_l; // Low 8 bits of lrck
57};
58
59/* Codec hifi mclk clock divider coefficients
60 * MEMBER REG
61 * mclk: 0x03
62 * lrck: standard
63 * ss_ds: --
64 * adc_div: 0x02
65 * dll: 0x06
66 * doubler: 0x02
67 * osr: 0x07
68 * mclk_src: 0x03
69 * lrckh: 0x04
70 * lrckl: 0x05
71 */
72static const ES7210Coefficient ES7210_COEFFICIENTS[] = {
73 // mclk lrck ss_ds adc_div dll doubler osr mclk_src lrckh lrckl
74 /* 8k */
75 {12288000, 8000, 0x00, 0x03, 0x01, 0x00, 0x20, 0x00, 0x06, 0x00},
76 {16384000, 8000, 0x00, 0x04, 0x01, 0x00, 0x20, 0x00, 0x08, 0x00},
77 {19200000, 8000, 0x00, 0x1e, 0x00, 0x01, 0x28, 0x00, 0x09, 0x60},
78 {4096000, 8000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
79
80 /* 11.025k */
81 {11289600, 11025, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
82
83 /* 12k */
84 {12288000, 12000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
85 {19200000, 12000, 0x00, 0x14, 0x00, 0x01, 0x28, 0x00, 0x06, 0x40},
86
87 /* 16k */
88 {4096000, 16000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
89 {19200000, 16000, 0x00, 0x0a, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x80},
90 {16384000, 16000, 0x00, 0x02, 0x01, 0x00, 0x20, 0x00, 0x04, 0x00},
91 {12288000, 16000, 0x00, 0x03, 0x01, 0x01, 0x20, 0x00, 0x03, 0x00},
92
93 /* 22.05k */
94 {11289600, 22050, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
95
96 /* 24k */
97 {12288000, 24000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
98 {19200000, 24000, 0x00, 0x0a, 0x00, 0x01, 0x28, 0x00, 0x03, 0x20},
99
100 /* 32k */
101 {12288000, 32000, 0x00, 0x03, 0x00, 0x00, 0x20, 0x00, 0x01, 0x80},
102 {16384000, 32000, 0x00, 0x01, 0x01, 0x00, 0x20, 0x00, 0x02, 0x00},
103 {19200000, 32000, 0x00, 0x05, 0x00, 0x00, 0x1e, 0x00, 0x02, 0x58},
104
105 /* 44.1k */
106 {11289600, 44100, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
107
108 /* 48k */
109 {12288000, 48000, 0x00, 0x01, 0x01, 0x01, 0x20, 0x00, 0x01, 0x00},
110 {19200000, 48000, 0x00, 0x05, 0x00, 0x01, 0x28, 0x00, 0x01, 0x90},
111
112 /* 64k */
113 {16384000, 64000, 0x01, 0x01, 0x01, 0x00, 0x20, 0x00, 0x01, 0x00},
114 {19200000, 64000, 0x00, 0x05, 0x00, 0x01, 0x1e, 0x00, 0x01, 0x2c},
115
116 /* 88.2k */
117 {11289600, 88200, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
118
119 /* 96k */
120 {12288000, 96000, 0x01, 0x01, 0x01, 0x01, 0x20, 0x00, 0x00, 0x80},
121 {19200000, 96000, 0x01, 0x05, 0x00, 0x01, 0x28, 0x00, 0x00, 0xc8},
122};
123
124static const float ES7210_MIC_GAIN_MIN = 0.0;
125static const float ES7210_MIC_GAIN_MAX = 37.5;
126
127} // namespace esphome::es7210
static void uint32_t