esp-idf/components/esp_hw_support/include/soc/esp32s2/spiram.h

76 lines
1.7 KiB
C
Raw Normal View History

/*
2022-01-12 02:03:50 -05:00
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* 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>
#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
/**
* @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);
/**
* @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