From 47486db37b21c1088a9fa0d51bea77e8e077778c Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Wed, 16 Nov 2016 22:00:18 +0800 Subject: [PATCH] component/bt: implement UIPC API functions according to esp_audio component --- .../bt/bluedroid/stack/include/bt_types.h | 2 +- components/spi_flash/flash_ops.c | 2 +- .../bluedroid_demos/udrv/ulinux/uipc.c | 21 ++++++++++++++++++- examples/09_a2dp/main/demo_main.c | 16 ++++++-------- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/components/bt/bluedroid/stack/include/bt_types.h b/components/bt/bluedroid/stack/include/bt_types.h index b01e29db3c..78c144d2a0 100755 --- a/components/bt/bluedroid/stack/include/bt_types.h +++ b/components/bt/bluedroid/stack/include/bt_types.h @@ -41,7 +41,7 @@ typedef int32_t INT32; typedef bool BOOLEAN; #define PACKED __packed -#define INLINE __inline +// #define INLINE __inline #define BCM_STRCPY_S(x1,x2,x3) strcpy((x1),(x3)) #define BCM_STRNCPY_S(x1,x2,x3,x4) strncpy((x1),(x3),(x4)) diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index ae72568aa5..8bf60843a7 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -39,7 +39,7 @@ static spi_flash_counters_t s_flash_stats; #define COUNTER_STOP(counter) \ do{ \ s_flash_stats.counter.count++; \ - s_flash_stats.counter.time += (xthal_get_ccount() - ts_begin) / (XT_CLOCK_FREQ / 1000000); \\ + s_flash_stats.counter.time += (xthal_get_ccount() - ts_begin) / (XT_CLOCK_FREQ / 1000000); \ } while(0) #define COUNTER_ADD_BYTES(counter, size) \ diff --git a/examples/09_a2dp/components/bluedroid_demos/udrv/ulinux/uipc.c b/examples/09_a2dp/components/bluedroid_demos/udrv/ulinux/uipc.c index cb0c14c45d..710975ffe6 100755 --- a/examples/09_a2dp/components/bluedroid_demos/udrv/ulinux/uipc.c +++ b/examples/09_a2dp/components/bluedroid_demos/udrv/ulinux/uipc.c @@ -25,7 +25,10 @@ *****************************************************************************/ #include #include "uipc.h" - +#include "esp_system.h" +#include "EspAudio.h" +#include "EspAudioCom.h" +#include "bt_trace.h" /***************************************************************************** ** Constants & Macros ******************************************************************************/ @@ -48,6 +51,8 @@ const char* dump_uipc_event(tUIPC_EVENT event) *******************************************************************************/ void UIPC_Init(void *dummy) { + LOG_ERROR("Free memory: %d bytes\n", system_get_free_heap_size()); + EspAudio_Init(); return; } @@ -62,6 +67,17 @@ void UIPC_Init(void *dummy) *******************************************************************************/ BOOLEAN UIPC_Open(tUIPC_CH_ID ch_id, tUIPC_RCV_CBACK *p_cback) { + if (ch_id == UIPC_CH_ID_AV_AUDIO) { + // TODO: review the stream param config parameter here + EspAudioPlayerStreamCfg(StreamSampleRate_44k, StreamChannel_Two, StreamBitLen_16BIT); + EspAudio_SetupStream("stream.pcm", InputSrcType_Stream); + } + + /* + if (p_cback) { + p_cback(ch_id, UIPC_OPEN_EVT); + } + */ return TRUE; } @@ -105,6 +121,9 @@ BOOLEAN UIPC_SendBuf(tUIPC_CH_ID ch_id, BT_HDR *p_msg) *******************************************************************************/ BOOLEAN UIPC_Send(tUIPC_CH_ID ch_id, UINT16 msg_evt, UINT8 *p_buf, UINT16 msglen) { + if (ch_id == UIPC_CH_ID_AV_AUDIO) { + EspAudioPlayerStreamWrite(p_buf, msglen); + } return TRUE; } diff --git a/examples/09_a2dp/main/demo_main.c b/examples/09_a2dp/main/demo_main.c index ad8243a1fc..a1135b4b99 100755 --- a/examples/09_a2dp/main/demo_main.c +++ b/examples/09_a2dp/main/demo_main.c @@ -1,28 +1,24 @@ #include #include #include +#include #include "bt.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "string.h" +#include "nvs_flash.h" +#include "esp_system.h" extern void bte_main_boot_entry(void *); extern void bt_app_task_start_up(void); extern void bt_app_core_start(void); -void pingTask(void *pvParameters) -{ - while (1) { - vTaskDelay(1000 / portTICK_PERIOD_MS); - printf("ping\n"); - } -} - void app_main() { + nvs_flash_init(); + system_init(); + printf("Free memory: %d bytes\n", system_get_free_heap_size()); bt_controller_init(); - xTaskCreatePinnedToCore(&pingTask, "pingTask", 2048, NULL, 5, NULL, 0); bt_app_task_start_up(); // bte_main_boot_entry(bt_app_core_start); }