spiram: expose function to initialize SPI RAM cache

Some frameworks based on ESP-IDF need to be able to decide whether to
initialize SPI RAM after the application has started. This change splits
out part of esp_spiram_init which manipulate cache MMU into a separate
function. Applications can disable cache, call esp_spiram_init_cache,
re-enable cache, and then call esp_spiram_init.
Disabling and re-enabling the cache can be achieved using functions
provided in esp_spi_flash.h.
This commit is contained in:
Ivan Grokhotkov
2017-09-18 23:02:33 +08:00
parent 3a271a4ae7
commit 1da3204a7c
3 changed files with 19 additions and 5 deletions

View File

@@ -91,9 +91,7 @@ bool esp_spiram_test()
}
}
esp_err_t esp_spiram_init()
void IRAM_ATTR esp_spiram_init_cache()
{
//Enable external RAM in MMU
cache_sram_mmu_set( 0, 0, SOC_EXTRAM_DATA_LOW, 0, 32, 128 );
@@ -102,7 +100,11 @@ esp_err_t esp_spiram_init()
DPORT_CLEAR_PERI_REG_MASK(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MASK_DRAM1);
cache_sram_mmu_set( 1, 0, SOC_EXTRAM_DATA_LOW, 0, 32, 128 );
#endif
}
esp_err_t esp_spiram_init()
{
esp_err_t r;
r = psram_enable(PSRAM_SPEED, PSRAM_MODE);
if (r != ESP_OK) {
@@ -202,4 +204,4 @@ void IRAM_ATTR esp_spiram_writeback_cache()
#endif
#endif