|
|
@@ -7,36 +7,14 @@
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
-#ifdef __cplusplus
|
|
|
-extern "C" {
|
|
|
-#endif
|
|
|
-
|
|
|
#include "sdkconfig.h"
|
|
|
#include <stdint.h>
|
|
|
#include <stdbool.h>
|
|
|
|
|
|
-#if CONFIG_IDF_TARGET_ESP32
|
|
|
-#include "esp32/rom/spi_flash.h"
|
|
|
-#elif CONFIG_IDF_TARGET_ESP32S2
|
|
|
-#include "esp32s2/rom/spi_flash.h"
|
|
|
-#elif CONFIG_IDF_TARGET_ESP32C3
|
|
|
-#include "esp32c3/rom/spi_flash.h"
|
|
|
-#elif CONFIG_IDF_TARGET_ESP32S3
|
|
|
-#include "esp32s3/rom/spi_flash.h"
|
|
|
-#elif CONFIG_IDF_TARGET_ESP32H2
|
|
|
-#include "esp32h2/rom/spi_flash.h"
|
|
|
-#elif CONFIG_IDF_TARGET_ESP8684
|
|
|
-#include "esp32h2/rom/spi_flash.h"
|
|
|
+#ifdef __cplusplus
|
|
|
+extern "C" {
|
|
|
#endif
|
|
|
|
|
|
-/** \defgroup spi_flash_apis, spi flash operation related apis
|
|
|
- * @brief spi_flash apis
|
|
|
- */
|
|
|
-
|
|
|
-/** @addtogroup spi_flash_apis
|
|
|
- * @{
|
|
|
- */
|
|
|
-
|
|
|
typedef enum {
|
|
|
ESP_ROM_SPIFLASH_QIO_MODE = 0,
|
|
|
ESP_ROM_SPIFLASH_QOUT_MODE,
|
|
|
@@ -69,59 +47,11 @@ typedef struct {
|
|
|
uint16_t data;
|
|
|
} esp_rom_spiflash_common_cmd_t;
|
|
|
|
|
|
-/**
|
|
|
- * @brief Fix the bug in SPI hardware communication with Flash/Ext-SRAM in High Speed.
|
|
|
- * Please do not call this function in SDK.
|
|
|
- *
|
|
|
- * @param uint8_t spi: 0 for SPI0(Cache Access), 1 for SPI1(Flash read/write).
|
|
|
- *
|
|
|
- * @param uint8_t freqdiv: Pll is 80M, 4 for 20M, 3 for 26.7M, 2 for 40M, 1 for 80M.
|
|
|
- *
|
|
|
- * @return None
|
|
|
- */
|
|
|
-void esp_rom_spiflash_fix_dummylen(uint8_t spi, uint8_t freqdiv);
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief Select SPI Flash to QIO mode when WP pad is read from Flash.
|
|
|
- * Please do not call this function in SDK.
|
|
|
- *
|
|
|
- * @param uint8_t wp_gpio_num: WP gpio number.
|
|
|
- *
|
|
|
- * @param uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping
|
|
|
- * else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, bit[23:18] spics0, bit[29:24] spihd
|
|
|
- *
|
|
|
- * @return None
|
|
|
- */
|
|
|
-void esp_rom_spiflash_select_qiomode(uint8_t wp_gpio_num, uint32_t ishspi);
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief Set SPI Flash pad drivers.
|
|
|
- * Please do not call this function in SDK.
|
|
|
- *
|
|
|
- * @param uint8_t wp_gpio_num: WP gpio number.
|
|
|
- *
|
|
|
- * @param uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping
|
|
|
- * else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, bit[23:18] spics0, bit[29:24] spihd
|
|
|
- *
|
|
|
- * @param uint8_t *drvs: drvs[0]-bit[3:0] for cpiclk, bit[7:4] for spiq, drvs[1]-bit[3:0] for spid, drvs[1]-bit[7:4] for spid
|
|
|
- * drvs[2]-bit[3:0] for spihd, drvs[2]-bit[7:4] for spiwp.
|
|
|
- * Values usually read from falsh by rom code, function usually callde by rom code.
|
|
|
- * if value with bit(3) set, the value is valid, bit[2:0] is the real value.
|
|
|
- *
|
|
|
- * @return None
|
|
|
- */
|
|
|
-void esp_rom_spiflash_set_drvs(uint8_t wp_gpio_num, uint32_t ishspi, uint8_t *drvs);
|
|
|
-
|
|
|
-/**
|
|
|
- * @brief Select SPI Flash function for pads.
|
|
|
- * Please do not call this function in SDK.
|
|
|
- *
|
|
|
- * @param uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping
|
|
|
- * else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, bit[23:18] spics0, bit[29:24] spihd
|
|
|
- *
|
|
|
- * @return None
|
|
|
- */
|
|
|
-void esp_rom_spiflash_select_padsfunc(uint32_t ishspi);
|
|
|
+typedef enum {
|
|
|
+ ESP_ROM_SPIFLASH_RESULT_OK,
|
|
|
+ ESP_ROM_SPIFLASH_RESULT_ERR,
|
|
|
+ ESP_ROM_SPIFLASH_RESULT_TIMEOUT
|
|
|
+} esp_rom_spiflash_result_t;
|
|
|
|
|
|
/**
|
|
|
* @brief SPI Flash init, clock divisor is 4, use 1 line Slow read mode.
|
|
|
@@ -130,7 +60,7 @@ void esp_rom_spiflash_select_padsfunc(uint32_t ishspi);
|
|
|
* @param uint32_t ishspi: 0 for spi, 1 for hspi, flash pad decided by strapping
|
|
|
* else, bit[5:0] spiclk, bit[11:6] spiq, bit[17:12] spid, bit[23:18] spics0, bit[29:24] spihd
|
|
|
*
|
|
|
- * @param uint8_t legacy: In legacy mode, more SPI command is used in line.
|
|
|
+ * @param uint8_t legacy: always keeping false.
|
|
|
*
|
|
|
* @return None
|
|
|
*/
|
|
|
@@ -220,18 +150,6 @@ esp_rom_spiflash_result_t esp_rom_spiflash_config_readmode(esp_rom_spiflash_read
|
|
|
*/
|
|
|
esp_rom_spiflash_result_t esp_rom_spiflash_config_clk(uint8_t freqdiv, uint8_t spi);
|
|
|
|
|
|
-/**
|
|
|
- * @brief Send CommonCmd to Flash so that is can go into QIO mode, some Flash use different CMD.
|
|
|
- * Please do not call this function in SDK.
|
|
|
- *
|
|
|
- * @param esp_rom_spiflash_common_cmd_t *cmd : A struct to show the action of a command.
|
|
|
- *
|
|
|
- * @return uint16_t 0 : do not send command any more.
|
|
|
- * 1 : go to the next command.
|
|
|
- * n > 1 : skip (n - 1) commands.
|
|
|
- */
|
|
|
-uint16_t esp_rom_spiflash_common_cmd(esp_rom_spiflash_common_cmd_t *cmd);
|
|
|
-
|
|
|
/**
|
|
|
* @brief Unlock SPI write protect.
|
|
|
* Please do not call this function in SDK.
|
|
|
@@ -460,14 +378,15 @@ typedef struct {
|
|
|
esp_rom_spiflash_chip_t chip;
|
|
|
uint8_t dummy_len_plus[3];
|
|
|
uint8_t sig_matrix;
|
|
|
-} spiflash_legacy_data_t;
|
|
|
+} esp_rom_spiflash_legacy_data_t;
|
|
|
|
|
|
|
|
|
/* Flash data defined in ROM*/
|
|
|
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
|
|
|
extern esp_rom_spiflash_chip_t g_rom_flashchip;
|
|
|
+extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
|
|
#else
|
|
|
-extern spiflash_legacy_data_t *rom_spiflash_legacy_data;
|
|
|
+extern esp_rom_spiflash_legacy_data_t *rom_spiflash_legacy_data;
|
|
|
#define g_rom_flashchip (rom_spiflash_legacy_data->chip)
|
|
|
#define g_rom_spiflash_dummy_len_plus (rom_spiflash_legacy_data->dummy_len_plus)
|
|
|
#endif
|