2021-08-05 10:30:10 -04:00
|
|
|
/*
|
2022-01-12 02:03:50 -05:00
|
|
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
2021-08-05 10:30:10 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-05-09 23:34:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef __ESP_SPIRAM_H
|
|
|
|
#define __ESP_SPIRAM_H
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
2019-06-05 22:57:29 -04:00
|
|
|
#include <stdbool.h>
|
2019-05-09 23:34:06 -04:00
|
|
|
#include "esp_err.h"
|
|
|
|
|
2020-01-26 22:43:08 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2019-05-09 23:34:06 -04:00
|
|
|
/**
|
|
|
|
* @brief Initialize spiram interface/hardware. Normally called from cpu_start.c.
|
|
|
|
*
|
|
|
|
* @return ESP_OK on success
|
|
|
|
*/
|
2019-08-11 22:06:07 -04:00
|
|
|
esp_err_t esp_spiram_init(void);
|
2019-05-09 23:34:06 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Add the initialized SPI RAM to the heap allocator.
|
|
|
|
*/
|
2019-08-11 22:06:07 -04:00
|
|
|
esp_err_t esp_spiram_add_to_heapalloc(void);
|
2019-05-09 23:34:06 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Force a writeback of the data in the SPI RAM cache. This is to be called whenever
|
|
|
|
* cache is disabled, because disabling cache on the ESP32 discards the data in the SPI
|
|
|
|
* RAM cache.
|
|
|
|
*
|
|
|
|
* This is meant for use from within the SPI flash code.
|
|
|
|
*/
|
2019-08-11 22:06:07 -04:00
|
|
|
void esp_spiram_writeback_cache(void);
|
2019-05-09 23:34:06 -04:00
|
|
|
|
2021-07-02 09:46:49 -04:00
|
|
|
/**
|
|
|
|
* @brief get psram CS IO
|
|
|
|
*
|
|
|
|
* This interface should be called after PSRAM is enabled, otherwise it will
|
|
|
|
* return an invalid value -1/0xff.
|
|
|
|
*
|
|
|
|
* @return psram CS IO or -1/0xff if psram not enabled
|
|
|
|
*/
|
|
|
|
uint8_t esp_spiram_get_cs_io(void);
|
2019-05-09 23:34:06 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Reserve a pool of internal memory for specific DMA/internal allocations
|
|
|
|
*
|
|
|
|
* @param size Size of reserved pool in bytes
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* - ESP_OK on success
|
|
|
|
* - ESP_ERR_NO_MEM when no memory available for pool
|
|
|
|
*/
|
|
|
|
esp_err_t esp_spiram_reserve_dma_pool(size_t size);
|
|
|
|
|
2021-07-29 00:45:29 -04:00
|
|
|
/**
|
|
|
|
* @brief If SPI RAM(PSRAM) has been initialized
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* - true SPI RAM has been initialized successfully
|
|
|
|
* - false SPI RAM hasn't been initialized or initialized failed
|
|
|
|
*/
|
|
|
|
bool esp_spiram_is_initialized(void);
|
|
|
|
|
2020-01-26 22:43:08 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2019-05-09 23:34:06 -04:00
|
|
|
|
|
|
|
#endif
|