Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
31
Issues
31
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
d5abb7e8
Commit
d5abb7e8
authored
Jan 08, 2015
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flash: adding erase function matching sdb-lib convention
parent
bcb4fdef
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
flash.c
dev/flash.c
+20
-0
flash.h
include/flash.h
+3
-0
No files found.
dev/flash.c
View file @
d5abb7e8
...
...
@@ -103,6 +103,26 @@ int flash_read(uint32_t addr, uint8_t *buf, int count)
return
count
;
}
int
flash_erase
(
uint32_t
addr
,
int
count
)
{
int
i
;
int
sectors
;
/*calc number of sectors to be removed*/
if
(
count
%
FLASH_BLOCKSIZE
>
0
)
sectors
=
1
;
else
sectors
=
0
;
sectors
+=
(
count
/
FLASH_BLOCKSIZE
);
for
(
i
=
0
;
i
<
sectors
;
++
i
)
{
flash_serase
(
addr
+
i
*
FLASH_BLOCKSIZE
);
while
(
flash_rsr
()
&
0x01
);
}
return
count
;
}
/*
* Sector erase
*/
...
...
include/flash.h
View file @
d5abb7e8
...
...
@@ -11,10 +11,13 @@
#include "types.h"
#define FLASH_BLOCKSIZE 512
/* Flash interface functions */
void
flash_init
(
void
);
int
flash_write
(
uint32_t
addr
,
uint8_t
*
buf
,
int
count
);
int
flash_read
(
uint32_t
addr
,
uint8_t
*
buf
,
int
count
);
int
flash_erase
(
uint32_t
addr
,
int
count
);
void
flash_serase
(
uint32_t
addr
);
void
flash_berase
(
void
);
uint8_t
flash_rsr
(
void
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment