ESPHome 2025.9.0-dev
Loading...
Searching...
No Matches
es7210.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "es7210_const.h"
8
9namespace esphome {
10namespace es7210 {
11
19
20class ES7210 : public audio_adc::AudioAdc, public Component, public i2c::I2CDevice {
21 /* Class for configuring an ES7210 ADC for microphone input.
22 * Based on code from:
23 * - https://github.com/espressif/esp-bsp/ (accessed 20241219)
24 * - https://github.com/espressif/esp-adf/ (accessed 20241219)
25 */
26 public:
27 void setup() override;
28 void dump_config() override;
29
30 void set_bits_per_sample(ES7210BitsPerSample bits_per_sample) { this->bits_per_sample_ = bits_per_sample; }
31 bool set_mic_gain(float mic_gain) override;
32 void set_sample_rate(uint32_t sample_rate) { this->sample_rate_ = sample_rate; }
33
34 float mic_gain() override { return this->mic_gain_; };
35
36 protected:
42 bool es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data);
43
47 uint8_t es7210_gain_reg_value_(float mic_gain);
48
52
53 bool setup_complete_{false};
54 bool enable_tdm_{false}; // TDM is unsupported in ESPHome as of version 2024.12
55 float mic_gain_{0};
57 uint32_t sample_rate_{0};
58};
59
60} // namespace es7210
61} // namespace esphome
bool configure_sample_rate_()
Definition es7210.cpp:99
uint8_t es7210_gain_reg_value_(float mic_gain)
Convert floating point mic gain value to register value.
Definition es7210.cpp:171
float mic_gain() override
Definition es7210.h:34
bool es7210_update_reg_bit_(uint8_t reg_addr, uint8_t update_bits, uint8_t data)
Updates an I2C registry address by modifying the current state.
Definition es7210.cpp:220
void setup() override
Definition es7210.cpp:40
void dump_config() override
Definition es7210.cpp:27
uint32_t sample_rate_
Definition es7210.h:57
bool set_mic_gain(float mic_gain) override
Definition es7210.cpp:91
void set_bits_per_sample(ES7210BitsPerSample bits_per_sample)
Definition es7210.h:30
ES7210BitsPerSample bits_per_sample_
Definition es7210.h:56
void set_sample_rate(uint32_t sample_rate)
Definition es7210.h:32
This Class provides the methods to read/write bytes from/to an i2c device.
Definition i2c.h:133
@ ES7210_BITS_PER_SAMPLE_20
Definition es7210.h:15
@ ES7210_BITS_PER_SAMPLE_18
Definition es7210.h:14
@ ES7210_BITS_PER_SAMPLE_16
Definition es7210.h:13
@ ES7210_BITS_PER_SAMPLE_32
Definition es7210.h:17
@ ES7210_BITS_PER_SAMPLE_24
Definition es7210.h:16
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7