ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
model_tas5825m.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, run after the reset in TAS58xx::init_(). Register 0x00 selects the page.
8// Based on the TI PurePath Console (PPC) export for "TAS5825M 2-Band DRC&AGL 2.0 96k".
9// Registers 0x46, 0x7D, 0x7E, page 1 register 0x51 and page 2 registers 0x1D, 0x19 are not documented in datasheet.
10static const uint8_t STARTUP_SEQUENCE[][2] PROGMEM = {
11 {0x03, 0x00}, // DEVICE_CTRL_2: deep sleep, the state the PPC sequence starts from
12 {0x7D, 0x11},
13 {0x7E, 0xFF},
14 {0x00, 0x01}, // Page 1
15 {0x51, 0x05},
16 {0x00, 0x02}, // Page 2
17 {0x1D, 0x00},
18 {0x19, 0x80},
19 {0x00, 0x00}, // Page 0
20 {0x46, 0x11},
21 // PPC also writes 0x02 (DEVICE_CTRL_1) and 0x54 (AGAIN) here; init_() writes both from YAML
22 {0x53, 0x01}, // ANA_CTRL: in phase, 100kHz bandwidth for high audio performance with Fsw=384kHz
23 {0x03, 0x02}, // DEVICE_CTRL_2: Hi-Z
24
25 // Additional register configuration
26 // GPIO1 is a dedicated pin on TAS5825M (separate from ADR), used as FAULTZ
27 {0x62, 0x0B}, // GPIO1_SEL: GPIO1 as FAULTZ
28 {0x60, 0x02}, // GPIO_CTRL: GPIO1 is output
29 {0x77, 0x07}, // CBC_CONTROL: enable cycle-by-cycle current limit for warnings and faults
30};
31
32static const LogString *model_name() { return LOG_STR("TAS5825M"); }
33
34// An if chain rather than a switch: a switch table would land in rodata, which is RAM on ESP8266.
35static const LogString *fault_name(uint8_t index) {
36 if (index == 0)
37 return LOG_STR("Right channel over current");
38 if (index == 1)
39 return LOG_STR("Left channel over current");
40 if (index == 2)
41 return LOG_STR("Right channel DC fault");
42 if (index == 3)
43 return LOG_STR("Left channel DC fault");
44 if (index == 8)
45 return LOG_STR("PVDD under voltage");
46 if (index == 9)
47 return LOG_STR("PVDD over voltage");
48 if (index == 10)
49 return LOG_STR("Clock fault");
50 if (index == 13)
51 return LOG_STR("Load EEPROM error");
52 if (index == 14)
53 return LOG_STR("BQ write failed");
54 if (index == 15)
55 return LOG_STR("OTP CRC check error");
56 if (index == 16)
57 return LOG_STR("Over temperature shutdown");
58 if (index == 17)
59 return LOG_STR("Left channel CBC over current");
60 if (index == 18)
61 return LOG_STR("Right channel CBC over current");
62 // if (index == 24)
63 // return LOG_STR("Over temperature warning 112C"); // not currently included
64 // if (index == 25)
65 // return LOG_STR("Over temperature warning 122C"); // not currently included
66 if (index == 26)
67 return LOG_STR("Over temperature warning");
68 if (index == 27)
69 return LOG_STR("Over temperature warning 146C");
70 if (index == 28)
71 return LOG_STR("Right channel CBC over current warning");
72 if (index == 29)
73 return LOG_STR("Left channel CBC over current warning");
74 return LOG_STR("Unknown fault");
75}
76
78 .name = model_name,
79 .startup_sequence = STARTUP_SEQUENCE,
80 .startup_sequence_length = sizeof(STARTUP_SEQUENCE) / sizeof(STARTUP_SEQUENCE[0]),
81 .mixer_book = 0x8C,
82 .mixer_page = 0x0B,
83 .mixer_register = 0x14,
84 // The clock fault is left out of the log and have_fault: it is set whenever the I2S clock stops, which is normal
85 .fault_error_mask = 0x0007E30F,
86 .fault_warning_mask =
87 0x3C000000, // 0x3F000000 if OVER_TEMP_122C_WARNING and OVER_TEMP_112C_WARNING included in future
88 // 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
89 // cleared automatically: a DC fault re-trips only after 570 ms, so a clear on every poll would pass DC to the
90 // speaker.
91 .fault_output_off_mask = 0x0000000F,
92 .fault_latched_mask = 0x3F07E70F,
93 .fault_name = fault_name,
94 .fault_sensor_bits =
95 {
96 3, // FAULT_SENSOR_LEFT_CHANNEL_DC_FAULT
97 2, // FAULT_SENSOR_RIGHT_CHANNEL_DC_FAULT
98 1, // FAULT_SENSOR_LEFT_CHANNEL_OVER_CURRENT
99 0, // FAULT_SENSOR_RIGHT_CHANNEL_OVER_CURRENT
100 15, // FAULT_SENSOR_OTP_CRC_CHECK
101 14, // FAULT_SENSOR_BQ_WRITE_FAILED
102 10, // FAULT_SENSOR_CLOCK_FAULT
103 9, // FAULT_SENSOR_PVDD_OVER_VOLTAGE
104 8, // FAULT_SENSOR_PVDD_UNDER_VOLTAGE
105 16, // FAULT_SENSOR_OVER_TEMP_SHUTDOWN
106 26, // FAULT_SENSOR_OVER_TEMP_WARNING
107 13, // FAULT_SENSOR_LOAD_EEPROM_ERROR
108 18, // FAULT_SENSOR_RIGHT_CHANNEL_CBC_OVER_CURRENT
109 17, // FAULT_SENSOR_LEFT_CHANNEL_CBC_OVER_CURRENT
110 29, // FAULT_SENSOR_LEFT_CHANNEL_CBC_OVER_CURRENT_WARNING
111 28, // FAULT_SENSOR_RIGHT_CHANNEL_CBC_OVER_CURRENT_WARNING
112 27, // FAULT_SENSOR_OVER_TEMP_146C_WARNING
113 // 25, // FAULT_SENSOR_OVER_TEMP_122C_WARNING // not currently included
114 // 24, // FAULT_SENSOR_OVER_TEMP_112C_WARNING // not currently included
115 },
116};
117
118} // namespace esphome::tas58xx
constexpr float BME680_GAS_LOOKUP_TABLE_1[16] PROGMEM
Definition bme680.cpp:26
const ModelInfo TAS5825M_MODEL
Everything that differs between models of the family.
Definition tas58xx.h:70