Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_psram_eid_v3.0' into 'release/v3.0'
Browse files Browse the repository at this point in the history
psram: fix psram eid (backport v3.0)

See merge request idf/esp-idf!3463
  • Loading branch information
projectgus committed Oct 12, 2018
2 parents 735f02c + 80c013e commit 6313ea0
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 113 deletions.
15 changes: 15 additions & 0 deletions components/esp32/include/esp_spiram.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,23 @@

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include "esp_err.h"

typedef enum {
ESP_SPIRAM_SIZE_32MBITS = 0, /*!< SPI RAM size is 32 MBits */
ESP_SPIRAM_SIZE_64MBITS = 1, /*!< SPI RAM size is 64 MBits */
ESP_SPIRAM_SIZE_INVALID, /*!< SPI RAM size is invalid */
} esp_spiram_size_t;

/**
* @brief get SPI RAM size
* @return
* - ESP_SPIRAM_SIZE_INVALID if SPI RAM not enabled or not valid
* - SPI RAM size
*/
esp_spiram_size_t esp_spiram_get_chip_size();

/**
* @brief Initialize spiram interface/hardware. Normally called from cpu_start.c.
*
Expand Down
2 changes: 2 additions & 0 deletions components/esp32/include/rom/spi_flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ extern "C" {
#define ESP_ROM_SPIFLASH_WR_PROTECT (ESP_ROM_SPIFLASH_BP0|ESP_ROM_SPIFLASH_BP1|ESP_ROM_SPIFLASH_BP2)
#define ESP_ROM_SPIFLASH_QE BIT9

#define FLASH_ID_GD25LQ32C 0xC86016

typedef enum {
ESP_ROM_SPIFLASH_QIO_MODE = 0,
ESP_ROM_SPIFLASH_QOUT_MODE,
Expand Down
17 changes: 17 additions & 0 deletions components/esp32/spiram.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ we add more types of external RAM memory, this can be made into a more intellige
#include "sdkconfig.h"
#include "esp_attr.h"
#include "esp_err.h"
#include "esp_spiram.h"
#include "spiram_psram.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
Expand Down Expand Up @@ -102,6 +103,22 @@ void IRAM_ATTR esp_spiram_init_cache()
#endif
}

esp_spiram_size_t esp_spiram_get_chip_size()
{
if (!spiram_inited) {
ESP_LOGE(TAG, "SPI RAM not initialized");
return ESP_SPIRAM_SIZE_INVALID;
}
psram_size_t psram_size = psram_get_size();
switch (psram_size) {
case PSRAM_SIZE_32MBITS:
return ESP_SPIRAM_SIZE_32MBITS;
case PSRAM_SIZE_64MBITS:
return ESP_SPIRAM_SIZE_64MBITS;
default:
return ESP_SPIRAM_SIZE_INVALID;
}
}

esp_err_t esp_spiram_init()
{
Expand Down
Loading

0 comments on commit 6313ea0

Please sign in to comment.