提交 a3947877 编写于 作者: A armink

【优化】stm32f10x flash 驱动。

Signed-off-by: Narmink <armink.ztl@gmail.com>
上级 45530c47
......@@ -71,12 +71,14 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
*/
EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
EfErrCode result = EF_NO_ERR;
uint8_t *buf_8 = (uint8_t *)buf;
size_t i;
EF_ASSERT(size % 4 == 0);
EF_ASSERT(addr % 4 == 0);
/*copy from flash to ram */
for (; size > 0; size -= 4, addr += 4, buf++) {
*buf = *(uint32_t *) addr;
for (i = 0; i < size; i++, addr ++, buf_8++) {
*buf_8 = *(uint8_t *) addr;
}
return result;
......@@ -136,7 +138,7 @@ EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) {
size_t i;
uint32_t read_data;
EF_ASSERT(size % 4 == 0);
EF_ASSERT(addr % 4 == 0);
FLASH_Unlock();
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
......
......@@ -112,7 +112,7 @@ int rt_application_init(void)
rt_thread_startup(&thread_sys_monitor);
init_thread = rt_thread_create("sys init", sys_init_thread,
NULL, 512, 10, 10);
NULL, 1024, 10, 10);
if (init_thread != NULL) {
rt_thread_startup(init_thread);
}
......
......@@ -74,12 +74,14 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
*/
EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
EfErrCode result = EF_NO_ERR;
uint8_t *buf_8 = (uint8_t *)buf;
size_t i;
EF_ASSERT(size % 4 == 0);
EF_ASSERT(addr % 4 == 0);
/*copy from flash to ram */
for (; size > 0; size -= 4, addr += 4, buf++) {
*buf = *(uint32_t *) addr;
for (i = 0; i < size; i++, addr ++, buf_8++) {
*buf_8 = *(uint8_t *) addr;
}
return result;
......@@ -139,7 +141,7 @@ EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) {
size_t i;
uint32_t read_data;
EF_ASSERT(size % 4 == 0);
EF_ASSERT(addr % 4 == 0);
FLASH_Unlock();
FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP | FLASH_FLAG_PGERR | FLASH_FLAG_WRPRTERR);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册