2022-04-13 05:23:57 -04:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-09-10 02:34:06 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "esp_err.h"
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2023-11-13 22:14:34 -05:00
|
|
|
#include "esp_private/spi_share_hw_ctrl.h"
|
2019-09-10 02:34:06 -04:00
|
|
|
#include "sdkconfig.h"
|
|
|
|
|
|
|
|
#include "esp_flash.h"
|
|
|
|
|
|
|
|
/** Internal API, don't use in the applications */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/** @brief Initialise the default SPI flash chip
|
|
|
|
*
|
|
|
|
* Called by OS startup code. You do not need to call this in your own applications.
|
|
|
|
*/
|
|
|
|
esp_err_t esp_flash_init_default_chip(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable OS-level SPI flash protections in IDF
|
|
|
|
*
|
|
|
|
* Called by OS startup code. You do not need to call this in your own applications.
|
|
|
|
*
|
|
|
|
* @return ESP_OK if success, otherwise failed. See return value of ``esp_flash_init_os_functions``.
|
|
|
|
*/
|
|
|
|
esp_err_t esp_flash_app_init(void);
|
|
|
|
|
2019-09-11 14:41:00 -04:00
|
|
|
/**
|
2020-04-09 01:30:12 -04:00
|
|
|
* Disable (or enable) OS-level SPI flash protections in IDF
|
2019-09-11 14:41:00 -04:00
|
|
|
*
|
|
|
|
* Called by the IDF internal code (e.g. coredump). You do not need to call this in your own applications.
|
|
|
|
*
|
|
|
|
* @return always ESP_OK.
|
|
|
|
*/
|
|
|
|
esp_err_t esp_flash_app_disable_protect(bool disable);
|
|
|
|
|
2019-09-10 02:34:06 -04:00
|
|
|
/**
|
|
|
|
* Initialize OS-level functions for a specific chip.
|
|
|
|
*
|
|
|
|
* @param chip The chip to init os functions.
|
|
|
|
* @param host_id Which SPI host to use, 1 for SPI1, 2 for SPI2 (HSPI), 3 for SPI3 (VSPI)
|
2022-04-13 05:23:57 -04:00
|
|
|
* @param dev_handle SPI bus lock device handle to acquire during flash operations
|
2019-09-10 02:34:06 -04:00
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* - ESP_OK if success
|
|
|
|
* - ESP_ERR_INVALID_ARG if host_id is invalid
|
|
|
|
*/
|
2022-04-13 05:23:57 -04:00
|
|
|
esp_err_t esp_flash_init_os_functions(esp_flash_t *chip, int host_id, spi_bus_lock_dev_handle_t dev_handle);
|
2019-10-24 07:00:26 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Deinitialize OS-level functions
|
|
|
|
*
|
2022-04-13 05:23:57 -04:00
|
|
|
* @param chip The chip to deinit os functions
|
|
|
|
* @param out_dev_handle The SPI bus lock passed from `esp_flash_init_os_functions`. The caller should deinitialize
|
|
|
|
* the lock.
|
2019-10-24 07:00:26 -04:00
|
|
|
* @return always ESP_OK.
|
|
|
|
*/
|
2022-04-13 05:23:57 -04:00
|
|
|
esp_err_t esp_flash_deinit_os_functions(esp_flash_t* chip, spi_bus_lock_dev_handle_t* out_dev_handle);
|
2019-09-10 02:34:06 -04:00
|
|
|
|
2020-04-09 01:30:12 -04:00
|
|
|
/**
|
|
|
|
* @brief Initialize the bus lock on the SPI1 bus. Should be called if drivers (including esp_flash)
|
|
|
|
* wants to use SPI1 bus.
|
|
|
|
*
|
|
|
|
* @note When using legacy spi flash API, the bus lock will not be available on SPI1 bus.
|
|
|
|
*
|
|
|
|
* @return esp_err_t always ESP_OK.
|
|
|
|
*/
|
|
|
|
esp_err_t esp_flash_init_main_bus_lock(void);
|
|
|
|
|
2019-09-11 14:41:00 -04:00
|
|
|
/**
|
|
|
|
* Initialize OS-level functions for the main flash chip.
|
|
|
|
*
|
|
|
|
* @param chip The chip to init os functions. Only pointer to the default chip is supported now.
|
|
|
|
*
|
|
|
|
* @return always ESP_OK
|
|
|
|
*/
|
2020-04-09 01:30:12 -04:00
|
|
|
esp_err_t esp_flash_app_enable_os_functions(esp_flash_t* chip);
|
2019-09-11 14:41:00 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable OS-level functions for the main flash chip during special phases (e.g. coredump)
|
|
|
|
*
|
|
|
|
* @param chip The chip to init os functions. Only "esp_flash_default_chip" is supported now.
|
|
|
|
*
|
|
|
|
* @return always ESP_OK
|
|
|
|
*/
|
|
|
|
esp_err_t esp_flash_app_disable_os_functions(esp_flash_t* chip);
|
|
|
|
|
|
|
|
|
2019-09-10 02:34:06 -04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|