Skip to content

Commit

Permalink
esp32: psram_set_cs_timing: sync with esp-idf
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Aug 30, 2024
1 parent 1086a05 commit f90aadf
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions arch/xtensa/src/esp32/esp32_psram.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,16 @@
# define PSRAM_SPICLKEN DPORT_SPI01_CLK_EN
#endif

/* Let's to assume SPIFLASH SPEED == SPIRAM SPEED for now */

#if defined(CONFIG_ESP32_SPIRAM_SPEED_40M)
# define PSRAM_CS_HOLD_TIME 0
#elif defined(CONFIG_ESP32_SPIRAM_SPEED_80M)
# define PSRAM_CS_HOLD_TIME 1
#else
# error "FLASH speed can only be equal to or higher than SRAM speed while SRAM is enabled!"
#endif

/****************************************************************************
* Private Types
****************************************************************************/
Expand Down Expand Up @@ -1260,8 +1270,8 @@ void psram_set_cs_timing(psram_spi_num_t spi_num, psram_clk_mode_t clk_mode)

/* Set cs time. */

SET_PERI_REG_BITS(SPI_CTRL2_REG(spi_num), SPI_HOLD_TIME_V, 1,
SPI_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_CTRL2_REG(spi_num), SPI_HOLD_TIME_V,
PSRAM_CS_HOLD_TIME, SPI_HOLD_TIME_S);
SET_PERI_REG_BITS(SPI_CTRL2_REG(spi_num), SPI_SETUP_TIME_V, 0,
SPI_SETUP_TIME_S);
}
Expand Down

0 comments on commit f90aadf

Please sign in to comment.