diff --git a/easyflash/inc/easyflash.h b/easyflash/inc/easyflash.h index 2aab0b1..dfaf4b3 100644 --- a/easyflash/inc/easyflash.h +++ b/easyflash/inc/easyflash.h @@ -85,6 +85,7 @@ EfErrCode ef_log_read(size_t index, uint32_t *log, size_t size); EfErrCode ef_log_write(const uint32_t *log, size_t size); EfErrCode ef_log_clean(void); size_t ef_log_get_used_size(void); +size_t ef_log_get_total_size(void); #endif /* ef_utils.c */ diff --git a/easyflash/src/ef_log.c b/easyflash/src/ef_log.c index 49e9d7c..7e4da13 100644 --- a/easyflash/src/ef_log.c +++ b/easyflash/src/ef_log.c @@ -410,6 +410,23 @@ size_t ef_log_get_used_size(void) { return physical_size - header_total_num * LOG_SECTOR_HEADER_SIZE; } +/** + * Get log flash total size. + * + * @return log flash total size. @note NOT contain sector headers + */ +size_t ef_log_get_total_size(void) { + size_t header_total_num = 0; + /* must be call this function after initialize OK */ + if (!init_ok) { + return 0; + } + + header_total_num = LOG_AREA_SIZE / EF_ERASE_MIN_SIZE; + + return LOG_AREA_SIZE - header_total_num * LOG_SECTOR_HEADER_SIZE; +} + /** * Sequential reading log data. It will ignore sector headers. *