]> granicus.if.org Git - esp-idf/commitdiff
dport_access: Fix spurious warning in unicore mode, refactor
authorAngus Gratton <angus@espressif.com>
Wed, 28 Jun 2017 23:55:47 +0000 (09:55 +1000)
committerIvan Grokhotkov <ivan@espressif.com>
Tue, 4 Jul 2017 07:27:31 +0000 (15:27 +0800)
components/esp32/dport_access.c

index dbb956e8209732aa6c0b9842a1dced71edc05005..f80de4012695804613e64c1781175d8ec9b38bb6 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdint.h>
 #include <string.h>
 
+#include <sdkconfig.h>
 #include "esp_attr.h"
 #include "esp_err.h"
 #include "esp_intr.h"
@@ -145,34 +146,20 @@ void IRAM_ATTR esp_dport_access_stall_other_cpu_end_wrap(void)
     DPORT_STALL_OTHER_CPU_END();
 }
 
-static void dport_access_init_core0(void *arg)
+static void dport_access_init_core(void *arg)
 {
-    int core_id = xPortGetCoreID();
+    int core_id = 0;
+    uint32_t intr_source = ETS_FROM_CPU_INTR2_SOURCE;
 
-    assert(core_id == 0);
-
-    vPortCPUInitializeMutex(&g_dport_mux);
-
-    ESP_INTR_DISABLE(ETS_DPORT_INUM);
-    intr_matrix_set(core_id, ETS_FROM_CPU_INTR2_SOURCE, ETS_DPORT_INUM);
-    ESP_INTR_ENABLE(ETS_DPORT_INUM);
-
-    dport_access_ref[core_id] = 0;
-    dport_access_start[core_id] = 0;
-    dport_access_end[core_id] = 0;
-    dport_core_state[core_id] = DPORT_CORE_STATE_RUNNING;
-
-    vTaskDelete(NULL);
-}
-
-static void dport_access_init_core1(void *arg)
-{
-    int core_id = xPortGetCoreID();
-
-    assert(core_id == 1);
+#ifndef CONFIG_FREERTOS_UNICORE
+    core_id = xPortGetCoreID();
+    if (core_id == 1) {
+        intr_source = ETS_FROM_CPU_INTR3_SOURCE;
+    }
+#endif
 
     ESP_INTR_DISABLE(ETS_DPORT_INUM);
-    intr_matrix_set(core_id, ETS_FROM_CPU_INTR3_SOURCE, ETS_DPORT_INUM);
+    intr_matrix_set(core_id, intr_source, ETS_DPORT_INUM);
     ESP_INTR_ENABLE(ETS_DPORT_INUM);
 
     dport_access_ref[core_id] = 0;
@@ -183,15 +170,10 @@ static void dport_access_init_core1(void *arg)
     vTaskDelete(NULL);
 }
 
-
-/*  This initialise should be really effective after vTaskStartScheduler */
+/*  Defer initialisation until after scheduler is running */
 void esp_dport_access_int_init(void)
 {
-    if (xPortGetCoreID() == 0) {
-        xTaskCreatePinnedToCore(&dport_access_init_core0, "dport0", 512, NULL, 5, NULL, 0);
-    } else {
-        xTaskCreatePinnedToCore(&dport_access_init_core1, "dport1", 512, NULL, 5, NULL, 1);
-    }
+    xTaskCreatePinnedToCore(&dport_access_init_core, "dport", 512, NULL, 5, NULL, xPortGetCoreID());
 }
 
 void esp_dport_access_int_deinit(void)