Skip to content

Commit

Permalink
Merge pull request #149 from i-jaffer/feat/calcu_usage
Browse files Browse the repository at this point in the history
[feat]增加log总大小计算接口
  • Loading branch information
armink authored Dec 14, 2022
2 parents aaa1681 + 06370af commit f732982
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions easyflash/inc/easyflash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
17 changes: 17 additions & 0 deletions easyflash/src/ef_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit f732982

Please sign in to comment.