@@ -72,55 +72,7 @@ The figure above shows the Mbed OS software component stack used for data storag
72
72
73
73
### SDBlockDevice example application
74
74
75
- The following sample code illustrates how to use the SD block device API:
76
-
77
- ``` cpp TODO
78
- #include " mbed.h"
79
- #include " SDBlockDevice.h"
80
-
81
- // Instantiate the SDBlockDevice by specifying the SPI pins connected to the SDCard
82
- // socket. The PINS are:
83
- // MOSI (Master Out Slave In)
84
- // MISO (Master In Slave Out)
85
- // SCLK (Serial Clock)
86
- // CS (Chip Select)
87
- SDBlockDevice sd (MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, MBED_CONF_SD_SPI_CS);
88
- uint8_t block[ 512] = "Hello World!\n";
89
-
90
- int main()
91
- {
92
- // call the SDBlockDevice instance initialisation method.
93
- if ( 0 != sd.init()) {
94
- printf("Init failed \n");
95
- return -1;
96
- }
97
- printf("sd size: %llu\n", sd.size());
98
- printf("sd read size: %llu\n", sd.get_read_size());
99
- printf("sd program size: %llu\n", sd.get_program_size());
100
- printf("sd erase size: %llu\n", sd.get_erase_size());
101
-
102
- // set the frequency
103
- if ( 0 != sd.frequency(5000000)) {
104
- printf("Error setting frequency \n");
105
- }
106
-
107
- if ( 0 != sd.erase(0, sd.get_erase_size())) {
108
- printf("Error Erasing block \n");
109
- }
110
-
111
- // Write some the data block to the device
112
- if ( 0 == sd.program(block, 0, 512)) {
113
- // read the data block from the device
114
- if ( 0 == sd.read(block, 0, 512)) {
115
- // print the contents of the block
116
- printf("%s", block);
117
- }
118
- }
119
-
120
- // call the SDBlockDevice instance de-initialisation method.
121
- sd.deinit();
122
- }
123
- ```
75
+ [ ![ View code] ( https://www.mbed.com/embed/?url=https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/blockdevices/SDBlockDevice )] ( https://github.com/ARMmbed/mbed-os-examples-docs_only/blob/master/blockdevices/SDBlockDevice/main.cpp )
124
76
125
77
### Related content
126
78
0 commit comments