2021-06-03 07:40:09 -04:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2017-07-20 04:26:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef _PSRAM_H
|
|
|
|
#define _PSRAM_H
|
2019-05-13 06:02:45 -04:00
|
|
|
#include "soc/spi_periph.h"
|
2017-07-20 04:26:35 -04:00
|
|
|
#include "esp_err.h"
|
|
|
|
#include "sdkconfig.h"
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
PSRAM_CACHE_F80M_S40M = 0,
|
|
|
|
PSRAM_CACHE_F40M_S40M,
|
|
|
|
PSRAM_CACHE_F80M_S80M,
|
|
|
|
PSRAM_CACHE_MAX,
|
|
|
|
} psram_cache_mode_t;
|
|
|
|
|
2018-07-03 23:43:30 -04:00
|
|
|
typedef enum {
|
2018-11-20 07:39:47 -05:00
|
|
|
PSRAM_SIZE_16MBITS = 0,
|
|
|
|
PSRAM_SIZE_32MBITS = 1,
|
|
|
|
PSRAM_SIZE_64MBITS = 2,
|
2018-07-03 23:43:30 -04:00
|
|
|
PSRAM_SIZE_MAX,
|
|
|
|
} psram_size_t;
|
2017-07-20 04:26:35 -04:00
|
|
|
|
|
|
|
/*
|
|
|
|
See the TRM, chapter PID/MPU/MMU, header 'External RAM' for the definitions of these modes.
|
|
|
|
|
|
|
|
Important is that NORMAL works with the app CPU cache disabled, but gives huge cache coherency
|
|
|
|
issues when both app and pro CPU are enabled. LOWHIGH and EVENODD do not have these coherency
|
|
|
|
issues but cannot be used when the app CPU cache is disabled.
|
|
|
|
*/
|
2018-07-03 23:43:30 -04:00
|
|
|
|
2017-07-20 04:26:35 -04:00
|
|
|
typedef enum {
|
|
|
|
PSRAM_VADDR_MODE_NORMAL=0, ///< App and pro CPU use their own flash cache for external RAM access
|
|
|
|
PSRAM_VADDR_MODE_LOWHIGH, ///< App and pro CPU share external RAM caches: pro CPU has low 2M, app CPU has high 2M
|
|
|
|
PSRAM_VADDR_MODE_EVENODD, ///< App and pro CPU share external RAM caches: pro CPU does even 32yte ranges, app does odd ones.
|
|
|
|
} psram_vaddr_mode_t;
|
|
|
|
|
2018-07-03 23:43:30 -04:00
|
|
|
/**
|
|
|
|
* @brief get psram size
|
|
|
|
* @return
|
|
|
|
* - PSRAM_SIZE_MAX if psram not enabled or not valid
|
|
|
|
* - PSRAM size
|
|
|
|
*/
|
2019-07-16 05:33:30 -04:00
|
|
|
psram_size_t psram_get_size(void);
|
2018-07-03 23:43:30 -04:00
|
|
|
|
2017-07-20 04:26:35 -04:00
|
|
|
/**
|
|
|
|
* @brief psram cache enable function
|
|
|
|
*
|
|
|
|
* Esp-idf uses this to initialize cache for psram, mapping it into the main memory
|
|
|
|
* address space.
|
|
|
|
*
|
|
|
|
* @param mode SPI mode to access psram in
|
|
|
|
* @param vaddrmode Mode the psram cache works in.
|
|
|
|
* @return ESP_OK on success, ESP_ERR_INVALID_STATE when VSPI peripheral is needed but cannot be claimed.
|
|
|
|
*/
|
|
|
|
esp_err_t psram_enable(psram_cache_mode_t mode, psram_vaddr_mode_t vaddrmode);
|
|
|
|
|
|
|
|
#endif
|