Skip to content

Move the SDBlockDevice example to an external repo #911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 1 addition & 49 deletions docs/api/storage/SDBlockDevice.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,55 +72,7 @@ The figure above shows the Mbed OS software component stack used for data storag

### SDBlockDevice example application

The following sample code illustrates how to use the SD block device API:

``` cpp TODO
#include "mbed.h"
#include "SDBlockDevice.h"

// Instantiate the SDBlockDevice by specifying the SPI pins connected to the SDCard
// socket. The PINS are:
// MOSI (Master Out Slave In)
// MISO (Master In Slave Out)
// SCLK (Serial Clock)
// CS (Chip Select)
SDBlockDevice sd(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, MBED_CONF_SD_SPI_CS);
uint8_t block[512] = "Hello World!\n";

int main()
{
// call the SDBlockDevice instance initialisation method.
if ( 0 != sd.init()) {
printf("Init failed \n");
return -1;
}
printf("sd size: %llu\n", sd.size());
printf("sd read size: %llu\n", sd.get_read_size());
printf("sd program size: %llu\n", sd.get_program_size());
printf("sd erase size: %llu\n", sd.get_erase_size());

// set the frequency
if ( 0 != sd.frequency(5000000)) {
printf("Error setting frequency \n");
}

if ( 0 != sd.erase(0, sd.get_erase_size())) {
printf("Error Erasing block \n");
}

// Write some the data block to the device
if ( 0 == sd.program(block, 0, 512)) {
// read the data block from the device
if ( 0 == sd.read(block, 0, 512)) {
// print the contents of the block
printf("%s", block);
}
}

// call the SDBlockDevice instance de-initialisation method.
sd.deinit();
}
```
[![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)

### Related content

Expand Down