@@ -383,24 +383,32 @@ The following sample code illustrates how to use the sd-driver Block Device API:
383
383
int main()
384
384
{
385
385
// call the SDBlockDevice instance initialisation method.
386
- if ( 0 != sd.init()) {
387
- printf("Init failed \n");
388
- return -1;
389
- }
390
-
391
- // set the frequency
392
- if ( 0 != sd.frequency(5000000)) {
393
- printf("Error setting frequency \n");
394
- }
395
-
396
- // Write some the data block to the device
397
- if ( 0 == sd.program(block, 0, 512)) {
398
- // read the data block from the device
399
- if ( 0 == sd.read(block, 0, 512)) {
400
- // print the contents of the block
401
- printf("%s", block);
402
- }
403
- }
386
+ if ( 0 != sd.init()) {
387
+ printf("Init failed \n");
388
+ return -1;
389
+ }
390
+ printf("sd size: %llu\n", sd.size());
391
+ printf("sd read size: %llu\n", sd.get_read_size());
392
+ printf("sd program size: %llu\n", sd.get_program_size());
393
+ printf("sd erase size: %llu\n", sd.get_erase_size());
394
+
395
+ // set the frequency
396
+ if ( 0 != sd.frequency(5000000)) {
397
+ printf("Error setting frequency \n");
398
+ }
399
+
400
+ if ( 0 != sd.erase(0, sd.get_erase_size())) {
401
+ printf("Error Erasing block \n");
402
+ }
403
+
404
+ // Write some the data block to the device
405
+ if ( 0 == sd.program(block, 0, 512)) {
406
+ // read the data block from the device
407
+ if ( 0 == sd.read(block, 0, 512)) {
408
+ // print the contents of the block
409
+ printf("%s", block);
410
+ }
411
+ }
404
412
405
413
// call the SDBlockDevice instance de-initialisation method.
406
414
sd.deinit();
0 commit comments