[feat]增加log总大小计算接口。

Signed-off-by: jaffer <jaffer.work@foxmail.com>
pull/149/head
jaffer 3 years ago
parent a5f09478f7
commit 06370af0a2

@ -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 */

@ -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.
*

Loading…
Cancel
Save