ESPHome 2026.12.0-dev
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 pulse_reset(this->enable_pin_, {.low_ms = PDN_LOW_MS, .high_after_ms = PDN_TO_I2C_MS});
84 if (!this->setup_check(this->init_()))
85 return;
86 this->publish_active_(true); // init_() leaves the device in play
87#ifdef USE_SELECT
88 // After init, so an on_value handler acts on a ready amplifier and init does not undo it
89 this->publish_mixer_mode_();
90#endif
91}
92
93bool TAS58xx::select_book_page_(uint8_t book, uint8_t page) {
94 // The book can only be changed from page 0
95 return this->write_byte(TAS58XX_PAGE_SELECT, TAS58XX_PAGE_0) && this->write_byte(TAS58XX_BOOK_SELECT, book) &&
96 this->write_byte(TAS58XX_PAGE_SELECT, page);
97}
98
100 // Header of every TI PurePath Console export: select book 0 in case the MCU restarted without a PDN toggle,
101 // silence the output with Hi-Z, reset the DSP and the control registers, then return to Hi-Z
102 if (!this->select_book_page_(TAS58XX_BOOK_CONTROL, TAS58XX_PAGE_0) ||
103 !this->write_byte(TAS58XX_DEVICE_CTRL_2, TAS58XX_CTRL_STATE_HIZ) ||
104 !this->write_byte(TAS58XX_RESET_CTRL, TAS58XX_RESET_CTRL_ALL) ||
105 !this->write_byte(TAS58XX_DEVICE_CTRL_2, TAS58XX_CTRL_STATE_HIZ)) {
106 ESP_LOGE(TAG, "I2C write failed during reset");
107 return false;
108 }
109 delay(RESET_SETTLE_MS);
110
111 if (!this->write_registers(this->model_->startup_sequence, this->model_->startup_sequence_length)) {
112 ESP_LOGE(TAG, "I2C write failed during init");
113 return false;
114 }
115
116 // The I2C address is latched at power up, so ADR can now be an output. The pin function is written before the
117 // output enable, so the pin never drives another function.
118 if (this->fault_output_pin_ != FAULT_OUTPUT_NONE) {
119 // The setter is public, so only write this model's pins; YAML only allows the pins of the model
120 if (this->fault_output_pin_ >= this->model_->fault_output_pins) {
121 ESP_LOGW(TAG, "Invalid fault output index %u", this->fault_output_pin_);
122 } else if (!this->write_byte(TAS58XX_GPIO0_SEL + this->fault_output_pin_, TAS58XX_GPIO_SEL_FAULTZ) ||
123 !this->write_byte(TAS58XX_GPIO_CTRL, static_cast<uint8_t>(1 << this->fault_output_pin_))) {
124 ESP_LOGE(TAG, "I2C write failed during init");
125 return false;
126 }
127 }
128
129 // Setters are public, so keep the values inside the register ranges
130 const uint8_t again =
131 static_cast<uint8_t>(lroundf(clamp(-this->analog_gain_db_ * 2.0f, 0.0f, float{TAS58XX_AGAIN_MINUS_15_5DB})));
132 const uint8_t device_ctrl_1 = (this->dac_mode_ == DAC_MODE_PBTL ? TAS58XX_DEVICE_CTRL_1_PBTL : 0) |
133 (this->modulation_ == MODULATION_1SPW_MODE ? TAS58XX_DEVICE_CTRL_1_1SPW : 0);
134 if (!this->write_byte(TAS58XX_DEVICE_CTRL_1, device_ctrl_1) || !this->write_byte(TAS58XX_AGAIN, again) ||
135 !this->write_volume_() || !this->write_ctrl_state_(TAS58XX_CTRL_STATE_PLAY, this->is_muted_) ||
136 !this->write_byte(TAS58XX_FAULT_CLEAR, TAS58XX_FAULT_CLEAR_ANALOG)) {
137 ESP_LOGE(TAG, "I2C write failed during init");
138 return false;
139 }
140 // The mixer is written once the I2S clocks run, see on_audio_started() and update()
141 this->power_state_ = TAS58XX_CTRL_STATE_UNKNOWN;
142 this->mixer_written_ = false;
143 return true;
144}
145
147 if (this->is_failed())
148 return;
149 ESP_LOGD(TAG, "[0x%02X] Activating", this->address_);
150 // A failed mixer write can leave the device in another book
151 if (!this->select_book_page_(TAS58XX_BOOK_CONTROL, TAS58XX_PAGE_0)) {
152 ESP_LOGE(TAG, "Failed to select the control port");
153 return;
154 }
155 // Also the way to restart the output after a DC or over current fault
156 if (!this->write_byte(TAS58XX_FAULT_CLEAR, TAS58XX_FAULT_CLEAR_ANALOG)) {
157 ESP_LOGW(TAG, "Failed to clear faults");
158 }
159 const bool muted = this->is_muted_;
160 // Leaving deep sleep needs this sequence to reset the internal state machine, see datasheet 7.4.5
161 if (this->ctrl_state_ == TAS58XX_CTRL_STATE_DEEP_SLEEP &&
162 !(this->write_ctrl_state_(TAS58XX_CTRL_STATE_HIZ, muted) &&
163 this->write_ctrl_state_(TAS58XX_CTRL_STATE_DEEP_SLEEP, muted) &&
164 this->write_ctrl_state_(TAS58XX_CTRL_STATE_HIZ, muted))) {
165 return;
166 }
167 if (this->write_ctrl_state_(TAS58XX_CTRL_STATE_PLAY, muted))
168 this->publish_active_(true);
169}
170
172 if (this->is_failed())
173 return;
174 ESP_LOGD(TAG, "[0x%02X] Deactivating", this->address_);
175 if (!this->select_book_page_(TAS58XX_BOOK_CONTROL, TAS58XX_PAGE_0)) {
176 ESP_LOGE(TAG, "Failed to select the control port");
177 return;
178 }
179 // The DSP, and with it the mixer, stays active in deep sleep
180 if (this->write_ctrl_state_(TAS58XX_CTRL_STATE_DEEP_SLEEP, this->is_muted_))
181 this->publish_active_(false);
182}
183
184// The activate switch shows whether the device is active (play) or in deep sleep. The state is published here, not
185// by the switch, so it also follows the tas58xx.activate and tas58xx.deactivate actions, and only after the write
186// to the device succeeded.
187void TAS58xx::publish_active_(bool active) {
188#ifdef USE_SWITCH
189 PUBLISH_STATE(this->activate_switch_, active);
190#endif
191}
192
193bool TAS58xx::write_ctrl_state_(uint8_t state, bool muted) {
194 if (!this->write_byte(TAS58XX_DEVICE_CTRL_2, state | (muted ? TAS58XX_DEVICE_CTRL_2_MUTE : 0))) {
195 ESP_LOGE(TAG, "Failed to write DEVICE_CTRL_2");
196 return false;
197 }
198 this->ctrl_state_ = state;
199 return true;
200}
201
202// Returns false if the fault registers could not be read
204 uint8_t fault_registers[TAS58XX_FAULT_REGISTER_COUNT];
205 if (!this->read_bytes(TAS58XX_CHAN_FAULT, fault_registers, sizeof(fault_registers)))
206 return false;
207 uint32_t faults = 0;
208 for (uint8_t reg = 0; reg < TAS58XX_FAULT_REGISTER_COUNT; reg++)
209 faults |= uint32_t{fault_registers[reg]} << (reg * 8);
210 const ModelInfo &model = *this->model_;
211 const uint32_t active = faults & (model.fault_error_mask | model.fault_warning_mask);
212
213 // Clearing makes a lasting condition latch again on every poll, so only log changes
214 const uint32_t changed = active ^ this->logged_faults_;
215 for (uint8_t index = 0; index < 32; index++) {
216 const uint32_t mask = uint32_t{1} << index;
217 if (!(changed & mask))
218 continue;
219 const LogString *name = model.fault_name(index);
220 if (!(active & mask)) {
221 ESP_LOGI(TAG, "[0x%02X] %s cleared", this->address_, LOG_STR_ARG(name));
222 } else if (model.fault_error_mask & mask) {
223 ESP_LOGE(TAG, "[0x%02X] %s", this->address_, LOG_STR_ARG(name));
224 } else {
225 ESP_LOGW(TAG, "[0x%02X] %s", this->address_, LOG_STR_ARG(name));
226 }
227 }
228 if (changed & active & model.fault_output_off_mask) {
229 ESP_LOGW(TAG, "[0x%02X] Output stays off: fix the cause, then call tas58xx.activate or power cycle the amplifier",
230 this->address_);
231 }
232 this->logged_faults_ = active;
233
234#ifdef USE_BINARY_SENSOR
235 PUBLISH_STATE(this->have_fault_binary_sensor_, (active & model.fault_error_mask) != 0);
236 for (uint8_t fault = 0; fault < FAULT_SENSOR_COUNT; fault++) {
237 const uint8_t bit = model.fault_sensor_bits[fault];
238 if (this->fault_binary_sensors_[fault] != nullptr && bit != NO_BIT)
239 this->fault_binary_sensors_[fault]->publish_state(faults & (uint32_t{1} << bit));
240 }
241#endif
242
243 // Latched fault bits stay set after the condition is gone and only report it; clear those so the bits, and the
244 // sensors, follow the current state. The clear register resets all faults at once, so hold off while the output
245 // is off.
246 if ((faults & model.fault_latched_mask) && !(active & model.fault_output_off_mask) &&
247 !this->write_byte(TAS58XX_FAULT_CLEAR, TAS58XX_FAULT_CLEAR_ANALOG)) {
248 ESP_LOGW(TAG, "Failed to clear faults");
249 }
250 return true;
251}
252
254 // Speaker calls this once I2S clock runs, so DSP is writable
255 if (!this->is_failed())
256 this->write_dsp_();
257}
258
259bool TAS58xx::read_power_state_(uint8_t &power_state) {
260 if (!this->read_byte(TAS58XX_POWER_STATE, &power_state))
261 return false;
262 power_state &= TAS58XX_CTRL_STATE_MASK;
263 return true;
264}
265
266// DSP keeps its coefficients when clock stops, so each setting is written once after reset
268 if (!this->mixer_written_ && !this->write_mixer_()) {
269 ESP_LOGW(TAG, "Failed to write mixer");
270 }
271}
272
274 uint8_t power_state{0};
275 if (!this->status_comm_result(this->read_faults_() && this->read_power_state_(power_state),
276 LOG_STR("Failed to read status")))
277 return;
278
279 if (power_state != this->power_state_) {
280 ESP_LOGD(TAG, "[0x%02X] Power state: %s", this->address_, LOG_STR_ARG(power_state_name(power_state)));
281 this->power_state_ = power_state;
282 }
283 // Fallback for speakers that do not call on_audio_started()
284 if (dsp_writable(power_state))
285 this->write_dsp_();
286}
287
289 const LogString *fault_output;
290 if (this->fault_output_pin_ == FAULT_OUTPUT_NONE) {
291 fault_output = LOG_STR("None");
292 } else if (this->fault_output_pin_ >= this->model_->fault_output_pins) {
293 fault_output = LOG_STR("Invalid");
294 } else {
295 fault_output = this->model_->fault_output_name(this->fault_output_pin_);
296 }
297 ESP_LOGCONFIG(TAG,
298 "Audio Amplifier:\n"
299 " Model: %s",
300 LOG_STR_ARG(this->model_->name()));
301 LOG_I2C_DEVICE(this);
302 LOG_PIN(" Enable Pin: ", this->enable_pin_);
303 LOG_UPDATE_INTERVAL(this);
304 ESP_LOGCONFIG(TAG,
305 " Analog Gain: %.1f dB\n"
306 " DAC Mode: %s\n"
307 " Modulation: %s\n"
308 " Mixer Mode: %s\n"
309 " Volume Range: %.1f dB to %.1f dB\n"
310 " Fault Output: %s",
311 this->analog_gain_db_,
312 this->dac_mode_ == DAC_MODE_PBTL ? LOG_STR_LITERAL("PBTL") : LOG_STR_LITERAL("BTL"),
313 this->modulation_ == MODULATION_1SPW_MODE ? LOG_STR_LITERAL("1SPW") : LOG_STR_LITERAL("BD"),
314 LOG_STR_ARG(mixer_mode_name(this->mixer_mode_)), this->volume_min_db_, this->volume_max_db_,
315 LOG_STR_ARG(fault_output));
316#ifdef USE_BINARY_SENSOR
317 LOG_BINARY_SENSOR(" ", "Any Fault", this->have_fault_binary_sensor_);
318 for (auto *sensor : this->fault_binary_sensors_) {
319 LOG_BINARY_SENSOR(" ", "Fault", sensor);
320 }
321#endif
322#ifdef USE_SWITCH
323 LOG_SWITCH(" ", "Activate", this->activate_switch_);
324#endif
325#ifdef USE_SELECT
326 LOG_SELECT(" ", "Mixer Mode", this->mixer_mode_select_);
327#endif
328}
329
330bool TAS58xx::set_mute_(bool muted) {
331 if (!this->write_ctrl_state_(this->ctrl_state_, muted))
332 return false;
333 this->is_muted_ = muted;
334 return true;
335}
336
337bool TAS58xx::set_volume(float volume) {
338 float previous = this->volume_;
339 this->volume_ = clamp(volume, 0.0f, 1.0f);
340 if (!this->write_volume_()) {
341 this->volume_ = previous;
342 return false;
343 }
344 return true;
345}
346
348 // volume 0.0 maps to volume_min_db_, which is only close to silence at -103 dB
349 const float volume_db = std::lerp(this->volume_min_db_, this->volume_max_db_, this->volume_);
350 const uint8_t dig_vol = static_cast<uint8_t>(
351 lroundf(clamp(TAS58XX_DIG_VOL_0DB - volume_db * 2.0f, 0.0f, float{TAS58XX_DIG_VOL_MINUS_103DB})));
352 ESP_LOGV(TAG, "Setting volume to 0x%02X", dig_vol);
353 return this->write_byte(TAS58XX_DIG_VOL, dig_vol);
354}
355
356#ifdef USE_SELECT
358 if (this->mixer_mode_select_ != nullptr) {
359 // Select options start at mono for PBTL
360 const uint8_t first_mode = this->dac_mode_ == DAC_MODE_PBTL ? MIXER_MODE_MONO : MIXER_MODE_STEREO;
361 this->mixer_mode_select_->publish_state(this->mixer_mode_ - first_mode);
362 }
363}
364
365void TAS58xx::apply_mixer_mode(MixerMode mixer_mode) {
366 if (this->is_failed())
367 return;
368 // Stereo modes are invalid for PBTL
369 if (this->dac_mode_ == DAC_MODE_PBTL && mixer_mode < MIXER_MODE_MONO) {
370 ESP_LOGW(TAG, "[0x%02X] Mixer mode %s is not valid for PBTL", this->address_,
371 LOG_STR_ARG(mixer_mode_name(mixer_mode)));
372 return;
373 }
374 this->mixer_mode_ = mixer_mode;
375 this->mixer_written_ = false;
376 this->publish_mixer_mode_();
377 uint8_t power_state;
378 if (this->read_power_state_(power_state) && dsp_writable(power_state))
379 this->write_dsp_();
380}
381#endif
382
384 uint8_t left_to_left = TAS58XX_MIXER_0DB;
385 uint8_t right_to_left = TAS58XX_MIXER_MUTE;
386 uint8_t left_to_right = TAS58XX_MIXER_MUTE;
387 uint8_t right_to_right = TAS58XX_MIXER_0DB;
389 left_to_left = TAS58XX_MIXER_MUTE;
390 right_to_left = TAS58XX_MIXER_0DB;
391 left_to_right = TAS58XX_MIXER_0DB;
392 right_to_right = TAS58XX_MIXER_MUTE;
393 } else if (this->mixer_mode_ == MIXER_MODE_MONO) {
394 left_to_left = TAS58XX_MIXER_MINUS_6DB;
395 right_to_left = TAS58XX_MIXER_MINUS_6DB;
396 left_to_right = TAS58XX_MIXER_MINUS_6DB;
397 right_to_right = TAS58XX_MIXER_MINUS_6DB;
398 } else if (this->mixer_mode_ == MIXER_MODE_LEFT) {
399 left_to_right = TAS58XX_MIXER_0DB;
400 right_to_right = TAS58XX_MIXER_MUTE;
401 } else if (this->mixer_mode_ == MIXER_MODE_RIGHT) {
402 left_to_left = TAS58XX_MIXER_MUTE;
403 right_to_left = TAS58XX_MIXER_0DB;
404 }
405 const uint8_t coefficients[4 * TAS58XX_MIXER_COEFFICIENT_SIZE] = {0, left_to_left, 0, 0, 0, right_to_left, 0, 0,
406 0, left_to_right, 0, 0, 0, right_to_right, 0, 0};
407 bool ok = this->select_book_page_(this->model_->mixer_book, this->model_->mixer_page) &&
408 this->write_bytes(this->model_->mixer_register, coefficients, sizeof(coefficients));
409 // Always return to the control port, even after a failed write
410 ok = this->select_book_page_(TAS58XX_BOOK_CONTROL, TAS58XX_PAGE_0) && ok;
411 this->mixer_written_ = ok;
412 if (ok) {
413 ESP_LOGD(TAG, "[0x%02X] Mixer mode written: %s", this->address_, LOG_STR_ARG(mixer_mode_name(this->mixer_mode_)));
414 }
415 return ok;
416}
417
418} // namespace esphome::tas58xx
bool is_failed() const
Definition component.h:288
bool status_comm_result(bool ok)
Clears the warning when ok, else sets it with message (default "Communication failed"); returns ok.
bool ESPHOME_ALWAYS_INLINE setup_check(bool ok)
Marks the component failed with message (default "Communication failed") unless ok; returns ok.
Definition component.h:236
uint8_t address_
store the address of the device on the bus
Definition i2c.h:340
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:89
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:187
bool set_mute_(bool muted)
Definition tas58xx.cpp:330
void write_dsp_()
Write DSP settings not written since last reset; call only while DSP is writable.
Definition tas58xx.cpp:267
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:357
void setup() override
Definition tas58xx.cpp:82
void update() override
Definition tas58xx.cpp:273
void dump_config() override
Definition tas58xx.cpp:288
bool set_volume(float volume) override
Definition tas58xx.cpp:337
bool read_power_state_(uint8_t &power_state)
Read POWER_STATE, masked to device state; false if read failed.
Definition tas58xx.cpp:259
bool write_ctrl_state_(uint8_t state, bool muted)
Definition tas58xx.cpp:193
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:146
void deactivate()
Switch to deep sleep, the lowest power state that keeps I2C and the DSP running.
Definition tas58xx.cpp:171
float volume() override
Definition tas58xx.h:138
void on_audio_started() override
Definition tas58xx.cpp:253
bool select_book_page_(uint8_t book, uint8_t page)
Definition tas58xx.cpp:93
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:78
ESPHOME_ALWAYS_INLINE void pulse_reset(GPIOPin *pin, ResetPulse pulse)
Set up an active-low reset pin and drive it through pulse.
Definition gpio_pin.h:214
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