esp_psram_extram.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stddef.h>
  8. #include <stdbool.h>
  9. #include "esp_err.h"
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief Check if the pointer is on PSRAM
  15. *
  16. * @param[in] p The pointer to check
  17. *
  18. * @return
  19. * - False: the pointer isn't on PSRAM, or PSRAM isn't initialised successfully
  20. * - True: the pointer is on PSRAM
  21. */
  22. bool esp_psram_check_ptr_addr(const void *p);
  23. /**
  24. * @brief Add the initialized PSRAM to the heap allocator.
  25. *
  26. * @return
  27. * - ESP_OK: On success
  28. * Other error type, see `heap_caps_add_region`.
  29. */
  30. esp_err_t esp_psram_extram_add_to_heap_allocator(void);
  31. /**
  32. * @brief Reserve a pool of internal memory for specific DMA/internal allocations
  33. *
  34. * @param size Size of reserved pool in bytes
  35. *
  36. * @return
  37. * - ESP_OK: On success
  38. * - ESP_ERR_NO_MEM: When no memory available for pool
  39. */
  40. esp_err_t esp_psram_extram_reserve_dma_pool(size_t size);
  41. /**
  42. * @brief Memory test for PSRAM. Should be called after PSRAM is initialized and
  43. * (in case of a dual-core system) the app CPU is online. This test overwrites the
  44. * memory with crap, so do not call after e.g. the heap allocator has stored important
  45. * stuff in PSRAM.
  46. *
  47. * @return true on success, false on failed memory test
  48. */
  49. bool esp_psram_extram_test(void);
  50. #if CONFIG_IDF_TARGET_ESP32
  51. /**
  52. * @brief Force a writeback of the data in the PSRAM cache. This is to be called whenever
  53. * cache is disabled, because disabling cache on the ESP32 discards the data in the PSRAM
  54. * cache.
  55. *
  56. * This is meant for use from within the SPI flash code.
  57. */
  58. void esp_psram_extram_writeback_cache(void);
  59. #endif
  60. #ifdef __cplusplus
  61. }
  62. #endif