10#ifndef PIN_AUDIO_KIT_SD_CARD_CS
11#define PIN_AUDIO_KIT_SD_CARD_CS 13
12#define PIN_AUDIO_KIT_SD_CARD_MISO 2
13#define PIN_AUDIO_KIT_SD_CARD_MOSI 15
14#define PIN_AUDIO_KIT_SD_CARD_CLK 14
19using namespace audio_driver;
22#if !defined(AUDIO_DRIVER_USE_NEW_API)
72 auto cfg_default =
i2s.defaultConfig(mode);
74 cfg.copyFrom(cfg_default);
75 cfg.input_device = ADC_INPUT_LINE1;
76 cfg.output_device = DAC_OUTPUT_ALL;
78 cfg.rx_tx_mode = mode;
109 cfg.sample_rate =
info.sample_rate;
110 cfg.bits_per_sample =
info.bits_per_sample;
123 if (
cfg.sample_rate ==
info.sample_rate &&
124 cfg.bits_per_sample ==
info.bits_per_sample &&
125 cfg.channels ==
info.channels) {
134 virtual size_t write(
const uint8_t *data,
size_t len) {
135 LOGD(
"I2SStream::write: %d", len);
136 return i2s.write(data, len);
140 virtual size_t readBytes(uint8_t *data,
size_t len)
override {
141 return i2s.readBytes(data, len);
154 return p_board->setVolume(vol * 100.0);
159 if (
p_board ==
nullptr)
return 0.0f;
160 return static_cast<float>(
p_board->getVolume()) / 100.0f;
167 if (
p_board ==
nullptr)
return false;
172 if (
p_board ==
nullptr)
return false;
173 return p_board->setMute(mute, line);
178 if (
p_board ==
nullptr)
return false;
179 return p_board->setPAPower(active);
185 return p_board->setInputVolume(100.0 * vol);
200 return p_board->getPins().getPinID(function);
206 return p_board->getPins().getPinID(function, pos);
219 p_board->getPins().getGPIO().digitalWrite(pin, value);
224 return p_board->getPins().getGPIO().digitalRead(pin);
261 if (tobeVol >= 0.0f) {
269 if (
cfg.i2s_function == PinFunction::UNDEFINED){
271 auto i2s =
p_board->getPins().getI2SPins(PinFunction::CODEC_ADC);
273 cfg.i2s_function = PinFunction::CODEC_ADC;
274 LOGI(
"using i2s_function: CODEC_ADC");
276 cfg.i2s_function = PinFunction::CODEC;
279 cfg.i2s_function = PinFunction::CODEC;
291 PinsI2S i2s_pins =
i2s.value();
292#if defined(__zephyr__)
294 if (i2s_pins.dev !=
nullptr){
295 cfg.dev = i2s_pins.dev;
298 cfg.pin_bck = i2s_pins.bck;
299 cfg.pin_mck = i2s_pins.mclk;
300 cfg.pin_ws = i2s_pins.ws;
301 switch (
cfg.rx_tx_mode) {
303 cfg.pin_data = i2s_pins.data_in;
306 cfg.pin_data = i2s_pins.data_out;
309 cfg.pin_data = i2s_pins.data_out;
310 cfg.pin_data_rx = i2s_pins.data_in;
319 audio_driver_local::Optional<PinsI2S>
i2s;
321 return p_board->getPins().getI2SPins(
cfg.i2s_function);
326 switch (
cfg.rx_tx_mode) {
329 codec_cfg.output_device = DAC_OUTPUT_NONE;
342 LOGD(
"input: %d",
info.input_device);
343 LOGD(
"output: %d",
info.output_device);
351 codec_cfg.i2s.mode =
info.is_master ? MODE_SLAVE : MODE_MASTER;
352 if (
p_board ==
nullptr)
return false;
361 LOGD(
"BIT_LENGTH_16BITS");
362 return BIT_LENGTH_16BITS;
364 LOGD(
"BIT_LENGTH_24BITS");
365 return BIT_LENGTH_24BITS;
367 LOGD(
"BIT_LENGTH_32BITS");
368 return BIT_LENGTH_32BITS;
370 LOGE(
"Unsupported bits: %d", bits);
371 return BIT_LENGTH_16BITS;
398 if (rate <= 48000 || rate > 48000) {
402 LOGE(
"Invalid rate: %d using 44K", rate);
424 LOGE(
"unsupported mode");
RxTxMode
The Microcontroller is the Audio Source (TX_MODE) or Audio Sink (RX_MODE). RXTX_MODE is Source and Si...
Definition AudioTypes.h:26
@ TX_MODE
Definition AudioTypes.h:26
@ RX_MODE
Definition AudioTypes.h:26