]> granicus.if.org Git - esp-idf/commitdiff
component/bt: implement UIPC API functions according to esp_audio component
authorwangmengyang <wangmengyang@espressif.com>
Wed, 16 Nov 2016 14:00:18 +0000 (22:00 +0800)
committerwangmengyang <wangmengyang@espressif.com>
Wed, 16 Nov 2016 14:00:18 +0000 (22:00 +0800)
components/bt/bluedroid/stack/include/bt_types.h
components/spi_flash/flash_ops.c
examples/09_a2dp/components/bluedroid_demos/udrv/ulinux/uipc.c
examples/09_a2dp/main/demo_main.c

index b01e29db3c58151a9b1626ef35e2b5c0ff32a7c0..78c144d2a05187f516f9b1c7bdbc253927e445f7 100755 (executable)
@@ -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))
index ae72568aa5509616ac1c488ac073b4ffd38b47b6..8bf60843a727d8f686f13b7f32584701d7093be7 100644 (file)
@@ -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) \
index cb0c14c45d422b4981b6897198a548b7816ff508..710975ffe61ad14c6ee0ed34d1f902e65a8ad8b3 100755 (executable)
  *****************************************************************************/
 #include <stddef.h>
 #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;
 }
 
index ad8243a1fc02a0759e4e95e1c2e3ecfd296260eb..a1135b4b993aac62fbe0602fffc4de4303f29008 100755 (executable)
@@ -1,28 +1,24 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <string.h>
 #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);
 }