ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
tas58xx.cpp
Go to the documentation of this file.
1#include "tas58xx.h"
2
3#include <cmath>
4
5#include "esphome/core/hal.h"
7#include "esphome/core/log.h"
8
9namespace esphome::tas58xx {
10
11ESPHOME_LOG_TAG(TAG, "tas58xx");
12
13static constexpr uint8_t TAS58XX_PAGE_SELECT = 0x00; // Page Select, in every book
14static constexpr uint8_t TAS58XX_BOOK_SELECT = 0x7F; // Book Select, on page 0 of every book
15static constexpr uint8_t TAS58XX_BOOK_CONTROL = 0x00;
16static constexpr uint8_t TAS58XX_PAGE_0 = 0x00;
17
18/* BOOK 0x00, PAGE 0x00 */
19static constexpr uint8_t TAS58XX_RESET_CTRL = 0x01;
20static constexpr uint8_t TAS58XX_RESET_CTRL_ALL = 0x11; // Reset DSP/control port and registers
21static constexpr uint8_t TAS58XX_DEVICE_CTRL_1 = 0x02;
22static constexpr uint8_t TAS58XX_DEVICE_CTRL_1_PBTL = (1 << 2);
23static constexpr uint8_t TAS58XX_DEVICE_CTRL_1_1SPW = 0x01; // DAMP_MOD = 01
24static constexpr uint8_t TAS58XX_DEVICE_CTRL_2 = 0x03;
25static constexpr uint8_t TAS58XX_DEVICE_CTRL_2_MUTE = (1 << 3);
26static constexpr uint8_t TAS58XX_CTRL_STATE_MASK = 0x03; // DEVICE_CTRL_2 and POWER_STATE
27static constexpr uint8_t TAS58XX_CTRL_STATE_DEEP_SLEEP = 0x00;
28static constexpr uint8_t TAS58XX_CTRL_STATE_SLEEP = 0x01;
29static constexpr uint8_t TAS58XX_CTRL_STATE_HIZ = 0x02;
30static constexpr uint8_t TAS58XX_CTRL_STATE_PLAY = 0x03;
31static constexpr uint8_t TAS58XX_CTRL_STATE_UNKNOWN = 0xFF; // Not a device value, forces the next update to act
32static constexpr uint8_t TAS58XX_DIG_VOL = 0x4C; // 0x00 = +24 dB to 0xFE = -103 dB in 0.5 dB steps, 0xFF = mute
33static constexpr uint8_t TAS58XX_DIG_VOL_0DB = 0x30;
34static constexpr uint8_t TAS58XX_DIG_VOL_MINUS_103DB = 0xFE;
35static constexpr uint8_t TAS58XX_AGAIN = 0x54; // 0x00 = 0 dB to 0x1F = -15.5 dB in 0.5 dB steps
36static constexpr uint8_t TAS58XX_AGAIN_MINUS_15_5DB = 0x1F;
37static constexpr uint8_t TAS58XX_GPIO_CTRL = 0x60; // ADR_PIN_CTRL on TAS5805M: output enable, bit n for pin n
38static constexpr uint8_t TAS58XX_GPIO0_SEL = 0x61; // ADR_PIN_CONFIG on TAS5805M: pin n is selected at 0x61 + n
39static constexpr uint8_t TAS58XX_GPIO_SEL_FAULTZ = 0x0B; // pin function: FAULTZ output
40static constexpr uint8_t TAS58XX_POWER_STATE = 0x68;
41static constexpr uint8_t TAS58XX_CHAN_FAULT = 0x70; // GLOBAL_FAULT1, GLOBAL_FAULT2 and OT_WARNING follow
42static constexpr uint8_t TAS58XX_FAULT_REGISTER_COUNT = 4;
43static constexpr uint8_t TAS58XX_FAULT_CLEAR = 0x78;
44static constexpr uint8_t TAS58XX_FAULT_CLEAR_ANALOG = 0x80;
45
46/* Input mixer, four 9.23 fixed point big endian coefficients at a location that differs per model */
47static constexpr uint8_t TAS58XX_MIXER_COEFFICIENT_SIZE = 4;
48// Only the second byte differs between mute, -6 dB and 0 dB
49static constexpr uint8_t TAS58XX_MIXER_MUTE = 0x00;
50static constexpr uint8_t TAS58XX_MIXER_MINUS_6DB = 0x40;
51static constexpr uint8_t TAS58XX_MIXER_0DB = 0x80;
52
53static constexpr uint32_t PDN_LOW_MS = 1;
54static constexpr uint32_t PDN_TO_I2C_MS = 5; // Minimum time from PDN high to I2C access
55static constexpr uint32_t RESET_SETTLE_MS = 5;
56
57static const LogString *power_state_name(uint8_t state) {
58 if (state == TAS58XX_CTRL_STATE_DEEP_SLEEP)
59 return LOG_STR("Deep sleep");
60 if (state == TAS58XX_CTRL_STATE_SLEEP)
61 return LOG_STR("Sleep");
62 if (state == TAS58XX_CTRL_STATE_HIZ)
63 return LOG_STR("Hi-Z");
64 return LOG_STR("Play");
65}
66
67// DSP coefficients can only be written while I2S clock runs, i.e. in Play (datasheet 7.5.3.1)
68static bool dsp_writable(uint8_t power_state) { return power_state == TAS58XX_CTRL_STATE_PLAY; }
69
70static const LogString *mixer_mode_name(MixerMode mixer_mode) {
71 if (mixer_mode == MIXER_MODE_STEREO_INVERSE)
72 return LOG_STR("Stereo inverse");
73 if (mixer_mode == MIXER_MODE_MONO)
74 return LOG_STR("Mono");
75 if (mixer_mode == MIXER_MODE_LEFT)
76 return LOG_STR("Left");
77 if (mixer_mode == MIXER_MODE_RIGHT)
78 return LOG_STR("Right");
79 return LOG_STR("Stereo");
80}
81
83 if (this->enable_pin_ != nullptr) {
84 this->enable_pin_->setup();
85 this->enable_pin_->digital_write(false);
86 delay(PDN_LOW_MS);
87 this->enable_pin_->digital_write(true);
88 delay(PDN_TO_I2C_MS);
89 }
90 if (!this->init_()) {
91 this->mark_failed();
92 return;
93 }
94 this->publish_active_(true); // init_() leaves the device in play
95#ifdef USE_SELECT
96 // After init, so an on_value handler acts on a ready amplifier and init does not undo it
97 this->publish_mixer_mode_();
98#endif
99}
100
101bool TAS58xx::select_book_page_(uint8_t book, uint8_t page) {
102 // The book can only be changed from page 0
103 return this->write_byte(TAS58XX_PAGE_SELECT, TAS58XX_PAGE_0) && this->write_byte(TAS58XX_BOOK_SELECT, book) &&
104 this->write_byte(TAS58XX_PAGE_SELECT, page);
105}
106
108 // Header of every TI PurePath Console export: select book 0 in case the MCU restarted without a PDN toggle,
109 // silence the output with Hi-Z, reset the DSP and the control registers, then return to Hi-Z
110 if (!this->select_book_page_(TAS58XX_BOOK_CONTROL, TAS58XX_PAGE_0) ||
111 !this->write_byte(TAS58XX_DEVICE_CTRL_2, TAS58XX_CTRL_STATE_HIZ) ||
112 !this->write_byte(TAS58XX_RESET_CTRL, TAS58XX_RESET_CTRL_ALL) ||
113 !this->write_byte(TAS58XX_DEVICE_CTRL_2, TAS58XX_CTRL_STATE_HIZ)) {
114 ESP_LOGE(TAG, "I2C write failed during reset");
115 return false;
116 }
117 delay(RESET_SETTLE_MS);
118
119 if (!this->write_registers(this->model_->startup_sequence, this->model_->startup_sequence_length)) {
120 ESP_LOGE(TAG, "I2C write failed during init");
121 return false;
122 }
123
124 // The I2C address is latched at power up, so ADR can now be an output. The pin function is written before the
125 // output enable, so the pin never drives another function.
126 if (this->fault_output_pin_ != FAULT_OUTPUT_NONE) {
127 // The setter is public, so only write this model's pins; YAML only allows the pins of the model
128 if (this->fault_output_pin_ >= this->model_->fault_output_pins) {
129 ESP_LOGW(TAG, "Invalid fault output index %u", this->fault_output_pin_);
130 } else if (!this->write_byte(TAS58XX_GPIO0_SEL + this->fault_output_pin_, TAS58XX_GPIO_SEL_FAULTZ) ||
131 !this->write_byte(TAS58XX_GPIO_CTRL, static_cast<uint8_t>(1 << this->fault_output_pin_))) {
132 ESP_LOGE(TAG, "I2C write failed during init");
133 return false;
134 }
135 }
136
137 // Setters are public, so keep the values inside the register ranges
138 const uint8_t again =
139 static_cast<uint8_t>(lroundf(clamp(-this->analog_gain_db_ * 2.0f, 0.0f, float{TAS58XX_AGAIN_MINUS_15_5DB})));
140 const uint8_t device_ctrl_1 = (this->dac_mode_ == DAC_MODE_PBTL ? TAS58XX_DEVICE_CTRL_1_PBTL : 0) |
141 (this->modulation_ == MODULATION_1SPW_MODE ? TAS58XX_DEVICE_CTRL_1_1SPW : 0);
142 if (!this->write_byte(TAS58XX_DEVICE_CTRL_1, device_ctrl_1) || !this->write_byte(TAS58XX_AGAIN, again) ||
143 !this->write_volume_() || !this->write_ctrl_state_(TAS58XX_CTRL_STATE_PLAY, this->is_muted_) ||
144 !this->write_byte(TAS58XX_FAULT_CLEAR, TAS58XX_FAULT_CLEAR_ANALOG)) {
145 ESP_LOGE(TAG, "I2C write failed during init");
146 return false;
147 }
148 // The mixer is written once the I2S clocks run, see on_audio_started() and update()
149 this->power_state_ = TAS58XX_CTRL_STATE_UNKNOWN;
150 this->mixer_written_ = false;
151 return true;
152}
153
155 if (this->is_failed())
156 return;
157 ESP_LOGD(TAG, "[0x%02X] Activating", this->address_);
158 // A failed mixer write can leave the device in another book
159 if (!this->select_book_page_(TAS58XX_BOOK_CONTROL, TAS58XX_PAGE_0)) {
160 ESP_LOGE(TAG, "Failed to select the control port");
161 return;
162 }
163 // Also the way to restart the output after a DC or over current fault
164 if (!this->write_byte(TAS58XX_FAULT_CLEAR, TAS58XX_FAULT_CLEAR_ANALOG)) {
165 ESP_LOGW(TAG, "Failed to clear faults");
166 }
167 const bool muted = this->is_muted_;
168 // Leaving deep sleep needs this sequence to reset the internal state machine, see datasheet 7.4.5
169 if (this->ctrl_state_ == TAS58XX_CTRL_STATE_DEEP_SLEEP &&
170 !(this->write_ctrl_state_(TAS58XX_CTRL_STATE_HIZ, muted) &&
171 this->write_ctrl_state_(TAS58XX_CTRL_STATE_DEEP_SLEEP, muted) &&
172 this->write_ctrl_state_(TAS58XX_CTRL_STATE_HIZ, muted))) {
173 return;
174 }
175 if (this->write_ctrl_state_(TAS58XX_CTRL_STATE_PLAY, muted))
176 this->publish_active_(true);
177}
178
180 if (this->is_failed())
181 return;
182 ESP_LOGD(TAG, "[0x%02X] Deactivating", this->address_);
183 if (!this->select_book_page_(TAS58XX_BOOK_CONTROL, TAS58XX_PAGE_0)) {
184 ESP_LOGE(TAG, "Failed to select the control port");
185 return;
186 }
187 // The DSP, and with it the mixer, stays active in deep sleep
188 if (this->write_ctrl_state_(TAS58XX_CTRL_STATE_DEEP_SLEEP, this->is_muted_))
189 this->publish_active_(false);
190}
191
192// The activate switch shows whether the device is active (play) or in deep sleep. The state is published here, not
193// by the switch, so it also follows the tas58xx.activate and tas58xx.deactivate actions, and only after the write
194// to the device succeeded.
195void TAS58xx::publish_active_(bool active) {
196#ifdef USE_SWITCH
197 PUBLISH_STATE(this->activate_switch_, active);
198#endif
199}
200
201bool TAS58xx::write_ctrl_state_(uint8_t state, bool muted) {
202 if (!this->write_byte(TAS58XX_DEVICE_CTRL_2, state | (muted ? TAS58XX_DEVICE_CTRL_2_MUTE : 0))) {
203 ESP_LOGE(TAG, "Failed to write DEVICE_CTRL_2");
204 return false;
205 }
206 this->ctrl_state_ = state;
207 return true;
208}
209
210// Returns false if the fault registers could not be read
212 uint8_t fault_registers[TAS58XX_FAULT_REGISTER_COUNT];
213 if (!this->read_bytes(TAS58XX_CHAN_FAULT, fault_registers, sizeof(fault_registers)))
214 return false;
215 uint32_t faults = 0;
216 for (uint8_t reg = 0; reg < TAS58XX_FAULT_REGISTER_COUNT; reg++)
217 faults |= uint32_t{fault_registers[reg]} << (reg * 8);
218 const ModelInfo &model = *this->model_;
219 const uint32_t active = faults & (model.fault_error_mask | model.fault_warning_mask);
220
221 // Clearing makes a lasting condition latch again on every poll, so only log changes
222 const uint32_t changed = active ^ this->logged_faults_;
223 for (uint8_t index = 0; index < 32; index++) {
224 const uint32_t mask = uint32_t{1} << index;
225 if (!(changed & mask))
226 continue;
227 const LogString *name = model.fault_name(index);
228 if (!(active & mask)) {
229 ESP_LOGI(TAG, "[0x%02X] %s cleared", this->address_, LOG_STR_ARG(name));
230 } else if (model.fault_error_mask & mask) {
231 ESP_LOGE(TAG, "[0x%02X] %s", this->address_, LOG_STR_ARG(name));
232 } else {
233 ESP_LOGW(TAG, "[0x%02X] %s", this->address_, LOG_STR_ARG(name));
234 }
235 }
236 if (changed & active & model.fault_output_off_mask) {
237 ESP_LOGW(TAG, "[0x%02X] Output stays off: fix the cause, then call tas58xx.activate or power cycle the amplifier",
238 this->address_);
239 }
240 this->logged_faults_ = active;
241
242#ifdef USE_BINARY_SENSOR
243 PUBLISH_STATE(this->have_fault_binary_sensor_, (active & model.fault_error_mask) != 0);
244 for (uint8_t fault = 0; fault < FAULT_SENSOR_COUNT; fault++) {
245 const uint8_t bit = model.fault_sensor_bits[fault];
246 if (this->fault_binary_sensors_[fault] != nullptr && bit != NO_BIT)
247 this->fault_binary_sensors_[fault]->publish_state(faults & (uint32_t{1} << bit));
248 }
249#endif
250
251 // Latched fault bits stay set after the condition is gone and only report it; clear those so the bits, and the
252 // sensors, follow the current state. The clear register resets all faults at once, so hold off while the output
253 // is off.
254 if ((faults & model.fault_latched_mask) && !(active & model.fault_output_off_mask) &&
255 !this->write_byte(TAS58XX_FAULT_CLEAR, TAS58XX_FAULT_CLEAR_ANALOG)) {
256 ESP_LOGW(TAG, "Failed to clear faults");
257 }
258 return true;
259}
260
262 // Speaker calls this once I2S clock runs, so DSP is writable
263 if (!this->is_failed())
264 this->write_dsp_();
265}
266
267bool TAS58xx::read_power_state_(uint8_t &power_state) {
268 if (!this->read_byte(TAS58XX_POWER_STATE, &power_state))
269 return false;
270 power_state &= TAS58XX_CTRL_STATE_MASK;
271 return true;
272}
273
274// DSP keeps its coefficients when clock stops, so each setting is written once after reset
276 if (!this->mixer_written_ && !this->write_mixer_()) {
277 ESP_LOGW(TAG, "Failed to write mixer");
278 }
279}
280
282 uint8_t power_state{0};
283 if (!this->status_comm_result(this->read_faults_() && this->read_power_state_(power_state),
284 LOG_STR("Failed to read status")))
285 return;
286
287 if (power_state != this->power_state_) {
288 ESP_LOGD(TAG, "[0x%02X] Power state: %s", this->address_, LOG_STR_ARG(power_state_name(power_state)));
289 this->power_state_ = power_state;
290 }
291 // Fallback for speakers that do not call on_audio_started()
292 if (dsp_writable(power_state))
293 this->write_dsp_();
294}
295
297 const LogString *fault_output;
298 if (this->fault_output_pin_ == FAULT_OUTPUT_NONE) {
299 fault_output = LOG_STR("None");
300 } else if (this->fault_output_pin_ >= this->model_->fault_output_pins) {
301 fault_output = LOG_STR("Invalid");
302 } else {
303 fault_output = this->model_->fault_output_name(this->fault_output_pin_);
304 }
305 ESP_LOGCONFIG(TAG,
306 "Audio Amplifier:\n"
307 " Model: %s",
308 LOG_STR_ARG(this->model_->name()));
309 LOG_I2C_DEVICE(this);
310 LOG_PIN(" Enable Pin: ", this->enable_pin_);
311 LOG_UPDATE_INTERVAL(this);
312 ESP_LOGCONFIG(TAG,
313 " Analog Gain: %.1f dB\n"
314 " DAC Mode: %s\n"
315 " Modulation: %s\n"
316 " Mixer Mode: %s\n"
317 " Volume Range: %.1f dB to %.1f dB\n"
318 " Fault Output: %s",
319 this->analog_gain_db_,
320 this->dac_mode_ == DAC_MODE_PBTL ? LOG_STR_LITERAL("PBTL") : LOG_STR_LITERAL("BTL"),
321 this->modulation_ == MODULATION_1SPW_MODE ? LOG_STR_LITERAL("1SPW") : LOG_STR_LITERAL("BD"),
322 LOG_STR_ARG(mixer_mode_name(this->mixer_mode_)), this->volume_min_db_, this->volume_max_db_,
323 LOG_STR_ARG(fault_output));
324#ifdef USE_BINARY_SENSOR
325 LOG_BINARY_SENSOR(" ", "Any Fault", this->have_fault_binary_sensor_);
326 for (auto *sensor : this->fault_binary_sensors_) {
327 LOG_BINARY_SENSOR(" ", "Fault", sensor);
328 }
329#endif
330#ifdef USE_SWITCH
331 LOG_SWITCH(" ", "Activate", this->activate_switch_);
332#endif
333#ifdef USE_SELECT
334 LOG_SELECT(" ", "Mixer Mode", this->mixer_mode_select_);
335#endif
336}
337
338bool TAS58xx::set_mute_(bool muted) {
339 if (!this->write_ctrl_state_(this->ctrl_state_, muted))
340 return false;
341 this->is_muted_ = muted;
342 return true;
343}
344
345bool TAS58xx::set_volume(float volume) {
346 float previous = this->volume_;
347 this->volume_ = clamp(volume, 0.0f, 1.0f);
348 if (!this->write_volume_()) {
349 this->volume_ = previous;
350 return false;
351 }
352 return true;
353}
354
356 // volume 0.0 maps to volume_min_db_, which is only close to silence at -103 dB
357 const float volume_db = std::lerp(this->volume_min_db_, this->volume_max_db_, this->volume_);
358 const uint8_t dig_vol = static_cast<uint8_t>(
359 lroundf(clamp(TAS58XX_DIG_VOL_0DB - volume_db * 2.0f, 0.0f, float{TAS58XX_DIG_VOL_MINUS_103DB})));
360 ESP_LOGV(TAG, "Setting volume to 0x%02X", dig_vol);
361 return this->write_byte(TAS58XX_DIG_VOL, dig_vol);
362}
363
364#ifdef USE_SELECT
366 if (this->mixer_mode_select_ != nullptr) {
367 // Select options start at mono for PBTL
368 const uint8_t first_mode = this->dac_mode_ == DAC_MODE_PBTL ? MIXER_MODE_MONO : MIXER_MODE_STEREO;
369 this->mixer_mode_select_->publish_state(this->mixer_mode_ - first_mode);
370 }
371}
372
373void TAS58xx::apply_mixer_mode(MixerMode mixer_mode) {
374 if (this->is_failed())
375 return;
376 // Stereo modes are invalid for PBTL
377 if (this->dac_mode_ == DAC_MODE_PBTL && mixer_mode < MIXER_MODE_MONO) {
378 ESP_LOGW(TAG, "[0x%02X] Mixer mode %s is not valid for PBTL", this->address_,
379 LOG_STR_ARG(mixer_mode_name(mixer_mode)));
380 return;
381 }
382 this->mixer_mode_ = mixer_mode;
383 this->mixer_written_ = false;
384 this->publish_mixer_mode_();
385 uint8_t power_state;
386 if (this->read_power_state_(power_state) && dsp_writable(power_state))
387 this->write_dsp_();
388}
389#endif
390
392 uint8_t left_to_left = TAS58XX_MIXER_0DB;
393 uint8_t right_to_left = TAS58XX_MIXER_MUTE;
394 uint8_t left_to_right = TAS58XX_MIXER_MUTE;
395 uint8_t right_to_right = TAS58XX_MIXER_0DB;
397 left_to_left = TAS58XX_MIXER_MUTE;
398 right_to_left = TAS58XX_MIXER_0DB;
399 left_to_right = TAS58XX_MIXER_0DB;
400 right_to_right = TAS58XX_MIXER_MUTE;
401 } else if (this->mixer_mode_ == MIXER_MODE_MONO) {
402 left_to_left = TAS58XX_MIXER_MINUS_6DB;
403 right_to_left = TAS58XX_MIXER_MINUS_6DB;
404 left_to_right = TAS58XX_MIXER_MINUS_6DB;
405 right_to_right = TAS58XX_MIXER_MINUS_6DB;
406 } else if (this->mixer_mode_ == MIXER_MODE_LEFT) {
407 left_to_right = TAS58XX_MIXER_0DB;
408 right_to_right = TAS58XX_MIXER_MUTE;
409 } else if (this->mixer_mode_ == MIXER_MODE_RIGHT) {
410 left_to_left = TAS58XX_MIXER_MUTE;
411 right_to_left = TAS58XX_MIXER_0DB;
412 }
413 const uint8_t coefficients[4 * TAS58XX_MIXER_COEFFICIENT_SIZE] = {0, left_to_left, 0, 0, 0, right_to_left, 0, 0,
414 0, left_to_right, 0, 0, 0, right_to_right, 0, 0};
415 bool ok = this->select_book_page_(this->model_->mixer_book, this->model_->mixer_page) &&
416 this->write_bytes(this->model_->mixer_register, coefficients, sizeof(coefficients));
417 // Always return to the control port, even after a failed write
418 ok = this->select_book_page_(TAS58XX_BOOK_CONTROL, TAS58XX_PAGE_0) && ok;
419 this->mixer_written_ = ok;
420 if (ok) {
421 ESP_LOGD(TAG, "[0x%02X] Mixer mode written: %s", this->address_, LOG_STR_ARG(mixer_mode_name(this->mixer_mode_)));
422 }
423 return ok;
424}
425
426} // namespace esphome::tas58xx
void mark_failed()
Mark this component as failed.
bool is_failed() const
Definition component.h:287
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
virtual void setup()=0
virtual void digital_write(bool value)=0
uint8_t address_
store the address of the device on the bus
Definition i2c.h:327
bool write_byte(uint8_t a_register, uint8_t data) const
Definition i2c.h:312
bool read_byte(uint8_t a_register, uint8_t *data)
Definition i2c.h:272
I2CRegister reg(uint8_t a_register)
calls the I2CRegister constructor
Definition i2c.h:164
bool write_bytes(uint8_t a_register, const uint8_t *data, uint8_t len) const
Definition i2c.h:298
bool read_bytes(uint8_t a_register, uint8_t *data, uint8_t len)
Compat APIs All methods below have been added for compatibility reasons.
Definition i2c.h:249
bool write_registers(const I2CRegValue *table, size_t count) const
Write each register and value of table in order, stopping at the first failure.
Definition i2c.cpp:73
binary_sensor::BinarySensor * sensor
Definition tas58xx.h:160
void publish_active_(bool active)
Publish the activate switch state, if there is one.
Definition tas58xx.cpp:195
bool set_mute_(bool muted)
Definition tas58xx.cpp:338
void write_dsp_()
Write DSP settings not written since last reset; call only while DSP is writable.
Definition tas58xx.cpp:275
const ModelInfo * model_
Definition tas58xx.h:195
std::array< binary_sensor::BinarySensor *, FAULT_SENSOR_COUNT > fault_binary_sensors_
Definition tas58xx.h:198
void publish_mixer_mode_()
Show current mixer mode on mixer mode select.
Definition tas58xx.cpp:365
void setup() override
Definition tas58xx.cpp:82
void update() override
Definition tas58xx.cpp:281
void dump_config() override
Definition tas58xx.cpp:296
bool set_volume(float volume) override
Definition tas58xx.cpp:345
bool read_power_state_(uint8_t &power_state)
Read POWER_STATE, masked to device state; false if read failed.
Definition tas58xx.cpp:267
bool write_ctrl_state_(uint8_t state, bool muted)
Definition tas58xx.cpp:201
void activate()
Clear faults, leave deep sleep and switch to play; the device waits in Hi-Z until an I2S clock is pre...
Definition tas58xx.cpp:154
void deactivate()
Switch to deep sleep, the lowest power state that keeps I2C and the DSP running.
Definition tas58xx.cpp:179
float volume() override
Definition tas58xx.h:138
void on_audio_started() override
Definition tas58xx.cpp:261
bool select_book_page_(uint8_t book, uint8_t page)
Definition tas58xx.cpp:101
bool state
Definition fan.h:2
ESPHOME_LOG_TAG(TAG, "tas58xx")
@ MIXER_MODE_STEREO_INVERSE
Definition tas58xx.h:36
void HOT delay(uint32_t ms)
Definition hal.cpp:85
static void uint32_t
Everything that differs between models of the family.
Definition tas58xx.h:84
uint8_t fault_sensor_bits[FAULT_SENSOR_COUNT]
Bit index for each FaultSensor, NO_BIT used where the model does not have that fault bit.
Definition tas58xx.h:104
uint32_t fault_output_off_mask
Faults that keep the output off until cleared by activate()
Definition tas58xx.h:99
const LogString *(* fault_name)(uint8_t index)
Definition tas58xx.h:102
uint32_t fault_warning_mask
Faults logged as warnings.
Definition tas58xx.h:97
const i2c::I2CRegValue * startup_sequence
Remainder of the startup sequence, run after the reset, as {register, value} pairs in PROGMEM.
Definition tas58xx.h:87
uint8_t mixer_book
Location of the four 9.23 fixed point input mixer coefficients: LEFT_TO_LEFT, RIGHT_TO_LEFT,...
Definition tas58xx.h:91
const LogString *(* name)()
Definition tas58xx.h:85
uint32_t fault_latched_mask
Faults that stay set after the condition is gone and are cleared after each read.
Definition tas58xx.h:101
uint8_t fault_output_pins
Number of pins that can report FAULTZ: pin n is selected at 0x61 + n and enabled by bit n of 0x60.
Definition tas58xx.h:106
uint32_t fault_error_mask
Faults logged as errors and reported by have_fault.
Definition tas58xx.h:95
const LogString *(* fault_output_name)(uint8_t pin)
Name of FAULTZ pin n, for dump_config.
Definition tas58xx.h:108