ESPHome 2026.11.0b6
Loading...
Searching...
No Matches
model_tas5805m.cpp
Go to the documentation of this file.
1#include "tas58xx.h"
2
3#include "esphome/core/hal.h"
4
5namespace esphome::tas58xx {
6
7// Remainder of the startup sequence from TI PurePath Console, run after the reset. Register 0x00 selects the page.
8// Registers 0x46, 0x7D, 0x7E and page 1 register 0x51 are not documented in the datasheet.
9static constexpr i2c::I2CRegValue STARTUP_SEQUENCE[] PROGMEM = {
10 {0x03, 0x00}, // DEVICE_CTRL_2: deep sleep
11 {0x46, 0x01}, // PPC 96 kHz process flow value (its 48 kHz FIR flows write 0x11)
12 {0x03, 0x02}, // DEVICE_CTRL_2: Hi-Z
13 {0x7D, 0x11},
14 {0x7E, 0xFF},
15 {0x00, 0x01}, // Page 1
16 {0x51, 0x05},
17 {0x00, 0x00}, // Page 0
18
19 // Additional register configuration
20 {0x53, 0x60}, // ANA_CTRL: for high audio performance use 175kHz bandwidth with Fsw=768kHz
21};
22
23static const LogString *model_name() { return LOG_STR("TAS5805M"); }
24
25static const LogString *fault_output_name(uint8_t) { return LOG_STR("ADR"); }
26
27// An if chain rather than a switch: a switch table would land in rodata, which is RAM on ESP8266.
28static const LogString *fault_name(uint8_t index) {
29 if (index == 0)
30 return LOG_STR("Right channel over current");
31 if (index == 1)
32 return LOG_STR("Left channel over current");
33 if (index == 2)
34 return LOG_STR("Right channel DC fault");
35 if (index == 3)
36 return LOG_STR("Left channel DC fault");
37 if (index == 8)
38 return LOG_STR("PVDD under voltage");
39 if (index == 9)
40 return LOG_STR("PVDD over voltage");
41 if (index == 10)
42 return LOG_STR("Clock fault");
43 if (index == 14)
44 return LOG_STR("BQ write failed");
45 if (index == 15)
46 return LOG_STR("OTP CRC check error");
47 if (index == 16)
48 return LOG_STR("Over temperature shutdown");
49 if (index == 26)
50 return LOG_STR("Over temperature warning");
51 return LOG_STR("Unknown fault");
52}
53
55 .name = model_name,
56 .startup_sequence = STARTUP_SEQUENCE,
57 .startup_sequence_length = sizeof(STARTUP_SEQUENCE) / sizeof(STARTUP_SEQUENCE[0]),
58 .mixer_book = 0x8C,
59 .mixer_page = 0x29,
60 .mixer_register = 0x18,
61 // The clock fault is left out of the log and have_fault: it is set whenever the I2S clock stops, which is normal
62 .fault_error_mask = 0x0001C30F,
63 .fault_warning_mask = 0x04000000,
64 // DC and over current faults keep the output off until cleared (datasheet 7.5.3.3.1, 7.5.3.3.2). They are not
65 // cleared automatically: a DC fault re-trips only after 570 ms, so a clear on every poll would pass DC to the
66 // speaker.
67 .fault_output_off_mask = 0x0000000F,
68 .fault_latched_mask = 0x0401C70F,
69 .fault_name = fault_name,
70 .fault_sensor_bits =
71 {
72 3, // FAULT_SENSOR_LEFT_CHANNEL_DC_FAULT
73 2, // FAULT_SENSOR_RIGHT_CHANNEL_DC_FAULT
74 1, // FAULT_SENSOR_LEFT_CHANNEL_OVER_CURRENT
75 0, // FAULT_SENSOR_RIGHT_CHANNEL_OVER_CURRENT
76 15, // FAULT_SENSOR_OTP_CRC_CHECK
77 14, // FAULT_SENSOR_BQ_WRITE_FAILED
78 10, // FAULT_SENSOR_CLOCK_FAULT
79 9, // FAULT_SENSOR_PVDD_OVER_VOLTAGE
80 8, // FAULT_SENSOR_PVDD_UNDER_VOLTAGE
81 16, // FAULT_SENSOR_OVER_TEMP_SHUTDOWN
82 26, // FAULT_SENSOR_OVER_TEMP_WARNING
83 NO_BIT, // FAULT_SENSOR_LOAD_EEPROM_ERROR
84 NO_BIT, // FAULT_SENSOR_RIGHT_CHANNEL_CBC_OVER_CURRENT
85 NO_BIT, // FAULT_SENSOR_LEFT_CHANNEL_CBC_OVER_CURRENT
86 NO_BIT, // FAULT_SENSOR_LEFT_CHANNEL_CBC_OVER_CURRENT_WARNING
87 NO_BIT, // FAULT_SENSOR_RIGHT_CHANNEL_CBC_OVER_CURRENT_WARNING
88 NO_BIT, // FAULT_SENSOR_OVER_TEMP_146C_WARNING
89 },
90 .fault_output_pins = 1, // ADR
91 .fault_output_name = fault_output_name,
92};
93
94} // namespace esphome::tas58xx
const ModelInfo TAS5805M_MODEL
One register write for I2CDevice::write_registers(); tables of these may live in PROGMEM.
Definition i2c.h:18
Everything that differs between models of the family.
Definition tas58xx.h:84