arduino-audio-tools
Loading...
Searching...
No Matches
I2SDriverESP32V1.h
Go to the documentation of this file.
1#pragma once
2
3#include "AudioToolsConfig.h"
4#if defined(ESP32) && !USE_LEGACY_I2S || defined(DOXYGEN)
5
8#include "driver/i2s_pdm.h"
9#include "driver/i2s_std.h"
10#include "driver/i2s_tdm.h"
11#include "esp_system.h"
12
13#define IS_I2S_IMPLEMENTED
14
15namespace audio_tools {
16
17// i2s_port_t not valid any more in ESP-IDF v6, but we keep it for compatibility
18#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(6, 0, 0)
19using i2s_port_t = int;
20#endif
21
22// support for Arduino ESP32 v3.0.7
23#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(5, 1, 4)
24#define I2S_MCLK_MULTIPLE_192 static_cast<i2s_mclk_multiple_t>(192)
25#endif
26
27
36 public:
39 I2SConfigESP32V1 c(mode);
40 return c;
41 }
44 // nothing to do
45 if (is_started) {
46 if (info.equals(cfg)) return true;
47 if (info.equalsExSampleRate(cfg)) {
49 LOGI("i2s_set_sample_rates: %d", (int)info.sample_rate);
51 }
52 } else {
53 LOGE("not started");
54 }
55 return false;
56 }
57
59 bool begin(RxTxMode mode) { return begin(defaultConfig(mode)); }
60
63 bool begin() { return (!is_started) ? begin(cfg) : true; }
64
67 TRACED();
68 this->cfg = cfg;
69
70 // stop if it is already open
71 if (is_started) end();
72
73 switch (cfg.rx_tx_mode) {
74 case TX_MODE:
76 case RX_MODE:
77 // usually we expet cfg.pin_data but if the used assinged rx we might
78 // consider this one
81 : cfg.pin_data);
82 default:
84 }
85 LOGE("Did not expect go get here");
86 }
87
90
93
95 void end() {
96 TRACED();
97 if (rx_chan != nullptr) {
100 rx_chan = nullptr;
101 }
102 if (tx_chan != nullptr) {
105 tx_chan = nullptr;
106 }
107
108 is_started = false;
109 }
110
113
115 size_t writeBytes(const void *src, size_t size_bytes) {
116 TRACED();
117 size_t result;
118 assert(tx_chan != nullptr);
119 if (i2s_channel_write(tx_chan, src, size_bytes, &result,
121 TRACEE();
122 }
123 return result;
124 }
125
126 size_t readBytes(void *dest, size_t size_bytes) {
127 size_t result = 0;
128 if (i2s_channel_read(rx_chan, dest, size_bytes, &result,
130 TRACEE();
131 }
132 return result;
133 }
134
141
142 protected:
145 i2s_chan_handle_t tx_chan = nullptr; // I2S tx channel handler
146 i2s_chan_handle_t rx_chan = nullptr; // I2S rx channel handler
147 bool is_started = false;
150
155 int rxPin) = 0;
156
158 // changes the sample rate
162 return false;
163 }
164
165 protected:
167 int get_bits_eff(int bits) { return (bits == 24) ? 32 : bits; }
168 };
169
170 struct DriverI2S : public DriverCommon {
173 TRACED();
174 LOGI("tx: %d, rx: %d", txPin, rxPin);
176 std_cfg.clk_cfg = getClockConfig(cfg);
177 std_cfg.slot_cfg = getSlotConfig(cfg);
178 std_cfg.gpio_cfg = {
179 .mclk = (gpio_num_t)cfg.pin_mck,
180 .bclk = (gpio_num_t)cfg.pin_bck,
181 .ws = (gpio_num_t)cfg.pin_ws,
182 .dout = (gpio_num_t)txPin,
183 .din = (gpio_num_t)rxPin,
184 .invert_flags =
185 {
186 .mclk_inv = false,
187 .bclk_inv = false,
188 .ws_inv = false,
189 },
190 };
191
192
195 LOGE("i2s_channel_init_std_mode %s", "tx");
196 return false;
197 }
199 LOGE("i2s_channel_enable %s", "tx");
200 return false;
201 }
202 }
203
206 LOGE("i2s_channel_init_std_mode %s", "rx");
207 return false;
208 }
210 LOGE("i2s_channel_enable %s", "rx");
211 return false;
212 }
213 }
214
215 LOGD("%s - %s", __func__, "started");
216 return true;
217 }
218
219 protected:
221 TRACED();
223 switch (cfg.i2s_format) {
225 case I2S_MSB_FORMAT:
229 break;
230 case I2S_PCM:
234 break;
235 default:
239 }
240
241 // Update slot_mask if only one channel
242 if (cfg.channels == 1) {
243 switch (cfg.channel_format) {
245 result.slot_mask = I2S_STD_SLOT_LEFT;
246 break;
248 result.slot_mask = I2S_STD_SLOT_RIGHT;
249 break;
250 default:
251 LOGW("Using channel_format: I2SChannelSelect::Left for mono");
252 result.slot_mask = I2S_STD_SLOT_LEFT;
253 break;
254 }
255 }
256
257 return result;
258 }
259
261 TRACED();
265 // use the legicy size parameters for frame num
266 int size = cfg.buffer_size * cfg.buffer_count;
267 int frame_size = get_bits_eff(cfg.bits_per_sample) * cfg.channels / 8;
268 frame_size = (frame_size == 0) ? 1 : frame_size;
269 if (size > 0) result.dma_frame_num = size / frame_size;
270 LOGI("dma_frame_num: %d", (int)result.dma_frame_num);
271 result.auto_clear = cfg.auto_clear;
272 return result;
273 }
274
276 TRACED();
277 i2s_std_clk_config_t clk_cfg;// = I2S_STD_CLK_DEFAULT_CONFIG((uint32_t)cfg.sample_rate);
278 memset(&clk_cfg, 0, sizeof(i2s_std_clk_config_t));
279 clk_cfg.sample_rate_hz = cfg.sample_rate;
280 clk_cfg.clk_src = getClockSource(cfg);
281 // clk_cfg.ext_clk_freq_hz = 0;
282
283 if (cfg.mclk_multiple > 0) {
285 LOGI("mclk_multiple=%d", clk_cfg.mclk_multiple);
286 } else {
287 if (cfg.bits_per_sample == 24) {
288 // mclk_multiple' should be the multiple of 3 while using 24-bit
289 // using the apll seems to double the frequency
291 LOGI("mclk_multiple=384");
292 } else {
293 // when use_appll is true, the multiple of 128 gives 256kHz
294 // using the apll seems to double the frequency
296 LOGI("mclk_multiple=%d", clk_cfg.mclk_multiple);
297 }
298 }
299
300 return clk_cfg;
301 }
302
306 // use mclk pin as input in slave mode if supported
307 if (cfg.pin_mck != -1 && !cfg.is_master) {
308#if SOC_I2S_HW_VERSION_2
309 LOGI("pin_mclk is input");
310 result = I2S_CLK_SRC_EXTERNAL;
311 return result;
312#else
313 LOGE("pin_mclk as input not supported");
314#endif
315 }
316
317 // select APLL clock if possible
318 if (cfg.use_apll) {
319 // select clock source
320#if SOC_I2S_SUPPORTS_APLL
321 result = I2S_CLK_SRC_APLL;
322 LOGI("clk_src is I2S_CLK_SRC_APLL");
323#elif SOC_I2S_SUPPORTS_PLL_F160M
324 result = I2S_CLK_SRC_PLL_160M;
325 LOGI("clk_src is I2S_CLK_SRC_PLL_160M");
326#endif
327 }
328
329 return result;
330 }
331
348
350
351#ifdef USE_PDM
352
353 struct DriverPDM : public DriverCommon {
354 bool startChannels(I2SConfigESP32V1 &cfg, i2s_chan_handle_t &tx_chan,
355 i2s_chan_handle_t &rx_chan, int txPin, int rxPin) {
356 if (cfg.rx_tx_mode == TX_MODE) {
357 return startTX(cfg, tx_chan, txPin);
358 } else if (cfg.rx_tx_mode == RX_MODE) {
359 return startRX(cfg, rx_chan, rxPin);
360 }
361 LOGE("Only RX and TX is supported for PDM")
362 return false;
363 }
364
365 protected:
366 i2s_pdm_tx_slot_config_t getTxSlotConfig(I2SConfigESP32V1 &cfg) {
367#ifdef SOC_I2S_HW_VERSION_2
368 return I2S_PDM_TX_SLOT_DAC_DEFAULT_CONFIG(
369 (i2s_data_bit_width_t)cfg.bits_per_sample,
370 (i2s_slot_mode_t)cfg.channels);
371#else
372 return I2S_PDM_TX_SLOT_DEFAULT_CONFIG(
373 (i2s_data_bit_width_t)cfg.bits_per_sample,
374 (i2s_slot_mode_t)cfg.channels);
375#endif
376 }
377
378 i2s_chan_config_t getChannelConfig(I2SConfigESP32V1 &cfg) {
379 return I2S_CHANNEL_DEFAULT_CONFIG(
380 (i2s_port_t)cfg.port_no,
381 cfg.is_master ? I2S_ROLE_MASTER : I2S_ROLE_SLAVE);
382 }
383
384 i2s_pdm_tx_clk_config_t getTxClockConfig(I2SConfigESP32V1 &cfg) {
385#if defined(I2S_PDM_TX_CLK_DAC_DEFAULT_CONFIG)
386 return I2S_PDM_TX_CLK_DAC_DEFAULT_CONFIG((uint32_t)cfg.sample_rate);
387#else
388 return I2S_PDM_TX_CLK_DEFAULT_CONFIG((uint32_t)cfg.sample_rate);
389#endif
390 }
391
392 bool startTX(I2SConfigESP32V1 &cfg, i2s_chan_handle_t &tx_chan, int txPin) {
393 i2s_pdm_tx_config_t pdm_tx_cfg = {
394 .clk_cfg = getTxClockConfig(cfg),
395 .slot_cfg = getTxSlotConfig(cfg),
396 .gpio_cfg =
397 {
398 .clk = (gpio_num_t)cfg.pin_bck,
399 .dout = (gpio_num_t)txPin,
400#if SOC_I2S_PDM_MAX_TX_LINES > 1
401 .dout2 = I2S_GPIO_UNUSED, // required in IDF v6+
402#endif
403 .invert_flags =
404 {
405 .clk_inv = false,
406 },
407 },
408 };
409
410 if (i2s_channel_init_pdm_tx_mode(tx_chan, &pdm_tx_cfg) != ESP_OK) {
411 LOGE("i2s_channel_init_pdm_tx_mode %s", "tx");
412 return false;
413 }
414 if (i2s_channel_enable(tx_chan) != ESP_OK) {
415 LOGE("i2s_channel_enable %s", "tx");
416 return false;
417 }
418 return true;
419 }
420
421#if defined(USE_PDM_RX)
422 i2s_pdm_rx_slot_config_t getRxSlotConfig(I2SConfigESP32V1 &cfg) {
423 return I2S_PDM_RX_SLOT_DEFAULT_CONFIG(
424 (i2s_data_bit_width_t)cfg.bits_per_sample,
425 (i2s_slot_mode_t)cfg.channels);
426 }
427 i2s_pdm_rx_clk_config_t getRxClockConfig(I2SConfigESP32V1 &cfg) {
428 return I2S_PDM_RX_CLK_DEFAULT_CONFIG((uint32_t)cfg.sample_rate);
429 }
430 bool startRX(I2SConfigESP32V1 &cfg, i2s_chan_handle_t &rx_chan, int rxPin) {
431 i2s_pdm_rx_config_t pdm_rx_cfg = {
432 .clk_cfg = getRxClockConfig(cfg),
433 .slot_cfg = getRxSlotConfig(cfg),
434 .gpio_cfg =
435 {
436 .clk = (gpio_num_t)cfg.pin_bck,
437 .din = (gpio_num_t)rxPin,
438 .invert_flags =
439 {
440 .clk_inv = false,
441 },
442 },
443 };
444
445 if (i2s_channel_init_pdm_rx_mode(rx_chan, &pdm_rx_cfg) != ESP_OK) {
446 LOGE("i2s_channel_init_pdm_rx_mode %s", "rx");
447 return false;
448 }
449 if (i2s_channel_enable(rx_chan) != ESP_OK) {
450 LOGE("i2s_channel_enable %s", "tx");
451 return false;
452 }
453 return true;
454 }
455#else
456 bool startRX(I2SConfigESP32V1 &cfg, i2s_chan_handle_t &rx_chan, int rxPin) {
457 LOGE("PDM RX not supported");
458 return false;
459 }
460#endif
461 } pdm;
462
463#endif
464
465#ifdef USE_TDM
466 // example at
467 // https://github.com/espressif/esp-idf/blob/v5.3-dev/examples/peripherals/i2s/i2s_basic/i2s_tdm/main/i2s_tdm_example_main.c
468 struct DriverTDM : public DriverCommon {
469 bool startChannels(I2SConfigESP32V1 &cfg, i2s_chan_handle_t &tx_chan,
470 i2s_chan_handle_t &rx_chan, int txPin, int rxPin) {
471 i2s_tdm_config_t tdm_cfg = {
472 .clk_cfg = getClockConfig(cfg),
473 .slot_cfg = getSlotConfig(cfg),
474 .gpio_cfg =
475 {
476 .mclk = (gpio_num_t)cfg.pin_mck,
477 .bclk = (gpio_num_t)cfg.pin_bck,
478 .ws = (gpio_num_t)cfg.pin_ws,
479 .dout = (gpio_num_t)txPin,
480 .din = (gpio_num_t)rxPin,
481 .invert_flags =
482 {
483 .mclk_inv = false,
484 .bclk_inv = false,
485 .ws_inv = false,
486 },
487 },
488 };
489
490 if (cfg.rx_tx_mode == TX_MODE || cfg.rx_tx_mode == RXTX_MODE) {
491 if (i2s_channel_init_tdm_mode(tx_chan, &tdm_cfg) != ESP_OK) {
492 LOGE("i2s_channel_init_tdm_tx_mode %s", "tx");
493 return false;
494 }
495 }
496 if (cfg.rx_tx_mode == RX_MODE || cfg.rx_tx_mode == RXTX_MODE) {
497 if (i2s_channel_init_tdm_mode(rx_chan, &tdm_cfg) != ESP_OK) {
498 LOGE("i2s_channel_init_tdm_tx_mode %s", "rx");
499 return false;
500 }
501 }
502 return true;
503 }
504
505 protected:
506 i2s_tdm_slot_config_t getSlotConfig(I2SConfigESP32V1 &cfg) {
507 int slots = 0;
508 for (int j = 0; j < cfg.channels; j++) {
509 slots |= 1 << j;
510 }
511 // setup default format
512 i2s_tdm_slot_config_t slot_cfg = I2S_TDM_PHILIPS_SLOT_DEFAULT_CONFIG(
513 (i2s_data_bit_width_t)cfg.bits_per_sample, I2S_SLOT_MODE_STEREO,
514 (i2s_tdm_slot_mask_t)slots);
515
516 switch (cfg.i2s_format) {
518 case I2S_LSB_FORMAT:
520 case I2S_STD_FORMAT:
521 slot_cfg = I2S_TDM_PHILIPS_SLOT_DEFAULT_CONFIG(
522 (i2s_data_bit_width_t)cfg.bits_per_sample, I2S_SLOT_MODE_STEREO,
523 (i2s_tdm_slot_mask_t)slots);
524 break;
526 case I2S_MSB_FORMAT:
527 slot_cfg = I2S_TDM_MSB_SLOT_DEFAULT_CONFIG(
528 (i2s_data_bit_width_t)cfg.bits_per_sample, I2S_SLOT_MODE_STEREO,
529 (i2s_tdm_slot_mask_t)slots);
530 break;
531 case I2S_PCM:
532 slot_cfg = I2S_TDM_PCM_LONG_SLOT_DEFAULT_CONFIG(
533 (i2s_data_bit_width_t)cfg.bits_per_sample, I2S_SLOT_MODE_STEREO,
534 (i2s_tdm_slot_mask_t)slots);
535 break;
536 default:
537 LOGE("TDM: Unsupported format");
538 }
539
540 return slot_cfg;
541 }
542
543 i2s_chan_config_t getChannelConfig(I2SConfigESP32V1 &cfg) {
544 return I2S_CHANNEL_DEFAULT_CONFIG(
545 (i2s_port_t)cfg.port_no,
546 cfg.is_master ? I2S_ROLE_MASTER : I2S_ROLE_SLAVE);
547 }
548
549 i2s_tdm_clk_config_t getClockConfig(I2SConfigESP32V1 &cfg) {
550 return I2S_TDM_CLK_DEFAULT_CONFIG((uint32_t)cfg.sample_rate);
551 }
552
553 } tdm;
554
555#endif
556
558
561 TRACED();
562 cfg.logInfo();
563 this->cfg = cfg;
564 if (cfg.channels <= 0 || cfg.channels > 2) {
565 LOGE("invalid channels: %d", cfg.channels);
566 return false;
567 }
568
569 DriverCommon &driver = getDriver(cfg);
570 if (!newChannels(cfg, driver)) {
571 end();
572 return false;
573 }
574
576 if (!is_started) {
577 end();
578 LOGE("Channels not started");
579 }
580 return is_started;
581 }
582
585 switch (cfg.rx_tx_mode) {
586 case RX_MODE:
588 LOGE("i2s_channel");
589 return false;
590 }
591 break;
592 case TX_MODE:
594 LOGE("i2s_channel");
595 return false;
596 }
597 break;
598 default:
600 LOGE("i2s_channel");
601 return false;
602 }
603 }
604 return true;
605 }
606
608 switch (cfg.signal_type) {
609 case Digital:
610 return i2s;
611#ifdef USE_PDM
612 case Analog:
613 case PDM:
614 return pdm;
615#endif
616#ifdef USE_TDM
617 case TDM:
618 return tdm;
619#endif
620 default:
621 break;
622 }
623 LOGE("Unsupported signal_type");
624 return i2s;
625 }
626};
627
628using I2SDriver = I2SDriverESP32V1;
629
630} // namespace audio_tools
631
632#endif
#define LOGW(...)
Definition AudioLoggerIDF.h:29
#define TRACED()
Definition AudioLoggerIDF.h:31
#define LOGI(...)
Definition AudioLoggerIDF.h:28
#define TRACEE()
Definition AudioLoggerIDF.h:34
#define LOGD(...)
Definition AudioLoggerIDF.h:27
#define LOGE(...)
Definition AudioLoggerIDF.h:30
#define I2S_BUFFER_SIZE
Definition AudioToolsConfig.h:112
#define I2S_BUFFER_COUNT
Definition AudioToolsConfig.h:116
#define I2S_MCLK_MULTIPLE_192
Definition I2SDriverESP32V1.h:24
#define portMAX_DELAY
Definition QueueZephyr.h:14
#define pdMS_TO_TICKS(ms)
Definition QueueZephyr.h:17
uint32_t TickType_t
Definition QueueZephyr.h:11
#define assert(T)
Definition avr.h:10
Configuration for ESP32 i2s for IDF > 5.0.
Definition I2SConfigESP32V1.h:21
int buffer_count
not used any more
Definition I2SConfigESP32V1.h:65
int pin_mck
Definition I2SConfigESP32V1.h:63
RxTxMode rx_tx_mode
public settings
Definition I2SConfigESP32V1.h:54
int pin_ws
Definition I2SConfigESP32V1.h:59
bool auto_clear
Definition I2SConfigESP32V1.h:69
I2SSignalType signal_type
Definition I2SConfigESP32V1.h:56
int pin_data
Definition I2SConfigESP32V1.h:61
int pin_data_rx
Definition I2SConfigESP32V1.h:62
bool use_apll
Definition I2SConfigESP32V1.h:68
int mclk_multiple
masterclock multiple (-1 = use default)
Definition I2SConfigESP32V1.h:73
bool is_master
Definition I2SConfigESP32V1.h:57
int pin_bck
Definition I2SConfigESP32V1.h:60
I2SFormat i2s_format
Definition I2SConfigESP32V1.h:55
void logInfo(const char *source="")
Definition I2SConfigESP32V1.h:75
int port_no
Definition I2SConfigESP32V1.h:58
I2SChannelSelect channel_format
Select left or right channel when channels == 1.
Definition I2SConfigESP32V1.h:71
int buffer_size
not used any more
Definition I2SConfigESP32V1.h:67
Definition I2SDriverBase.h:7
Basic I2S API for the ESP32 (using the new API). https://docs.espressif.com/projects/esp-idf/en/v5....
Definition I2SDriverESP32V1.h:35
I2SConfigESP32V1 defaultConfig(RxTxMode mode)
Provides the default configuration.
Definition I2SDriverESP32V1.h:38
void setWaitTimeWriteMs(TickType_t ms)
Definition I2SDriverESP32V1.h:138
bool begin(I2SConfigESP32V1 cfg)
starts the DAC
Definition I2SDriverESP32V1.h:66
i2s_chan_handle_t rx_chan
Definition I2SDriverESP32V1.h:146
TickType_t ticks_to_wait_read
Definition I2SDriverESP32V1.h:148
audio_tools::I2SDriverESP32V1::DriverI2S i2s
void setWaitTimeReadMs(TickType_t ms)
Definition I2SDriverESP32V1.h:135
int available()
we assume the data is already available in the buffer
Definition I2SDriverESP32V1.h:89
bool is_started
Definition I2SDriverESP32V1.h:147
bool begin()
Definition I2SDriverESP32V1.h:63
bool setAudioInfo(AudioInfo info)
Potentially updates the sample rate (if supported)
Definition I2SDriverESP32V1.h:43
i2s_chan_handle_t tx_chan
Definition I2SDriverESP32V1.h:145
bool newChannels(I2SConfigESP32V1 &cfg, DriverCommon &driver)
Definition I2SDriverESP32V1.h:583
int availableForWrite()
We limit the write size to the buffer size.
Definition I2SDriverESP32V1.h:92
I2SConfigESP32V1 config()
provides the actual configuration
Definition I2SDriverESP32V1.h:112
DriverCommon & getDriver(I2SConfigESP32V1 &cfg)
Definition I2SDriverESP32V1.h:607
void end()
stops the I2C and unistalls the driver
Definition I2SDriverESP32V1.h:95
bool begin(RxTxMode mode)
starts the DAC with the default config
Definition I2SDriverESP32V1.h:59
bool begin(I2SConfigESP32V1 cfg, int txPin, int rxPin)
-> protected methods from I2SDriverESP32V1
Definition I2SDriverESP32V1.h:560
TickType_t ticks_to_wait_write
Definition I2SDriverESP32V1.h:149
size_t writeBytes(const void *src, size_t size_bytes)
writes the data to the I2S interface
Definition I2SDriverESP32V1.h:115
I2SConfigESP32V1 cfg
Definition I2SDriverESP32V1.h:143
i2s_std_config_t i2s_config
Definition I2SDriverESP32V1.h:144
size_t readBytes(void *dest, size_t size_bytes)
Definition I2SDriverESP32V1.h:126
RxTxMode
The Microcontroller is the Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Si...
Definition AudioTypes.h:26
@ RXTX_MODE
Definition AudioTypes.h:26
@ TX_MODE
Definition AudioTypes.h:26
@ RX_MODE
Definition AudioTypes.h:26
Generic Implementation of sound input and output for desktop environments using portaudio.
Definition AudioCodecsBase.h:10
@ Digital
Definition AudioTypes.h:438
@ PDM
Definition AudioTypes.h:440
@ TDM
Definition AudioTypes.h:441
@ Analog
Definition AudioTypes.h:439
@ I2S_STD_FORMAT
Definition AudioTypes.h:417
@ I2S_PHILIPS_FORMAT
Definition AudioTypes.h:420
@ I2S_LSB_FORMAT
Definition AudioTypes.h:418
@ I2S_LEFT_JUSTIFIED_FORMAT
Definition AudioTypes.h:422
@ I2S_RIGHT_JUSTIFIED_FORMAT
Definition AudioTypes.h:421
@ I2S_MSB_FORMAT
Definition AudioTypes.h:419
@ I2S_PCM
Definition AudioTypes.h:423
int i2s_port_t
Definition I2SDriverESP32V1.h:19
I2SDriverESP32 I2SDriver
Definition I2SDriverESP32.h:403
size_t writeData(Print *p_out, T *data, int samples, int maxSamples=512)
Definition AudioTypes.h:508
Basic Audio information which drives e.g. I2S.
Definition AudioTypes.h:51
sample_rate_t sample_rate
Sample Rate: e.g 44100.
Definition AudioTypes.h:53
bool equals(AudioInfo alt)
Returns true if alt values are the same like the current values.
Definition AudioTypes.h:83
uint16_t channels
Number of channels: 2=stereo, 1=mono.
Definition AudioTypes.h:55
bool equalsExSampleRate(AudioInfo alt)
Checks if only the sample rate is different.
Definition AudioTypes.h:86
uint8_t bits_per_sample
Number of bits per sample (int16_t = 16 bits)
Definition AudioTypes.h:57
Definition I2SDriverESP32V1.h:151
virtual i2s_chan_config_t getChannelConfig(I2SConfigESP32V1 &cfg)=0
int get_bits_eff(int bits)
24 bits are stored in a 32 bit integer
Definition I2SDriverESP32V1.h:167
virtual bool startChannels(I2SConfigESP32V1 &cfg, i2s_chan_handle_t &tx_chan, i2s_chan_handle_t &rx_chan, int txPin, int rxPin)=0
virtual bool changeSampleRate(I2SConfigESP32V1 &cfg, i2s_chan_handle_t &tx_chan, i2s_chan_handle_t &rx_chan)
Definition I2SDriverESP32V1.h:159
Definition I2SDriverESP32V1.h:170
bool startChannels(I2SConfigESP32V1 &cfg, i2s_chan_handle_t &tx_chan, i2s_chan_handle_t &rx_chan, int txPin, int rxPin)
Definition I2SDriverESP32V1.h:171
i2s_std_slot_config_t getSlotConfig(I2SConfigESP32V1 &cfg)
Definition I2SDriverESP32V1.h:220
i2s_chan_config_t getChannelConfig(I2SConfigESP32V1 &cfg)
Definition I2SDriverESP32V1.h:260
i2s_std_clk_config_t getClockConfig(I2SConfigESP32V1 &cfg)
Definition I2SDriverESP32V1.h:275
bool changeSampleRate(I2SConfigESP32V1 &cfg, i2s_chan_handle_t &tx_chan, i2s_chan_handle_t &rx_chan) override
Definition I2SDriverESP32V1.h:332
soc_periph_i2s_clk_src_t getClockSource(I2SConfigESP32V1 &cfg)
select clock source dependent on is_master and use_apll
Definition I2SDriverESP32V1.h:304