Skip to content
首页
学习广场
开源秀
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mirrors
armink
easyflash
提交
818bc4f3
E
easyflash
项目概览
mirrors
/
armink
/
easyflash
大约 15 小时 前同步成功
通知
63
Star
1499
Fork
655
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
easyflash
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
818bc4f3
编写于
11月 15, 2018
作者:
R
redocCheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【优化】tab键导致的格式问题。
上级
8ddd8047
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
40 deletion
+40
-40
easyflash/src/ef_log.c
easyflash/src/ef_log.c
+40
-40
未找到文件。
easyflash/src/ef_log.c
浏览文件 @
818bc4f3
...
...
@@ -111,7 +111,7 @@ EfErrCode ef_log_init(void) {
static
SectorStatus
get_sector_status
(
uint32_t
addr
)
{
uint32_t
header_buf
[
3
]
=
{
0
},
header_addr
=
0
;
uint32_t
sector_magic
=
0
;
uint32_t
status_full_magic
=
0
,
status_use_magic
=
0
;
uint32_t
status_full_magic
=
0
,
status_use_magic
=
0
;
/* calculate the sector header address */
header_addr
=
addr
/
EF_ERASE_MIN_SIZE
*
EF_ERASE_MIN_SIZE
;
...
...
@@ -119,47 +119,47 @@ static SectorStatus get_sector_status(uint32_t addr) {
if
(
ef_port_read
(
header_addr
,
header_buf
,
sizeof
(
header_buf
))
==
EF_NO_ERR
)
{
sector_magic
=
header_buf
[
0
];
status_full_magic
=
header_buf
[
SECTOR_STATUS_FULL
];
status_use_magic
=
header_buf
[
SECTOR_STATUS_USING
];
status_use_magic
=
header_buf
[
SECTOR_STATUS_USING
];
}
else
{
EF_DEBUG
(
"Error: Read sector header data error.
\n
"
);
return
SECTOR_STATUS_HEADER_ERROR
;
}
/* compare header magic code */
if
(
sector_magic
==
LOG_SECTOR_MAGIC
)
{
switch
(
status_use_magic
)
{
switch
(
status_use_magic
)
{
case
SECTOR_STATUS_MAGIC_EMPUT
:{
switch
(
status_full_magic
)
{
case
SECTOR_STATUS_MAGIC_EMPUT
:
return
SECTOR_STATUS_EMPUT
;
case
SECTOR_STATUS_MAGIC_USING
:
return
SECTOR_STATUS_HEADER_ERROR
;
case
SECTOR_STATUS_MAGIC_FULL
:
return
SECTOR_STATUS_HEADER_ERROR
;
default:
return
SECTOR_STATUS_HEADER_ERROR
;
}
}
switch
(
status_full_magic
)
{
case
SECTOR_STATUS_MAGIC_EMPUT
:
return
SECTOR_STATUS_EMPUT
;
case
SECTOR_STATUS_MAGIC_USING
:
return
SECTOR_STATUS_HEADER_ERROR
;
case
SECTOR_STATUS_MAGIC_FULL
:
return
SECTOR_STATUS_HEADER_ERROR
;
default:
return
SECTOR_STATUS_HEADER_ERROR
;
}
}
case
SECTOR_STATUS_MAGIC_USING
:{
switch
(
status_full_magic
)
{
case
SECTOR_STATUS_MAGIC_EMPUT
:
return
SECTOR_STATUS_USING
;
case
SECTOR_STATUS_MAGIC_USING
:
return
SECTOR_STATUS_HEADER_ERROR
;
case
SECTOR_STATUS_MAGIC_FULL
:
return
SECTOR_STATUS_FULL
;
default:
return
SECTOR_STATUS_HEADER_ERROR
;
}
}
switch
(
status_full_magic
)
{
case
SECTOR_STATUS_MAGIC_EMPUT
:
return
SECTOR_STATUS_USING
;
case
SECTOR_STATUS_MAGIC_USING
:
return
SECTOR_STATUS_HEADER_ERROR
;
case
SECTOR_STATUS_MAGIC_FULL
:
return
SECTOR_STATUS_FULL
;
default:
return
SECTOR_STATUS_HEADER_ERROR
;
}
}
case
SECTOR_STATUS_MAGIC_FULL
:
return
SECTOR_STATUS_HEADER_ERROR
;
return
SECTOR_STATUS_HEADER_ERROR
;
default:
return
SECTOR_STATUS_HEADER_ERROR
;
}
}
}
else
{
return
SECTOR_STATUS_HEADER_ERROR
;
}
...
...
@@ -181,24 +181,24 @@ static EfErrCode write_sector_status(uint32_t addr, SectorStatus status) {
switch
(
status
)
{
case
SECTOR_STATUS_EMPUT
:
{
header_buf
[
SECTOR_STATUS_USING
]
=
SECTOR_STATUS_MAGIC_EMPUT
;
header_buf
[
SECTOR_STATUS_FULL
]
=
SECTOR_STATUS_MAGIC_EMPUT
;
header_buf
[
SECTOR_STATUS_USING
]
=
SECTOR_STATUS_MAGIC_EMPUT
;
header_buf
[
SECTOR_STATUS_FULL
]
=
SECTOR_STATUS_MAGIC_EMPUT
;
break
;
}
case
SECTOR_STATUS_USING
:
{
header_buf
[
SECTOR_STATUS_USING
]
=
SECTOR_STATUS_MAGIC_USING
;
header_buf
[
SECTOR_STATUS_FULL
]
=
SECTOR_STATUS_MAGIC_EMPUT
;
header_buf
[
SECTOR_STATUS_USING
]
=
SECTOR_STATUS_MAGIC_USING
;
header_buf
[
SECTOR_STATUS_FULL
]
=
SECTOR_STATUS_MAGIC_EMPUT
;
break
;
}
case
SECTOR_STATUS_FULL
:
{
header_buf
[
SECTOR_STATUS_USING
]
=
SECTOR_STATUS_MAGIC_USING
;
header_buf
[
SECTOR_STATUS_FULL
]
=
SECTOR_STATUS_MAGIC_FULL
;
header_buf
[
SECTOR_STATUS_FULL
]
=
SECTOR_STATUS_MAGIC_FULL
;
break
;
}
}
header_buf
[
0
]
=
LOG_SECTOR_MAGIC
;
header_buf
[
0
]
=
LOG_SECTOR_MAGIC
;
return
ef_port_write
(
header_addr
,
header_buf
,
sizeof
(
header_buf
));
}
...
...
@@ -292,7 +292,7 @@ static void find_start_and_end_addr(void) {
/* get the first sector status */
cur_sec_status
=
get_sector_status
(
log_area_start_addr
);
last_sec_status
=
cur_sec_status
;
for
(
cur_size
=
EF_ERASE_MIN_SIZE
;
cur_size
<
LOG_AREA_SIZE
;
cur_size
+=
EF_ERASE_MIN_SIZE
)
{
/* get current sector status */
...
...
@@ -402,7 +402,7 @@ static void find_start_and_end_addr(void) {
/* find the end address */
log_end_addr
=
find_sec_using_end_addr
(
cur_using_sec_addr
);
}
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录