]> granicus.if.org Git - esp-idf/commitdiff
spi_flash: Expose an accessor the current SPI flash guard functions
authorAngus Gratton <angus@espressif.com>
Fri, 17 Nov 2017 04:00:51 +0000 (15:00 +1100)
committerAngus Gratton <gus@projectgus.com>
Mon, 20 Nov 2017 04:54:31 +0000 (15:54 +1100)
Change places which uses g_flash_guard_default_ops to use this. Probably exact same data, but a bit
cleaner.

components/esp32/test/test_ets_timer.c
components/heap/test/test_malloc_caps.c
components/spi_flash/cache_utils.c
components/spi_flash/flash_ops.c
components/spi_flash/include/esp_spi_flash.h

index fa79bea8cbf04aa340d38b5d7a40c7f85e924440..33f633ff69ba7344b7c4996b37ab155e2217d904 100644 (file)
@@ -212,27 +212,27 @@ IRAM_ATTR TEST_CASE("ETSTimers arm & disarm run from IRAM", "[ets_timer]")
 
     /* arm a disabled timer, then disarm a live timer */
 
-    g_flash_guard_default_ops.start(); // Disables flash cache
+    spi_flash_guard_get()->start(); // Disables flash cache
 
     ets_timer_arm(&timer1, INTERVAL, false);
     // redundant call is deliberate (test code path if already armed)
     ets_timer_arm(&timer1, INTERVAL, false);
     ets_timer_disarm(&timer1);
 
-    g_flash_guard_default_ops.end(); // Re-enables flash cache
+    spi_flash_guard_get()->end(); // Re-enables flash cache
 
     TEST_ASSERT_FALSE(flag); // didn't expire yet
 
     /* do the same thing but wait for the timer to expire */
 
-    g_flash_guard_default_ops.start();
+    spi_flash_guard_get()->start();
     ets_timer_arm(&timer1, INTERVAL, false);
-    g_flash_guard_default_ops.end();
+    spi_flash_guard_get()->end();
 
     vTaskDelay(2 * INTERVAL / portTICK_PERIOD_MS);
     TEST_ASSERT_TRUE(flag);
 
-    g_flash_guard_default_ops.start();
+    spi_flash_guard_get()->start();
     ets_timer_disarm(&timer1);
-    g_flash_guard_default_ops.end();
+    spi_flash_guard_get()->end();
 }
index a41bf5958336dbe3f93f33febf3ac1ad3515dd66..0be5f6a6cac903f9be3a8304952360c408f2f0b4 100644 (file)
@@ -105,7 +105,7 @@ TEST_CASE("heap_caps metadata test", "[heap]")
 */
 static IRAM_ATTR __attribute__((noinline)) bool iram_malloc_test()
 {
-    g_flash_guard_default_ops.start(); // Disables flash cache
+    spi_flash_guard_get()->start(); // Disables flash cache
 
     bool result = true;
     void *x = heap_caps_malloc(64, MALLOC_CAP_32BIT);
@@ -114,7 +114,7 @@ static IRAM_ATTR __attribute__((noinline)) bool iram_malloc_test()
     result = result && (y != NULL);
     heap_caps_free(y);
 
-    g_flash_guard_default_ops.end(); // Re-enables flash cache
+    spi_flash_guard_get()->end(); // Re-enables flash cache
 
     return result;
 }
index 63c6692cee53f2dbde20b92024ccb7ed284b7dee..bc4e8885ebade89ad67d2ca2566a6036d5677ae2 100644 (file)
@@ -214,7 +214,7 @@ void spi_flash_op_unlock()
 
 void IRAM_ATTR spi_flash_disable_interrupts_caches_and_other_cpu()
 {
-    spi_flash_op_lockspi_flash_op_lock();
+    spi_flash_op_lock();
     esp_intr_noniram_disable();
     spi_flash_disable_cache(0, &s_flash_op_cache_state[0]);
 }
index 4b811d1151e3a7a1dbad7b2ecdffd686a2b3ffa0..7fd47dcca41392c10b447553221f4725472d0d29 100644 (file)
@@ -137,6 +137,11 @@ void IRAM_ATTR spi_flash_guard_set(const spi_flash_guard_funcs_t *funcs)
     s_flash_guard_ops = funcs;
 }
 
+const spi_flash_guard_funcs_t *IRAM_ATTR spi_flash_guard_get()
+{
+    return s_flash_guard_ops;
+}
+
 size_t IRAM_ATTR spi_flash_get_chip_size()
 {
     return g_rom_flashchip.chip_size;
index 7d6a03612b3457f52669e89b99367614f38ca9b9..8dee9d341ea7591feae98aa756b7175ad0a49ffa 100644 (file)
@@ -324,6 +324,15 @@ typedef struct {
  */
 void spi_flash_guard_set(const spi_flash_guard_funcs_t* funcs);
 
+
+/**
+ * @brief Get the guard functions used for flash access
+ *
+ * @return The guard functions that were set via spi_flash_guard_set(). These functions
+ * can be called if implementing custom low-level SPI flash operations.
+ */
+const spi_flash_guard_funcs_t *spi_flash_guard_get();
+
 /**
  * @brief Default OS-aware flash access guard functions
  */