From 8eff0efac23fc2ab20eabb5663f5f73796ae897f Mon Sep 17 00:00:00 2001 From: Peter Harper Date: Thu, 15 Feb 2024 14:04:11 +0000 Subject: [PATCH] Fix BT audio examples When audio is initialised twice we get a error and make it more obvious how to change the pins for audio hat hardware --- pico_w/bt/btstack_audio_pico.c | 5 +++-- pico_w/bt/hfp_hf_demo/CMakeLists.txt | 7 ++++++- pico_w/bt/mod_player/CMakeLists.txt | 7 ++++++- pico_w/bt/sine_player/CMakeLists.txt | 7 ++++++- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pico_w/bt/btstack_audio_pico.c b/pico_w/bt/btstack_audio_pico.c index f98fc1e11..1f40fccf0 100644 --- a/pico_w/bt/btstack_audio_pico.c +++ b/pico_w/bt/btstack_audio_pico.c @@ -153,8 +153,9 @@ static int btstack_audio_pico_sink_init( playback_callback = playback; - btstack_audio_pico_audio_buffer_pool = init_audio(samplerate, channels); - + if (!btstack_audio_pico_audio_buffer_pool) { + btstack_audio_pico_audio_buffer_pool = init_audio(samplerate, channels); + } return 0; } diff --git a/pico_w/bt/hfp_hf_demo/CMakeLists.txt b/pico_w/bt/hfp_hf_demo/CMakeLists.txt index cf8d89c17..77e52f0af 100644 --- a/pico_w/bt/hfp_hf_demo/CMakeLists.txt +++ b/pico_w/bt/hfp_hf_demo/CMakeLists.txt @@ -1 +1,6 @@ -picow_bt_example(hfp_hf_demo pico_btstack_sco_demo_util pico_btstack_sbc_encoder) +add_library(hfp_hf_demo_pins INTERFACE) +target_compile_definitions(hfp_hf_demo_pins INTERFACE + PICO_AUDIO_I2S_DATA_PIN=9 + PICO_AUDIO_I2S_CLOCK_PIN_BASE=10 + ) +picow_bt_example(hfp_hf_demo pico_btstack_sco_demo_util pico_btstack_sbc_encoder hfp_hf_demo_pins) diff --git a/pico_w/bt/mod_player/CMakeLists.txt b/pico_w/bt/mod_player/CMakeLists.txt index 106901590..b27b23bd4 100644 --- a/pico_w/bt/mod_player/CMakeLists.txt +++ b/pico_w/bt/mod_player/CMakeLists.txt @@ -1 +1,6 @@ -picow_bt_example(mod_player pico_btstack_hxcmod_player) +add_library(mod_player_pins INTERFACE) +target_compile_definitions(mod_player_pins INTERFACE + PICO_AUDIO_I2S_DATA_PIN=9 + PICO_AUDIO_I2S_CLOCK_PIN_BASE=10 + ) +picow_bt_example(mod_player pico_btstack_hxcmod_player mod_player_pins) diff --git a/pico_w/bt/sine_player/CMakeLists.txt b/pico_w/bt/sine_player/CMakeLists.txt index 97edf797a..0ccbddef8 100644 --- a/pico_w/bt/sine_player/CMakeLists.txt +++ b/pico_w/bt/sine_player/CMakeLists.txt @@ -1 +1,6 @@ -picow_bt_example(sine_player) +add_library(sine_player_pins INTERFACE) +target_compile_definitions(sine_player_pins INTERFACE + PICO_AUDIO_I2S_DATA_PIN=9 + PICO_AUDIO_I2S_CLOCK_PIN_BASE=10 + ) +picow_bt_example(sine_player sine_player_pins)