]> granicus.if.org Git - esp-idf/commitdiff
component/bt : support UART HCI and fix some bugs
authorTian Hao <tianhao@espressif.com>
Fri, 24 Mar 2017 06:57:07 +0000 (14:57 +0800)
committerTian Hao <tianhao@espressif.com>
Wed, 5 Apr 2017 13:23:43 +0000 (21:23 +0800)
1. support UART HCI, devolper need not to make a bridge between VHCI and UART.
2. fix bug of rand/srand called in ISR.
3. fix bug of BLE rx packets may cause assert.

components/bt/Kconfig
components/bt/bt.c
components/bt/lib

index 92d060999c5c1bfe5fae5a302d271c8c34911467..5490ba99b3191b5bffcacaf7c022dabdb511dfe2 100644 (file)
@@ -33,12 +33,12 @@ config BT_DRAM_RELEASE
        Open this option will release about 30K DRAM from Classic BT.
        The released DRAM will be used as system heap memory.
 
-#config BTDM_CONTROLLER_RUN_APP_CPU
-#    bool "Run controller on APP CPU"
-#    depends on BT_ENABLED
-#    default n
-#    help
-#        Run controller on APP CPU.
+config BTDM_CONTROLLER_RUN_APP_CPU
+    bool "Run controller on APP CPU"
+    depends on BT_ENABLED && !FREERTOS_UNICORE && 0
+    default n
+    help
+        Run controller on APP CPU.
 
 menuconfig HCI_UART
     bool "HCI use UART as IO"
index 6182c5eb5f4c0c8a5887e56aad10a07d2b41b1b5..f1676107c5ea84985172a2b3bf7bdbc419f2766f 100644 (file)
@@ -87,6 +87,8 @@ struct osi_funcs_t {
     int32_t (*_mutex_lock)(void *mutex);
     int32_t (*_mutex_unlock)(void *mutex);
     int32_t (* _read_efuse_mac)(uint8_t mac[6]);
+    void (* _srand)(unsigned int seed);
+    int (* _rand)(void);
 };
 
 /* Static variable declare */
@@ -142,6 +144,16 @@ static int32_t IRAM_ATTR read_mac_wrapper(uint8_t mac[6])
     return esp_read_mac(mac, ESP_MAC_BT);
 }
 
+static void IRAM_ATTR srand_wrapper(unsigned int seed)
+{
+    /* empty function */
+}
+
+static int IRAM_ATTR rand_wrapper(void)
+{
+    return (int)esp_random();
+}
+
 static struct osi_funcs_t osi_funcs = {
     ._set_isr = xt_set_interrupt_handler,
     ._ints_on = xt_ints_on,
@@ -154,7 +166,9 @@ static struct osi_funcs_t osi_funcs = {
     ._mutex_create = mutex_create_wrapper,
     ._mutex_lock = mutex_lock_wrapper,
     ._mutex_unlock = mutex_unlock_wrapper,
-    ._read_efuse_mac = read_mac_wrapper
+    ._read_efuse_mac = read_mac_wrapper,
+    ._srand = srand_wrapper,
+    ._rand = rand_wrapper,
 };
 
 bool esp_vhci_host_check_send_available(void)
@@ -223,9 +237,15 @@ void esp_bt_controller_init()
         return;
     }
 
+#ifdef CONFIG_BTDM_CONTROLLER_RUN_APP_CPU
+    xTaskCreatePinnedToCore(bt_controller_task, "btController",
+                            ESP_TASK_BT_CONTROLLER_STACK, NULL,
+                            ESP_TASK_BT_CONTROLLER_PRIO, &btControllerTaskHandle, 1);
+#else
     xTaskCreatePinnedToCore(bt_controller_task, "btController",
                             ESP_TASK_BT_CONTROLLER_STACK, NULL,
                             ESP_TASK_BT_CONTROLLER_PRIO, &btControllerTaskHandle, 0);
+#endif
 }
 
 void esp_bt_controller_deinit(void)
index f1c0c65171e5bd02e1d63137b3582af3bcbb85a4..0986936c6d21a009d7d4249cbae8a23b0f3bd20b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f1c0c65171e5bd02e1d63137b3582af3bcbb85a4
+Subproject commit 0986936c6d21a009d7d4249cbae8a23b0f3bd20b