esp_flash_internal.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include "esp_err.h"
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. #include "sdkconfig.h"
  19. #include "esp_flash.h"
  20. /** Internal API, don't use in the applications */
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /** @brief Initialise the default SPI flash chip
  25. *
  26. * Called by OS startup code. You do not need to call this in your own applications.
  27. */
  28. #ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
  29. #define esp_flash_init_default_chip(...) ({ESP_OK;})
  30. #else
  31. esp_err_t esp_flash_init_default_chip(void);
  32. #endif
  33. /**
  34. * Enable OS-level SPI flash protections in IDF
  35. *
  36. * Called by OS startup code. You do not need to call this in your own applications.
  37. *
  38. * @return ESP_OK if success, otherwise failed. See return value of ``esp_flash_init_os_functions``.
  39. */
  40. #ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
  41. #define esp_flash_app_init(...) ({ESP_OK;})
  42. #else
  43. esp_err_t esp_flash_app_init(void);
  44. #endif
  45. /**
  46. * Disable OS-level SPI flash protections in IDF
  47. *
  48. * Called by the IDF internal code (e.g. coredump). You do not need to call this in your own applications.
  49. *
  50. * @return always ESP_OK.
  51. */
  52. #ifdef CONFIG_SPI_FLASH_USE_LEGACY_IMPL
  53. #define esp_flash_app_disable_protect(...) ({ESP_OK;})
  54. #else
  55. esp_err_t esp_flash_app_disable_protect(bool disable);
  56. #endif
  57. /**
  58. * Initialize OS-level functions for a specific chip.
  59. *
  60. * @param chip The chip to init os functions.
  61. * @param host_id Which SPI host to use, 1 for SPI1, 2 for SPI2 (HSPI), 3 for SPI3 (VSPI)
  62. *
  63. * @return
  64. * - ESP_OK if success
  65. * - ESP_ERR_INVALID_ARG if host_id is invalid
  66. */
  67. esp_err_t esp_flash_init_os_functions(esp_flash_t *chip, int host_id);
  68. /**
  69. * Initialize OS-level functions for the main flash chip.
  70. *
  71. * @param chip The chip to init os functions. Only pointer to the default chip is supported now.
  72. *
  73. * @return always ESP_OK
  74. */
  75. esp_err_t esp_flash_app_init_os_functions(esp_flash_t* chip);
  76. /**
  77. * Disable OS-level functions for the main flash chip during special phases (e.g. coredump)
  78. *
  79. * @param chip The chip to init os functions. Only "esp_flash_default_chip" is supported now.
  80. *
  81. * @return always ESP_OK
  82. */
  83. esp_err_t esp_flash_app_disable_os_functions(esp_flash_t* chip);
  84. #ifdef __cplusplus
  85. }
  86. #endif