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.

Committer:
switches
Date:
Sun Nov 20 23:57:26 2016 +0000
Revision:
3:247c750f9f3d
Parent:
1:90313362ec11
Child:
4:bafcac667ef6
Updated to new MAX32630FTHR Class Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:60a522ae2e35 1 #include "mbed.h"
switches 1:90313362ec11 2 #include "max32630fthr.h"
switches 1:90313362ec11 3 #include "SDFileSystem.h"
switches 0:60a522ae2e35 4
switches 3:247c750f9f3d 5 MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
switches 3:247c750f9f3d 6
switches 1:90313362ec11 7 DigitalOut rLED(LED1);
switches 1:90313362ec11 8 DigitalOut gLED(LED2);
switches 0:60a522ae2e35 9
switches 1:90313362ec11 10 SDFileSystem sd(P0_5, P0_6, P0_4, P0_7, "sd"); // mosi, miso, sclk, cs
switches 0:60a522ae2e35 11
switches 0:60a522ae2e35 12 // main() runs in its own thread in the OS
switches 0:60a522ae2e35 13 // (note the calls to Thread::wait below for delays)
switches 0:60a522ae2e35 14 int main()
switches 0:60a522ae2e35 15 {
switches 1:90313362ec11 16 gLED = LED_OFF;
switches 1:90313362ec11 17 rLED = LED_ON;
switches 1:90313362ec11 18
switches 3:247c750f9f3d 19 pegasus.init();
switches 1:90313362ec11 20 gLED = LED_ON;
switches 1:90313362ec11 21
switches 1:90313362ec11 22 FILE *fp = fopen("/sd/myfile.txt", "w");
switches 1:90313362ec11 23 fprintf(fp, "Hello World!\n");
switches 1:90313362ec11 24 fclose(fp);
switches 1:90313362ec11 25 rLED = LED_OFF;
switches 0:60a522ae2e35 26
switches 0:60a522ae2e35 27 while (true) {
switches 1:90313362ec11 28 gLED = !gLED;
switches 0:60a522ae2e35 29 Thread::wait(500);
switches 0:60a522ae2e35 30 }
switches 0:60a522ae2e35 31 }
switches 0:60a522ae2e35 32