arduino-audio-driver
Loading...
Searching...
No Matches
MAX98091.h
Go to the documentation of this file.
1
9#pragma once
10
12
13namespace audio_driver {
14
16enum class MAX98091Protocol {
17 I2S,
20};
21
30
39 public:
40 // ---- Register addresses ----
41 enum Reg : uint8_t {
121 };
122
123 // ---- M98091_REG_SOFTWARE_RESET ----
124 static constexpr uint8_t SWRESET_MASK = (1 << 7);
125
126 // ---- M98091_REG_QUICK_SAMPLE_RATE ----
127 static constexpr uint8_t SR_96K_MASK = (1 << 5);
128 static constexpr uint8_t SR_32K_MASK = (1 << 4);
129 static constexpr uint8_t SR_48K_MASK = (1 << 3);
130 static constexpr uint8_t SR_44K1_MASK = (1 << 2);
131 static constexpr uint8_t SR_16K_MASK = (1 << 1);
132 static constexpr uint8_t SR_8K_MASK = (1 << 0);
133
134 // ---- M98091_REG_DAI_INTERFACE ----
135 static constexpr uint8_t RJ_M_MASK = (1 << 5);
136 static constexpr uint8_t RJ_S_MASK = (1 << 4);
137 static constexpr uint8_t LJ_M_MASK = (1 << 3);
138 static constexpr uint8_t LJ_S_MASK = (1 << 2);
139 static constexpr uint8_t I2S_M_MASK = (1 << 1);
140 static constexpr uint8_t I2S_S_MASK = (1 << 0);
141
142 // ---- M98091_REG_SYSTEM_CLOCK (PSCLK) ----
143 static constexpr uint8_t PSCLK_DISABLED = (0 << 4);
144 static constexpr uint8_t PSCLK_DIV1 = (1 << 4);
145 static constexpr uint8_t PSCLK_DIV2 = (2 << 4);
146 static constexpr uint8_t PSCLK_DIV4 = (3 << 4);
147
148 // ---- M98091_REG_MASTER_MODE ----
149 static constexpr uint8_t MAS_MASK = (1 << 7);
150
151 // ---- M98091_REG_INTERFACE_FORMAT ----
152 static constexpr uint8_t RJ_MASK = (1 << 5);
153 static constexpr uint8_t WCI_MASK = (1 << 4);
154 static constexpr uint8_t BCI_MASK = (1 << 3);
155 static constexpr uint8_t DLY_MASK = (1 << 2);
156 static constexpr uint8_t WS_MASK = (3 << 0);
157 static constexpr uint8_t WS_16B = (0 << 0);
158
159 // ---- M98091_REG_IO_CONFIGURATION ----
160 static constexpr uint8_t LTEN_MASK = (1 << 5);
161 static constexpr uint8_t LBEN_MASK = (1 << 4);
162 static constexpr uint8_t DMONO_MASK = (1 << 3);
163 static constexpr uint8_t HIZOFF_MASK = (1 << 2);
164 static constexpr uint8_t SDOEN_MASK = (1 << 1);
165 static constexpr uint8_t SDIEN_MASK = (1 << 0);
166
167 // ---- M98091_REG_LEFT/RIGHT_HP_MIXER ----
168 static constexpr uint8_t MIXHPL_MIC2_MASK = (1 << 5);
169 static constexpr uint8_t MIXHPL_MIC1_MASK = (1 << 4);
170 static constexpr uint8_t MIXHPL_LINEB_MASK = (1 << 3);
171 static constexpr uint8_t MIXHPL_LINEA_MASK = (1 << 2);
172 static constexpr uint8_t MIXHPL_DACR_MASK = (1 << 1);
173 static constexpr uint8_t MIXHPL_DACL_MASK = (1 << 0);
174 static constexpr uint8_t MIXHPL_MASK = (63 << 0);
175
176 static constexpr uint8_t MIXHPR_MIC2_MASK = (1 << 5);
177 static constexpr uint8_t MIXHPR_MIC1_MASK = (1 << 4);
178 static constexpr uint8_t MIXHPR_LINEB_MASK = (1 << 3);
179 static constexpr uint8_t MIXHPR_LINEA_MASK = (1 << 2);
180 static constexpr uint8_t MIXHPR_DACR_MASK = (1 << 1);
181 static constexpr uint8_t MIXHPR_DACL_MASK = (1 << 0);
182 static constexpr uint8_t MIXHPR_MASK = (63 << 0);
183
184 // ---- M98091_REG_HP_CONTROL ----
185 static constexpr uint8_t MIXHPRSEL_MASK = (1 << 5);
186 static constexpr uint8_t MIXHPLSEL_MASK = (1 << 4);
187 static constexpr uint8_t MIXHPRG_MASK = (3 << 2);
188 static constexpr uint8_t MIXHPLG_MASK = (3 << 0);
189
190 // ---- M98091_REG_LEFT/RIGHT_HP_VOLUME ----
191 static constexpr uint8_t HPLM_MASK = (1 << 7);
192 static constexpr uint8_t HPVOLL_MASK = (31 << 0);
193
194 // ---- M98091_REG_LEFT_SPK_MIXER ----
195 static constexpr uint8_t MIXSPL_MIC2_MASK = (1 << 5);
196 static constexpr uint8_t MIXSPL_MIC1_MASK = (1 << 4);
197 static constexpr uint8_t MIXSPL_LINEB_MASK = (1 << 3);
198 static constexpr uint8_t MIXSPL_LINEA_MASK = (1 << 2);
199 static constexpr uint8_t MIXSPL_DACR_MASK = (1 << 1);
200 static constexpr uint8_t MIXSPL_DACL_MASK = (1 << 0);
201 static constexpr uint8_t MIXSPL_MASK = (63 << 0);
202
203 // ---- M98091_REG_RIGHT_SPK_MIXER ----
204 static constexpr uint8_t SPK_SLAVE_MASK = (1 << 6);
205 static constexpr uint8_t MIXSPR_MIC2_MASK = (1 << 5);
206 static constexpr uint8_t MIXSPR_MIC1_MASK = (1 << 4);
207 static constexpr uint8_t MIXSPR_LINEB_MASK = (1 << 3);
208 static constexpr uint8_t MIXSPR_LINEA_MASK = (1 << 2);
209 static constexpr uint8_t MIXSPR_DACR_MASK = (1 << 1);
210 static constexpr uint8_t MIXSPR_DACL_MASK = (1 << 0);
211 static constexpr uint8_t MIXSPR_MASK = (63 << 0);
212
213 // ---- M98091_REG_SPK_CONTROL ----
214 static constexpr uint8_t MIXSPRG_MASK = (3 << 2);
215 static constexpr uint8_t MIXSPLG_MASK = (3 << 0);
216
217 // ---- M98091_REG_LEFT/RIGHT_SPK_VOLUME ----
218 static constexpr uint8_t SPLM_MASK = (1 << 7);
219 static constexpr uint8_t SPVOLL_MASK = (63 << 0);
220
221 // ---- M98091_REG_OUTPUT_ENABLE ----
222 static constexpr uint8_t HPREN_MASK = (1 << 7);
223 static constexpr uint8_t HPLEN_MASK = (1 << 6);
224 static constexpr uint8_t SPREN_MASK = (1 << 5);
225 static constexpr uint8_t SPLEN_MASK = (1 << 4);
226 static constexpr uint8_t RCVLEN_MASK = (1 << 3);
227 static constexpr uint8_t RCVREN_MASK = (1 << 2);
228 static constexpr uint8_t DAREN_MASK = (1 << 1);
229 static constexpr uint8_t DALEN_MASK = (1 << 0);
230
231 // ---- M98091_REG_DEVICE_SHUTDOWN ----
232 static constexpr uint8_t SHDNN_MASK = (1 << 7);
233
234 static constexpr uint8_t DEFAULT_VOLUME = 0x2A;
235 static constexpr uint8_t REVA = 0x50;
236
237 MAX98091() { i2c_addr = 0x10; }
238
254 bool begin(uint32_t sample_rate, uint8_t bits) {
255 return begin(MAX98091Protocol::I2S, sample_rate, 12000000, bits);
256 }
257
262 bool begin(uint32_t sample_rate, uint8_t bits, codec_mode_t mode,
263 i2s_format_t fmt, bool is_master, uint8_t channels) override {
264 (void)is_master;
266 switch (fmt) {
267 case I2S_LEFT:
269 break;
270 case I2S_RIGHT:
272 break;
273 default:
274 protocol = MAX98091Protocol::I2S;
275 break;
276 }
277 return begin(protocol, sample_rate, 12000000, bits, channels,
278 mode & CODEC_MODE_DECODE);
279 }
280
282 uint32_t sample_rate = 44100, uint32_t mclk_freq = 12000000,
283 uint8_t word_size = 16, uint8_t channels = 2,
284 bool playback = true) {
285 bool rc = true;
286
287 rc &= softReset();
288
289 /* Put the audio codec into shutdown mode */
290 rc &= writeReg(REG_DEVICE_SHUTDOWN, 0x00);
291
292 rc &= writeReg(REG_DAC_CONTROL, 0x00);
293
294 rc &= writeReg(REG_TDM_CONTROL, 0x00);
295
296 /* Set DLY = 1 to conform to the I2S standard.
297 * DLY is only effective when TDM = 0 */
299
300 /* Configure system clock */
301 rc &= setSystemClock(mclk_freq);
302
303 rc &= setProtocol(protocol);
304 rc &= setAudioFormat(sample_rate, word_size, channels);
305
306 if (playback) rc &= configureOutput();
307
308 /* Bring the audio codec out of shutdown mode */
310
311 return rc;
312 }
313
315 bool softReset() {
316 bool rc = writeReg(REG_SOFTWARE_RESET, 0x01);
317 delayMs(20);
318 return rc;
319 }
320
323 uint8_t fmt_reg = 0;
324 switch (protocol) {
326 fmt_reg = I2S_S_MASK;
327 break;
329 fmt_reg = LJ_S_MASK;
330 break;
332 fmt_reg = RJ_S_MASK;
333 break;
334 default:
335 return false;
336 }
337 return writeReg(REG_DAI_INTERFACE, fmt_reg);
338 }
339
349 bool setAudioFormat(uint32_t sample_rate, uint8_t word_size = 16,
350 uint8_t channels = 2) {
351 bool rc = true;
352 uint8_t sample_rate_mask;
353
354 switch (sample_rate) {
355 case 8000:
356 sample_rate_mask = SR_8K_MASK;
357 break;
358 case 16000:
359 sample_rate_mask = SR_16K_MASK;
360 break;
361 case 32000:
362 sample_rate_mask = SR_32K_MASK;
363 break;
364 case 44100:
365 sample_rate_mask = SR_44K1_MASK;
366 break;
367 case 48000:
368 sample_rate_mask = SR_48K_MASK;
369 break;
370 case 96000:
371 sample_rate_mask = SR_96K_MASK;
372 break;
373 default:
374 return false;
375 }
376 rc &= writeReg(REG_QUICK_SAMPLE_RATE, sample_rate_mask);
377
378 uint8_t mono = (channels == 1) ? 1 : 0;
380
381 // only 16 bit word size is supported by the codec's quick config
382 (void)word_size;
384
385 return rc;
386 }
387
394 bool setSystemClock(uint32_t mclk_freq) {
395 uint8_t psclk;
396 if (mclk_freq >= 10000000 && mclk_freq <= 20000000) {
397 psclk = PSCLK_DIV1;
398 } else if (mclk_freq > 20000000 && mclk_freq <= 40000000) {
399 psclk = PSCLK_DIV2;
400 } else if (mclk_freq > 40000000 && mclk_freq <= 60000000) {
401 psclk = PSCLK_DIV4;
402 } else {
403 return false;
404 }
405
406 bool rc = writeReg(REG_SYSTEM_CLOCK, psclk);
408 return rc;
409 }
410
413 bool setOutputVolume(uint8_t volume, MAX98091Channel channel = MAX98091Channel::All) {
414 return setVolumeOrMute(channel, volume, true);
415 }
416
419 return setVolumeOrMute(channel, mute ? 1 : 0, false);
420 }
421
423 bool setVolume(int volume) override {
424 volume_percent = volume < 0 ? 0 : (volume > 100 ? 100 : volume);
425 uint8_t vol = (uint8_t)((volume_percent * 31) / 100);
427 }
428
430 bool setMute(bool mute) override { return setOutputMute(mute, MAX98091Channel::All); }
431
434 (void)input_device;
435 this->output_device = output_device;
436 return true;
437 }
438
446 bool rc = true;
447
450
452
455
456 /* select DAC only source */
457 rc &= writeReg(REG_HP_CONTROL, 0x00);
458
459 /* DAREN, DALEN always on; HPREN/HPLEN and SPREN/SPLEN depend on output_device */
460 uint8_t output_enable = DAREN_MASK | DALEN_MASK;
461 if (hp) output_enable |= HPREN_MASK | HPLEN_MASK;
462 if (spk) output_enable |= SPREN_MASK | SPLEN_MASK;
463 rc &= writeReg(REG_OUTPUT_ENABLE, output_enable);
464
470
471 return rc;
472 }
473
476 bool readRevisionId(uint8_t& id) { return readReg(REG_REVISION_ID, id); }
477
478 protected:
481
482 bool setVolumeOrMute(MAX98091Channel channel, uint8_t value, bool is_volume) {
483 uint8_t hp_mask = is_volume ? HPVOLL_MASK : HPLM_MASK;
484 uint8_t spk_mask = is_volume ? SPVOLL_MASK : SPLM_MASK;
485
486 switch (channel) {
488 return updateReg(REG_LEFT_SPK_VOLUME, spk_mask, value);
490 return updateReg(REG_RIGHT_SPK_VOLUME, spk_mask, value);
492 return updateReg(REG_LEFT_HP_VOLUME, hp_mask, value);
494 return updateReg(REG_RIGHT_HP_VOLUME, hp_mask, value);
496 bool rc = true;
497 rc &= updateReg(REG_LEFT_SPK_VOLUME, spk_mask, value);
498 rc &= updateReg(REG_RIGHT_SPK_VOLUME, spk_mask, value);
499 rc &= updateReg(REG_LEFT_HP_VOLUME, hp_mask, value);
500 rc &= updateReg(REG_RIGHT_HP_VOLUME, hp_mask, value);
501 return rc;
502 }
503 default:
504 return false;
505 }
506 }
507};
508
509} // namespace audio_driver
Header only C++ driver for the MAX98091 audio codec.
Definition MAX98091.h:38
static constexpr uint8_t MIXHPL_DACR_MASK
Definition MAX98091.h:172
static constexpr uint8_t RCVREN_MASK
Definition MAX98091.h:227
bool setDevices(input_device_t input_device, output_device_t output_device) override
Stores the output device selection for use by configureOutput()
Definition MAX98091.h:433
bool begin(uint32_t sample_rate, uint8_t bits)
Initialize the codec: soft reset, configure the system clock, digital audio interface protocol,...
Definition MAX98091.h:254
static constexpr uint8_t SPVOLL_MASK
Definition MAX98091.h:219
static constexpr uint8_t REVA
Definition MAX98091.h:235
bool begin(MAX98091Protocol protocol=MAX98091Protocol::I2S, uint32_t sample_rate=44100, uint32_t mclk_freq=12000000, uint8_t word_size=16, uint8_t channels=2, bool playback=true)
Definition MAX98091.h:281
static constexpr uint8_t MIXSPL_MASK
Definition MAX98091.h:201
static constexpr uint8_t MIXSPL_MIC1_MASK
Definition MAX98091.h:196
static constexpr uint8_t DAREN_MASK
Definition MAX98091.h:228
bool setOutputMute(bool mute, MAX98091Channel channel=MAX98091Channel::All)
Mute / unmute the output for the given channel(s)
Definition MAX98091.h:418
static constexpr uint8_t SDIEN_MASK
Definition MAX98091.h:165
static constexpr uint8_t RJ_M_MASK
Definition MAX98091.h:135
static constexpr uint8_t MIXHPR_MIC2_MASK
Definition MAX98091.h:176
static constexpr uint8_t BCI_MASK
Definition MAX98091.h:154
static constexpr uint8_t LJ_S_MASK
Definition MAX98091.h:138
static constexpr uint8_t SR_44K1_MASK
Definition MAX98091.h:130
bool softReset()
Soft reset of the codec.
Definition MAX98091.h:315
static constexpr uint8_t MIXHPR_LINEB_MASK
Definition MAX98091.h:178
static constexpr uint8_t DEFAULT_VOLUME
Definition MAX98091.h:234
static constexpr uint8_t SR_16K_MASK
Definition MAX98091.h:131
static constexpr uint8_t PSCLK_DIV2
Definition MAX98091.h:145
static constexpr uint8_t MIXHPR_DACL_MASK
Definition MAX98091.h:181
static constexpr uint8_t SR_48K_MASK
Definition MAX98091.h:129
static constexpr uint8_t MIXHPRG_MASK
Definition MAX98091.h:187
static constexpr uint8_t SR_8K_MASK
Definition MAX98091.h:132
static constexpr uint8_t LBEN_MASK
Definition MAX98091.h:161
bool setSystemClock(uint32_t mclk_freq)
Configure the master clock pre-scaler (PSCLK) based on the MCLK frequency, and ensure the codec remai...
Definition MAX98091.h:394
bool setMute(bool mute) override
Mutes/unmutes all outputs.
Definition MAX98091.h:430
bool setVolumeOrMute(MAX98091Channel channel, uint8_t value, bool is_volume)
Definition MAX98091.h:482
static constexpr uint8_t SDOEN_MASK
Definition MAX98091.h:164
static constexpr uint8_t MIXSPR_DACR_MASK
Definition MAX98091.h:209
static constexpr uint8_t HPLM_MASK
Definition MAX98091.h:191
static constexpr uint8_t MIXHPR_MIC1_MASK
Definition MAX98091.h:177
static constexpr uint8_t MIXSPR_DACL_MASK
Definition MAX98091.h:210
output_device_t output_device
Output device selection set via setDevices(), used by configureOutput()
Definition MAX98091.h:480
static constexpr uint8_t SPK_SLAVE_MASK
Definition MAX98091.h:204
bool configureOutput()
Configure the default playback path: route the DAC to the speaker mixers, select DAC-only source for ...
Definition MAX98091.h:445
static constexpr uint8_t LJ_M_MASK
Definition MAX98091.h:137
static constexpr uint8_t MIXHPL_DACL_MASK
Definition MAX98091.h:173
static constexpr uint8_t WS_16B
Definition MAX98091.h:157
static constexpr uint8_t PSCLK_DIV1
Definition MAX98091.h:144
static constexpr uint8_t HPVOLL_MASK
Definition MAX98091.h:192
static constexpr uint8_t LTEN_MASK
Definition MAX98091.h:160
MAX98091()
Definition MAX98091.h:237
static constexpr uint8_t MIXHPLG_MASK
Definition MAX98091.h:188
static constexpr uint8_t MIXSPL_MIC2_MASK
Definition MAX98091.h:195
static constexpr uint8_t MIXSPR_MIC1_MASK
Definition MAX98091.h:206
Reg
Definition MAX98091.h:41
@ REG_LEFT_SPK_VOLUME
Definition MAX98091.h:91
@ REG_RCV_LOUTL_VOLUME
Definition MAX98091.h:99
@ REG_MASTER_CLOCK
Definition MAX98091.h:46
@ REG_DEVICE_STATUS
Definition MAX98091.h:43
@ REG_EQUALIZER_BASE
Definition MAX98091.h:112
@ REG_INPUT_ENABLE
Definition MAX98091.h:104
@ REG_LEFT_ADC_MIXER
Definition MAX98091.h:63
@ REG_DSP_FILTER_ENABLE
Definition MAX98091.h:107
@ REG_DEVICE_SHUTDOWN
Definition MAX98091.h:111
@ REG_DMIC34_BIQUAD_BASE
Definition MAX98091.h:119
@ REG_DRC_COMPRESSOR
Definition MAX98091.h:94
@ REG_DMIC3_VOLUME
Definition MAX98091.h:114
@ REG_ANALOG_LINE_LOOP
Definition MAX98091.h:53
@ REG_MASTER_MODE
Definition MAX98091.h:75
@ REG_LEVEL_CONTROL
Definition MAX98091.h:106
@ REG_REVISION_ID
Definition MAX98091.h:120
@ REG_RESERVED
Definition MAX98091.h:54
@ REG_SPK_CONTROL
Definition MAX98091.h:90
@ REG_DRC_TIMING
Definition MAX98091.h:93
@ REG_TDM_FORMAT
Definition MAX98091.h:78
@ REG_LINE_INPUT_CONFIG
Definition MAX98091.h:55
@ REG_INPUT_MODE
Definition MAX98091.h:57
@ REG_LEFT_SPK_MIXER
Definition MAX98091.h:88
@ REG_RCV_LOUTL_MIXER
Definition MAX98091.h:97
@ REG_BIAS_CONTROL
Definition MAX98091.h:108
@ REG_CLOCK_RATIO_NI_MSB
Definition MAX98091.h:71
@ REG_CLOCK_MODE
Definition MAX98091.h:70
@ REG_RECORD_BIQUAD_BASE
Definition MAX98091.h:113
@ REG_JACK_DETECT
Definition MAX98091.h:103
@ REG_CLOCK_RATIO_NI_LSB
Definition MAX98091.h:72
@ REG_DRC_EXPANDER
Definition MAX98091.h:95
@ REG_ADC_CONTROL
Definition MAX98091.h:110
@ REG_ADC_SIDETONE
Definition MAX98091.h:68
@ REG_DAC_CONTROL
Definition MAX98091.h:109
@ REG_DMIC34_BQ_PREATTEN
Definition MAX98091.h:116
@ REG_LOUTR_CONTROL
Definition MAX98091.h:101
@ REG_LEFT_ADC_LEVEL
Definition MAX98091.h:65
@ REG_DAC_PATH
Definition MAX98091.h:49
@ REG_QUICK_SAMPLE_RATE
Definition MAX98091.h:47
@ REG_RIGHT_SPK_VOLUME
Definition MAX98091.h:92
@ REG_MIC1_INPUT_LEVEL
Definition MAX98091.h:58
@ REG_LEFT_HP_MIXER
Definition MAX98091.h:83
@ REG_RIGHT_SPK_MIXER
Definition MAX98091.h:89
@ REG_DAI_PLAYBACK_LEVEL_EQ
Definition MAX98091.h:82
@ REG_MIC_DIRECT_TO_ADC
Definition MAX98091.h:50
@ REG_FILTER_CONFIG
Definition MAX98091.h:80
@ REG_RIGHT_ADC_MIXER
Definition MAX98091.h:64
@ REG_RECORD_TDM_SLOT
Definition MAX98091.h:117
@ REG_CLOCK_RATIO_MI_MSB
Definition MAX98091.h:73
@ REG_RIGHT_HP_VOLUME
Definition MAX98091.h:87
@ REG_LOUTR_MIXER
Definition MAX98091.h:100
@ REG_RIGHT_HP_MIXER
Definition MAX98091.h:84
@ REG_LINE_INPUT_LEVEL
Definition MAX98091.h:56
@ REG_DAI_INTERFACE
Definition MAX98091.h:48
@ REG_SOFTWARE_RESET
Definition MAX98091.h:42
@ REG_DAI_PLAYBACK_LEVEL
Definition MAX98091.h:81
@ REG_IO_CONFIGURATION
Definition MAX98091.h:79
@ REG_INTERFACE_FORMAT
Definition MAX98091.h:76
@ REG_SAMPLE_RATE
Definition MAX98091.h:118
@ REG_MIC2_INPUT_LEVEL
Definition MAX98091.h:59
@ REG_OUTPUT_ENABLE
Definition MAX98091.h:105
@ REG_RCV_LOUTL_CONTROL
Definition MAX98091.h:98
@ REG_LOUTR_VOLUME
Definition MAX98091.h:102
@ REG_JACK_STATUS
Definition MAX98091.h:44
@ REG_ADC_BIQUAD_LEVEL
Definition MAX98091.h:67
@ REG_RIGHT_ADC_LEVEL
Definition MAX98091.h:66
@ REG_INTERRUPT_S
Definition MAX98091.h:45
@ REG_DMIC4_VOLUME
Definition MAX98091.h:115
@ REG_DIGITAL_MIC_ENABLE
Definition MAX98091.h:61
@ REG_MIC_BIAS_VOLTAGE
Definition MAX98091.h:60
@ REG_ANALOG_MIC_LOOP
Definition MAX98091.h:52
@ REG_DRC_GAIN
Definition MAX98091.h:96
@ REG_HP_CONTROL
Definition MAX98091.h:85
@ REG_CLOCK_RATIO_MI_LSB
Definition MAX98091.h:74
@ REG_LINE_TO_ADC
Definition MAX98091.h:51
@ REG_DIGITAL_MIC_CONFIG
Definition MAX98091.h:62
@ REG_LEFT_HP_VOLUME
Definition MAX98091.h:86
@ REG_SYSTEM_CLOCK
Definition MAX98091.h:69
@ REG_TDM_CONTROL
Definition MAX98091.h:77
static constexpr uint8_t MIXHPL_MIC2_MASK
Definition MAX98091.h:168
bool setProtocol(MAX98091Protocol protocol)
Configure the digital audio interface protocol (slave mode)
Definition MAX98091.h:322
static constexpr uint8_t MIXSPL_DACR_MASK
Definition MAX98091.h:199
static constexpr uint8_t MIXSPL_DACL_MASK
Definition MAX98091.h:200
bool setOutputVolume(uint8_t volume, MAX98091Channel channel=MAX98091Channel::All)
Definition MAX98091.h:413
static constexpr uint8_t MIXSPL_LINEA_MASK
Definition MAX98091.h:198
static constexpr uint8_t RCVLEN_MASK
Definition MAX98091.h:226
static constexpr uint8_t SR_96K_MASK
Definition MAX98091.h:127
static constexpr uint8_t MIXSPR_MASK
Definition MAX98091.h:211
bool readRevisionId(uint8_t &id)
Definition MAX98091.h:476
static constexpr uint8_t PSCLK_DIV4
Definition MAX98091.h:146
static constexpr uint8_t MIXHPL_MIC1_MASK
Definition MAX98091.h:169
static constexpr uint8_t MIXHPR_DACR_MASK
Definition MAX98091.h:180
static constexpr uint8_t WS_MASK
Definition MAX98091.h:156
static constexpr uint8_t MIXHPR_MASK
Definition MAX98091.h:182
static constexpr uint8_t HIZOFF_MASK
Definition MAX98091.h:163
static constexpr uint8_t SHDNN_MASK
Definition MAX98091.h:232
static constexpr uint8_t MIXSPRG_MASK
Definition MAX98091.h:214
bool setAudioFormat(uint32_t sample_rate, uint8_t word_size=16, uint8_t channels=2)
Configure the sample rate, channel count and word size of the digital audio interface.
Definition MAX98091.h:349
bool begin(uint32_t sample_rate, uint8_t bits, codec_mode_t mode, i2s_format_t fmt, bool is_master, uint8_t channels) override
Definition MAX98091.h:262
static constexpr uint8_t MIXHPL_LINEA_MASK
Definition MAX98091.h:171
static constexpr uint8_t WCI_MASK
Definition MAX98091.h:153
static constexpr uint8_t I2S_M_MASK
Definition MAX98091.h:139
static constexpr uint8_t DLY_MASK
Definition MAX98091.h:155
static constexpr uint8_t MIXSPL_LINEB_MASK
Definition MAX98091.h:197
static constexpr uint8_t MIXHPL_LINEB_MASK
Definition MAX98091.h:170
static constexpr uint8_t MIXHPR_LINEA_MASK
Definition MAX98091.h:179
static constexpr uint8_t HPREN_MASK
Definition MAX98091.h:222
static constexpr uint8_t SPLM_MASK
Definition MAX98091.h:218
static constexpr uint8_t PSCLK_DISABLED
Definition MAX98091.h:143
static constexpr uint8_t RJ_MASK
Definition MAX98091.h:152
static constexpr uint8_t DMONO_MASK
Definition MAX98091.h:162
static constexpr uint8_t MIXSPR_MIC2_MASK
Definition MAX98091.h:205
static constexpr uint8_t MIXSPR_LINEA_MASK
Definition MAX98091.h:208
static constexpr uint8_t SPREN_MASK
Definition MAX98091.h:224
static constexpr uint8_t MIXSPLG_MASK
Definition MAX98091.h:215
bool setVolume(int volume) override
Sets the output volume in % (0...100) for all channels.
Definition MAX98091.h:423
static constexpr uint8_t DALEN_MASK
Definition MAX98091.h:229
static constexpr uint8_t SPLEN_MASK
Definition MAX98091.h:225
static constexpr uint8_t RJ_S_MASK
Definition MAX98091.h:136
static constexpr uint8_t SWRESET_MASK
Definition MAX98091.h:124
static constexpr uint8_t MIXHPL_MASK
Definition MAX98091.h:174
static constexpr uint8_t MAS_MASK
Definition MAX98091.h:149
static constexpr uint8_t I2S_S_MASK
Definition MAX98091.h:140
static constexpr uint8_t MIXHPLSEL_MASK
Definition MAX98091.h:186
static constexpr uint8_t MIXSPR_LINEB_MASK
Definition MAX98091.h:207
static constexpr uint8_t SR_32K_MASK
Definition MAX98091.h:128
static constexpr uint8_t HPLEN_MASK
Definition MAX98091.h:223
static constexpr uint8_t MIXHPRSEL_MASK
Definition MAX98091.h:185
Common parent class for codec drivers that have been ported from the Zephyr RTOS audio driver impleme...
Definition ZephyrDriverCommon.h:22
uint8_t i2c_addr
Definition ZephyrDriverCommon.h:87
bool updateReg(uint8_t reg, uint8_t mask, uint8_t value)
Read-Modify-Write of a single byte register.
Definition ZephyrDriverCommon.h:110
int volume_percent
Last volume (in %) provided to setVolume()
Definition ZephyrDriverCommon.h:89
bool readReg(uint8_t reg, uint8_t &value, bool stopBit=true)
Reads a single byte from an 8 bit register address.
Definition ZephyrDriverCommon.h:100
bool writeReg(uint8_t reg, uint8_t value)
Writes a single byte to an 8 bit register address.
Definition ZephyrDriverCommon.h:94
Namespace for audio driver components.
Definition AudioBoard.h:5
input_device_t
Definition DriverCommon.h:170
void delayMs(unsigned long ms)
Definition API_Delay.h:19
codec_mode_t
Definition DriverCommon.h:290
@ CODEC_MODE_DECODE
Definition DriverCommon.h:294
output_device_t
Definition DriverCommon.h:186
@ DAC_OUTPUT_LINE1
Definition DriverCommon.h:188
@ DAC_OUTPUT_ALL
Definition DriverCommon.h:190
@ DAC_OUTPUT_LINE2
Definition DriverCommon.h:189
MAX98091Channel
Logical audio channels.
Definition MAX98091.h:23
MAX98091Protocol
Digital audio interface protocol (slave mode)
Definition MAX98091.h:16
i2s_format_t
Definition DriverCommon.h:250
@ I2S_RIGHT
Definition DriverCommon.h:253
@ I2S_LEFT
Definition DriverCommon.h:252