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