From 7c74ed86384df2482021525a60feb9fe1302d0fd Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Fri, 17 Nov 2017 15:00:51 +1100 Subject: [PATCH] spi_flash: Expose an accessor the current SPI flash guard functions Change places which uses g_flash_guard_default_ops to use this. Probably exact same data, but a bit cleaner. --- components/spi_flash/flash_ops.c | 5 +++++ components/spi_flash/include/esp_spi_flash.h | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/components/spi_flash/flash_ops.c b/components/spi_flash/flash_ops.c index afb8f407be..da097a9d91 100644 --- a/components/spi_flash/flash_ops.c +++ b/components/spi_flash/flash_ops.c @@ -95,6 +95,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; diff --git a/components/spi_flash/include/esp_spi_flash.h b/components/spi_flash/include/esp_spi_flash.h index 00797b8df2..9ea4588818 100644 --- a/components/spi_flash/include/esp_spi_flash.h +++ b/components/spi_flash/include/esp_spi_flash.h @@ -297,6 +297,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 */