@@ -14,38 +14,7 @@ To configure this class, please see our [BlockDevice configuration documentation
14
14
15
15
### SPIFBlockDevice example
16
16
17
- ``` cpp TODO
18
- // Here's an example using the MX25R SPI flash device on the K82F
19
- #include " mbed.h"
20
- #include " SPIFBlockDevice.h"
21
-
22
- // Create flash device on SPI bus with PTE5 as chip select
23
- SPIFBlockDevice spif (PTE2, PTE4, PTE1, PTE5);
24
-
25
- int main() {
26
- printf("spif test\n");
27
-
28
- // Initialize the SPI flash device and print the memory layout
29
- spif.init();
30
- printf("spif size: %llu\n", spif.size());
31
- printf("spif read size: %llu\n", spif.get_read_size());
32
- printf("spif program size: %llu\n", spif.get_program_size());
33
- printf("spif erase size: %llu\n", spif.get_erase_size());
34
-
35
- // Write "Hello World!" to the first block
36
- char *buffer = (char*)malloc(spif.get_erase_size());
37
- sprintf(buffer, "Hello World!\n");
38
- spif.erase(0, spif.get_erase_size());
39
- spif.program(buffer, 0, spif.get_erase_size());
40
-
41
- // Read back what was stored
42
- spif.read(buffer, 0, spif.get_erase_size());
43
- printf("%s", buffer);
44
-
45
- // Deinitialize the device
46
- spif.deinit();
47
- }
48
- ```
17
+ [ ![ View code] ( https://www.mbed.com/embed/?url=https://github.com/ARMmbed/mbed-os-examples-docs_only/SPIFBlockDevice )] ( https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/SPIFBlockDevice/main.cpp )
49
18
50
19
### Related content
51
20
0 commit comments