mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-07 09:55:45 +00:00
esp32: audio use I2S config from LyraT v4.3 board
This commit is contained in:
parent
ea6419f9b7
commit
52a720ae15
@ -52,17 +52,22 @@ There are different issues in the Bluetooth Controller of the ESP32 that is prov
|
||||
|
||||
### Audio playback
|
||||
|
||||
Audio playback is implemented by `btstack_audio_esp32.c`. It assumes an I2S Codec connected as follows:
|
||||
|
||||
Audio playback is implemented by `btstack_audio_esp32.c` and supports generic I2S codecs as well as the ES8388 on the [ESP32 LyraT v4.3](https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/board-esp32-lyrat-v4.3.html) devkit.
|
||||
|
||||
It uses the first I2S interface with the following pin out:
|
||||
|
||||
ESP32 pin | I2S Pin
|
||||
----------|---------
|
||||
GPIO0 | MCK
|
||||
GPIO5 | BCLK
|
||||
GPIO25 | LRCK
|
||||
GPIO26 | BCLK
|
||||
GPIO22 | DATA
|
||||
GPIO26 | DOUT
|
||||
GPIO35 | DIN
|
||||
|
||||
We've used the MAX98357A on the [Adafruit breakout board](https://www.adafruit.com/product/3006). The simplest example is the mod_player, which plays back an 8 kB sound file and the a2dp_sink_demo implements a basic Bluetooth loudspeaker.
|
||||
If support for the LyraT v4.3 is enabled, e.g. via menuconfig - Example Board Configuration --> ESP32 board --> ESP32-LyraT V4.3, CONFIG_ESP_LYRAT_V4_3_BOARD gets defined and the ES8388 will be configured as well.
|
||||
|
||||
We've also used the MAX98357A on the [Adafruit breakout board](https://www.adafruit.com/product/3006). The simplest example is the mod_player, which plays back an 8 kB sound file and the a2dp_sink_demo that implements a basic Bluetooth loudspeaker.
|
||||
|
||||
Audio input via I2S or ADC is not supported yet. We might have a look at it when [HFP/SCO via VHCI](https://github.com/espressif/esp-idf/issues/1118) is working on the ESP32.
|
||||
|
||||
### Multi-Threading
|
||||
|
||||
|
@ -187,30 +187,28 @@ static void btstack_audio_esp32_init(void){
|
||||
i2s_driver_uninstall(BTSTACK_AUDIO_I2S_NUM);
|
||||
}
|
||||
|
||||
// set i2s mode and pins based on sink / source state
|
||||
// set i2s mode, sample rate and pins based on sink / source config
|
||||
i2s_mode_t i2s_mode = I2S_MODE_MASTER;
|
||||
int i2s_data_out_pin = I2S_PIN_NO_CHANGE;
|
||||
int i2s_data_in_pin = I2S_PIN_NO_CHANGE;
|
||||
#ifdef CONFIG_ESP_LYRAT_V4_3_BOARD
|
||||
int i2s_bck_io_pin = GPIO_NUM_5;
|
||||
#else
|
||||
int i2s_bck_io_pin = 26;
|
||||
#endif
|
||||
btstack_audio_esp32_i2s_samplerate = 0;
|
||||
|
||||
if (btstack_audio_esp32_sink_state != BTSTACK_AUDIO_ESP32_OFF){
|
||||
i2s_mode |= I2S_MODE_TX; // playback
|
||||
btstack_audio_esp32_i2s_samplerate = btstack_audio_esp32_sink_samplerate;
|
||||
#ifdef CONFIG_ESP_LYRAT_V4_3_BOARD
|
||||
i2s_data_out_pin = GPIO_NUM_26;
|
||||
#else
|
||||
i2s_data_out_pin = 22;
|
||||
#endif
|
||||
if (btstack_audio_esp32_i2s_samplerate != 0){
|
||||
btstack_assert(btstack_audio_esp32_i2s_samplerate == btstack_audio_esp32_sink_samplerate);
|
||||
}
|
||||
btstack_audio_esp32_i2s_samplerate = btstack_audio_esp32_sink_samplerate;
|
||||
}
|
||||
|
||||
if (btstack_audio_esp32_source_state != BTSTACK_AUDIO_ESP32_OFF){
|
||||
i2s_mode |= I2S_MODE_RX; // recording
|
||||
btstack_audio_esp32_i2s_samplerate = btstack_audio_esp32_source_samplerate;
|
||||
#ifdef CONFIG_ESP_LYRAT_V4_3_BOARD
|
||||
i2s_data_in_pin = GPIO_NUM_35;
|
||||
#endif
|
||||
if (btstack_audio_esp32_i2s_samplerate != 0){
|
||||
btstack_assert(btstack_audio_esp32_i2s_samplerate == btstack_audio_esp32_source_samplerate);
|
||||
}
|
||||
btstack_audio_esp32_i2s_samplerate = btstack_audio_esp32_source_samplerate;
|
||||
}
|
||||
|
||||
i2s_config_t config =
|
||||
@ -227,7 +225,7 @@ static void btstack_audio_esp32_init(void){
|
||||
|
||||
i2s_pin_config_t pins =
|
||||
{
|
||||
.bck_io_num = i2s_bck_io_pin,
|
||||
.bck_io_num = GPIO_NUM_5,
|
||||
.ws_io_num = GPIO_NUM_25,
|
||||
.data_out_num = i2s_data_out_pin,
|
||||
.data_in_num = i2s_data_in_pin
|
||||
@ -323,15 +321,15 @@ static void btstack_audio_esp32_sink_start_stream(void){
|
||||
// validate samplerate
|
||||
btstack_assert(btstack_audio_esp32_sink_samplerate == btstack_audio_esp32_i2s_samplerate);
|
||||
|
||||
// state
|
||||
btstack_audio_esp32_sink_state = BTSTACK_AUDIO_ESP32_STREAMING;
|
||||
|
||||
// pre-fill HAL buffers
|
||||
uint16_t i;
|
||||
for (i=0;i<DMA_BUFFER_COUNT;i++){
|
||||
btstack_audio_esp32_sink_fill_buffer();
|
||||
}
|
||||
|
||||
// state
|
||||
btstack_audio_esp32_sink_state = BTSTACK_AUDIO_ESP32_STREAMING;
|
||||
|
||||
btstack_audio_esp32_stream_start();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user