mirror of https://github.com/ARMmbed/mbed-os.git
Updated Readme example
parent
e2dbe1fae7
commit
38247b9987
40
README.md
40
README.md
|
@ -383,24 +383,32 @@ The following sample code illustrates how to use the sd-driver Block Device API:
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// call the SDBlockDevice instance initialisation method.
|
// call the SDBlockDevice instance initialisation method.
|
||||||
if ( 0 != sd.init()) {
|
if ( 0 != sd.init()) {
|
||||||
printf("Init failed \n");
|
printf("Init failed \n");
|
||||||
return -1;
|
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
|
// set the frequency
|
||||||
if ( 0 != sd.frequency(5000000)) {
|
if ( 0 != sd.frequency(5000000)) {
|
||||||
printf("Error setting frequency \n");
|
printf("Error setting frequency \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write some the data block to the device
|
if ( 0 != sd.erase(0, sd.get_erase_size())) {
|
||||||
if ( 0 == sd.program(block, 0, 512)) {
|
printf("Error Erasing block \n");
|
||||||
// read the data block from the device
|
}
|
||||||
if ( 0 == sd.read(block, 0, 512)) {
|
|
||||||
// print the contents of the block
|
// Write some the data block to the device
|
||||||
printf("%s", block);
|
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.
|
// call the SDBlockDevice instance de-initialisation method.
|
||||||
sd.deinit();
|
sd.deinit();
|
||||||
|
|
Loading…
Reference in New Issue