MCPcopy Create free account
hub / github.com/BruceDevices/firmware / _setup_codec_speaker

Function _setup_codec_speaker

boards/m5stack-sticks3/interface.cpp:233–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233void _setup_codec_speaker(bool enable) {
234
235 static constexpr const uint8_t enabled_bulk_data[] = {
236 2, 0x00, 0x80, // 0x00 RESET/ CSM POWER ON
237 2, 0x01, 0xB5, // 0x01 CLOCK_MANAGER/ MCLK=BCLK
238 2, 0x02, 0x18, // 0x02 CLOCK_MANAGER/ MULT_PRE=3
239 2, 0x0D, 0x01, // 0x0D SYSTEM/ Power up analog circuitry
240 2, 0x12, 0x00, // 0x12 SYSTEM/ power-up DAC - NOT default
241 2, 0x13, 0x10, // 0x13 SYSTEM/ Enable output to HP drive - NOT default
242 2, 0x32, 0xBF, // 0x32 DAC/ DAC volume (0xBF == +-0 dB )
243 2, 0x37, 0x08, // 0x37 DAC/ Bypass DAC equalizer - NOT default
244 0
245 };
246
247 if (speaker_off_timer == NULL) {
248 speaker_off_timer = xTimerCreate("SpkOffTimer", pdMS_TO_TICKS(100), pdFALSE, (void *)0, speaker_off_timer_cb);
249 }
250
251 if (enable) {
252 if (speaker_off_timer != NULL && xTimerIsTimerActive(speaker_off_timer)) {
253 xTimerStop(speaker_off_timer, 0); // Cancel pending shutdown
254 } else {
255 i2c_bulk_write(&Wire1, ES8311_ADDR, enabled_bulk_data);
256 M5.In_I2C.bitOn(0x6E, 0x11, 1 << 3, 100000); // Set gpio3 output high (turn on PA)
257 }
258 } else {
259 if (speaker_off_timer != NULL) {
260 xTimerReset(speaker_off_timer, 0); // Start/reset shutdown timeout for 100ms
261 }
262 }
263}
264
265/*********************************************************************
266** Function: _setup_codec_mic

Callers

nothing calls this directly

Calls 1

i2c_bulk_writeFunction · 0.85

Tested by

no test coverage detected