esp_spi_flash_counters.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2015-2016 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. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include "esp_err.h"
  17. #include "sdkconfig.h"
  18. #if CONFIG_SPI_FLASH_ENABLE_COUNTERS
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /**
  23. * Structure holding statistics for one type of operation
  24. */
  25. typedef struct {
  26. uint32_t count; // number of times operation was executed
  27. uint32_t time; // total time taken, in microseconds
  28. uint32_t bytes; // total number of bytes
  29. } spi_flash_counter_t;
  30. typedef struct {
  31. spi_flash_counter_t read;
  32. spi_flash_counter_t write;
  33. spi_flash_counter_t erase;
  34. } spi_flash_counters_t;
  35. /**
  36. * @brief Reset SPI flash operation counters
  37. */
  38. void spi_flash_reset_counters(void);
  39. /**
  40. * @brief Print SPI flash operation counters
  41. */
  42. void spi_flash_dump_counters(void);
  43. /**
  44. * @brief Return current SPI flash operation counters
  45. *
  46. * @return pointer to the spi_flash_counters_t structure holding values
  47. * of the operation counters
  48. */
  49. const spi_flash_counters_t* spi_flash_get_counters(void);
  50. #ifdef __cplusplus
  51. }
  52. #endif
  53. #endif //CONFIG_SPI_FLASH_ENABLE_COUNTERS