components/spi_flash: add flash operation counters option to Kconfig

This commit is contained in:
Ivan Grokhotkov
2016-09-23 08:44:45 +08:00
parent 2a68f60874
commit f2149eabee
3 changed files with 93 additions and 36 deletions

View File

@@ -17,6 +17,7 @@
#include <stdint.h>
#include "esp_err.h"
#include "sdkconfig.h"
#ifdef __cplusplus
extern "C" {
@@ -69,10 +70,42 @@ esp_err_t spi_flash_write(uint32_t des_addr, const uint32_t *src_addr, uint32_t
esp_err_t spi_flash_read(uint32_t src_addr, uint32_t *des_addr, uint32_t size);
void spi_flash_reset_stats();
#if CONFIG_SPI_FLASH_ENABLE_COUNTERS
void spi_flash_dump_stats();
/**
* Structure holding statistics for one type of operation
*/
typedef struct {
uint32_t count; // number of times operation was executed
uint32_t time; // total time taken, in microseconds
uint32_t bytes; // total number of bytes, for read and write operations
} spi_flash_counter_t;
typedef struct {
spi_flash_counter_t read;
spi_flash_counter_t write;
spi_flash_counter_t erase;
} spi_flash_counters_t;
/**
* @brief Reset SPI flash operation counters
*/
void spi_flash_reset_counters();
/**
* @brief Print SPI flash operation counters
*/
void spi_flash_dump_counters();
/**
* @brief Return current SPI flash operation counters
*
* @return pointer to the spi_flash_counters_t structure holding values
* of the operation counters
*/
const spi_flash_counters_t* spi_flash_get_counters();
#endif //CONFIG_SPI_FLASH_ENABLE_COUNTERS
#ifdef __cplusplus
}