feat(spi_flash): Adds esp_flash_set_dangerous_write_protection

This commit is contained in:
Konstantin Kondrashov
2024-09-26 08:42:19 +03:00
parent 02d61c1c5a
commit 0d4787fb3a
2 changed files with 39 additions and 3 deletions
+17 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -350,6 +350,22 @@ esp_err_t esp_flash_app_enable_os_functions(esp_flash_t* chip)
return ESP_OK;
}
esp_err_t esp_flash_set_dangerous_write_protection(esp_flash_t *chip, const bool protect)
{
#if !CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED
if (chip == NULL) {
return ESP_ERR_INVALID_ARG;
}
if (chip->os_func_data != NULL) {
((app_func_arg_t*)chip->os_func_data)->no_protect = !protect;
}
#else
(void)chip;
(void)protect;
#endif
return ESP_OK;
}
// The goal of this part is to manually insert one valid task execution interval, if the time since
// last valid interval exceed the limitation (CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS).
//