@@ -368,53 +368,53 @@ The above figure shows how to connect the NUCLEO_F429ZI with the v1.0.0 CI test
368
368
369
369
The following sample code illustrates how to use the sd-driver Block Device API:
370
370
371
+ ``` cpp
372
+ #include "mbed.h"
373
+ #include "SDBlockDevice.h"
374
+
375
+ // Instantiate the SDBlockDevice by specifying the SPI pins connected to the SDCard
376
+ // socket. The PINS are:
377
+ // MOSI (Master Out Slave In)
378
+ // MISO (Master In Slave Out)
379
+ // SCLK (Serial Clock)
380
+ // CS (Chip Select)
381
+ SDBlockDevice sd(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, MBED_CONF_SD_SPI_CS);
382
+ uint8_t block[512] = "Hello World!\n";
383
+
384
+ int main()
385
+ {
386
+ // call the SDBlockDevice instance initialisation method.
387
+ if ( 0 != sd.init()) {
388
+ printf("Init failed \n");
389
+ return -1;
390
+ }
391
+ printf("sd size: %llu\n", sd.size());
392
+ printf("sd read size: %llu\n", sd.get_read_size());
393
+ printf("sd program size: %llu\n", sd.get_program_size());
394
+ printf("sd erase size: %llu\n", sd.get_erase_size());
395
+
396
+ // set the frequency
397
+ if ( 0 != sd.frequency(5000000)) {
398
+ printf("Error setting frequency \n");
399
+ }
371
400
372
- #include "mbed.h"
373
- #include "SDBlockDevice.h"
374
-
375
- // Instantiate the SDBlockDevice by specifying the SPI pins connected to the SDCard
376
- // socket. The PINS are:
377
- // MOSI (Master Out Slave In)
378
- // MISO (Master In Slave Out)
379
- // SCLK (Serial Clock)
380
- // CS (Chip Select)
381
- SDBlockDevice sd(MBED_CONF_SD_SPI_MOSI, MBED_CONF_SD_SPI_MISO, MBED_CONF_SD_SPI_CLK, MBED_CONF_SD_SPI_CS);
382
- uint8_t block[512] = "Hello World!\n";
383
-
384
- int main()
385
- {
386
- // call the SDBlockDevice instance initialisation method.
387
- if ( 0 != sd.init()) {
388
- printf("Init failed \n");
389
- return -1;
390
- }
391
- printf("sd size: %llu\n", sd.size());
392
- printf("sd read size: %llu\n", sd.get_read_size());
393
- printf("sd program size: %llu\n", sd.get_program_size());
394
- printf("sd erase size: %llu\n", sd.get_erase_size());
395
-
396
- // set the frequency
397
- if ( 0 != sd.frequency(5000000)) {
398
- printf("Error setting frequency \n");
399
- }
400
-
401
- if ( 0 != sd.erase(0, sd.get_erase_size())) {
402
- printf("Error Erasing block \n");
403
- }
401
+ if ( 0 != sd.erase(0, sd.get_erase_size())) {
402
+ printf("Error Erasing block \n");
403
+ }
404
404
405
- // Write some the data block to the device
406
- if ( 0 == sd.program(block, 0, 512)) {
407
- // read the data block from the device
408
- if ( 0 == sd.read(block, 0, 512)) {
409
- // print the contents of the block
410
- printf("%s", block);
411
- }
405
+ // Write some the data block to the device
406
+ if ( 0 == sd.program(block, 0, 512)) {
407
+ // read the data block from the device
408
+ if ( 0 == sd.read(block, 0, 512)) {
409
+ // print the contents of the block
410
+ printf("%s", block);
412
411
}
413
-
414
- // call the SDBlockDevice instance de-initialisation method.
415
- sd.deinit();
416
412
}
417
413
414
+ // call the SDBlockDevice instance de-initialisation method.
415
+ sd.deinit();
416
+ }
417
+ ```
418
418
419
419
# SDCard POSIX File API mbed Greentea Test Cases
420
420
0 commit comments