File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ # FlashIAPBlockDevice example
2
+
3
+ FlashIAPBlockDevice usage example for Mbed OS
4
+
Original file line number Diff line number Diff line change
1
+ #include " mbed.h"
2
+ #include " FlashIAPBlockDevice.h"
3
+
4
+ // Create flash IAP block device
5
+ FlashIAPBlockDevice bd;
6
+
7
+ int main () {
8
+ printf (" FlashIAPBlockDevice test\n " );
9
+
10
+ // Initialize the flash IAP block device and print the memory layout
11
+ bd.init ();
12
+ printf (" Flash block device size: %llu\n " , bd.size ());
13
+ printf (" Flash block device read size: %llu\n " , bd.get_read_size ());
14
+ printf (" Flash block device program size: %llu\n " , bd.get_program_size ());
15
+ printf (" Flash block device erase size: %llu\n " , bd.get_erase_size ());
16
+
17
+ // Write "Hello World!" to the first block
18
+ char *buffer = (char *)malloc (bd.get_erase_size ());
19
+ sprintf (buffer, " Hello World!\n " );
20
+ bd.erase (0 , bd.get_erase_size ());
21
+ bd.program (buffer, 0 , bd.get_erase_size ());
22
+
23
+ // Read back what was stored
24
+ bd.read (buffer, 0 , bd.get_erase_size ());
25
+ printf (" %s" , buffer);
26
+
27
+ // Deinitialize the device
28
+ bd.deinit ();
29
+ }
Original file line number Diff line number Diff line change
1
+ https://github.com/ARMmbed/mbed-os/#c966348d3f9ca80843be7cdc9b748f06ea73ced0
You can’t perform that action at this time.
0 commit comments