Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
人间散章
rt-thread
提交
acf4fc6d
R
rt-thread
项目概览
人间散章
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
acf4fc6d
编写于
3月 12, 2020
作者:
R
redoc
提交者:
GitHub
3月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update drv_flash_f1.c
support stm32f103vg
上级
3e8c03e9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
90 addition
and
4 deletion
+90
-4
bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c
bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c
+90
-4
未找到文件。
bsp/stm32/libraries/HAL_Drivers/drv_flash/drv_flash_f1.c
浏览文件 @
acf4fc6d
...
...
@@ -6,6 +6,8 @@
* Change Logs:
* Date Author Notes
* 2018-12-5 SummerGift first version
* 2020-03-05 redoc support stm32f103vg
*
*/
#include "board.h"
...
...
@@ -122,16 +124,17 @@ int stm32_flash_write(rt_uint32_t addr, const rt_uint8_t *buf, size_t size)
}
/**
* Erase data on flash.
* Erase data on flash
with bank
.
* @note This operation is irreversible.
* @note This operation's units is different which on many chips.
*
* @param bank flash bank
* @param addr flash address
* @param size erase bytes size
*
* @return result
*/
int
stm32_flash_erase
(
rt_uint32_t
addr
,
size_t
size
)
int
stm32_flash_erase
_bank
(
uint32_t
bank
,
rt_uint32_t
addr
,
size_t
size
)
{
rt_err_t
result
=
RT_EOK
;
uint32_t
PAGEError
=
0
;
...
...
@@ -151,7 +154,8 @@ int stm32_flash_erase(rt_uint32_t addr, size_t size)
EraseInitStruct
.
TypeErase
=
FLASH_TYPEERASE_PAGES
;
EraseInitStruct
.
PageAddress
=
GetPage
(
addr
);
EraseInitStruct
.
NbPages
=
(
size
+
FLASH_PAGE_SIZE
-
1
)
/
FLASH_PAGE_SIZE
;
EraseInitStruct
.
Banks
=
bank
;
if
(
HAL_FLASHEx_Erase
(
&
EraseInitStruct
,
&
PAGEError
)
!=
HAL_OK
)
{
result
=
-
RT_ERROR
;
...
...
@@ -166,10 +170,92 @@ __exit:
return
result
;
}
LOG_D
(
"erase done: addr (0x%p), size %d"
,
(
void
*
)
addr
,
size
);
log_d
(
"erase done: addr (0x%p), size %d"
,
(
void
*
)
addr
,
size
);
return
size
;
}
/**
* Erase data on flash .
* @note This operation is irreversible.
* @note This operation's units is different which on many chips.
*
* @param addr flash address
* @param size erase bytes size
*
* @return result
*/
int
stm32_flash_erase
(
rt_uint32_t
addr
,
size_t
size
)
{
rt_err_t
result
=
RT_EOK
;
#if defined(FLASH_BANK2_END)
uint32_t
addr_bank1
=
0
;
uint32_t
size_bank1
=
0
;
uint32_t
addr_bank2
=
0
;
uint32_t
size_bank2
=
0
;
uint8_t
bank1_flag
=
0
;
uint8_t
bank2_flag
=
0
;
#endif
#if defined(FLASH_BANK2_END)
if
(
addr
<=
FLASH_BANK1_END
)
{
addr_bank1
=
addr
;
bank1_flag
=
1
;
if
((
addr
+
size
)
>
FLASH_BANK1_END
)
{
addr_bank2
=
FLASH_BANK1_END
+
1
;
size_bank2
=
addr
+
size
-
(
FLASH_BANK1_END
+
1
);
if
(
size_bank2
)
{
bank2_flag
=
1
;
}
size_bank1
=
FLASH_BANK1_END
+
1
-
addr_bank1
;
}
else
{
size_bank1
=
size
;
}
}
else
{
addr_bank2
=
addr
;
size_bank2
=
size
;
bank1_flag
=
0
;
bank2_flag
=
1
;
}
if
(
bank1_flag
)
{
log_d
(
"bank1: addr (0x%p), size %d"
,
(
void
*
)
addr_bank1
,
size_bank1
);
if
(
size_bank1
!=
stm32_flash_erase_bank
(
FLASH_BANK_1
,
addr_bank1
,
size_bank1
))
{
result
=
-
RT_ERROR
;
}
}
if
(
bank2_flag
)
{
log_d
(
"bank2: addr (0x%p), size %d"
,
(
void
*
)
addr_bank2
,
size_bank2
);
if
(
size_bank2
!=
stm32_flash_erase_bank
(
FLASH_BANK_2
,
addr_bank2
,
size_bank2
))
{
result
=
-
RT_ERROR
;
}
}
return
result
;
#else
return
stm32_flash_erase_bank
(
FLASH_BANK_1
,
addr
,
size
);
#endif
}
#if defined(PKG_USING_FAL)
static
int
fal_flash_read
(
long
offset
,
rt_uint8_t
*
buf
,
size_t
size
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录