Example program demonstrates SD card library

Dependencies:   SDFileSystem USBDevice max32630fthr

Fork of FTHR_SD_Demo by Greg Steiert

This example program writes "Hello World!" into a file named "myfile.txt" on the card inserted into the microSD card connector.

main.cpp

Committer:
h_keyur
Date:
2017-11-17
Revision:
8:be1c3495b9ea
Parent:
6:96d8d823e292

File content as of revision 8:be1c3495b9ea:

#include "mbed.h"
#include "max32630fthr.h"
#include "SDFileSystem.h"

MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);

DigitalOut rLED(LED1);
DigitalOut gLED(LED2);

SDFileSystem sd(P0_5, P0_6, P0_4, P0_7, "sd");  // mosi, miso, sclk, cs

// main() runs in its own thread in the OS
// (note the calls to Thread::wait below for delays)
int main()
{
    gLED = LED_ON;
    rLED = LED_ON;

    FILE *fp = fopen("/sd/myfile.txt", "w");
    fprintf(fp, "Hello World!\n");
    fclose(fp);
    rLED = LED_OFF;

    while (true) {
        gLED = !gLED;
        Thread::wait(500);
    }
}