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:
Wed Nov 16 01:02:04 2016 +0000
Revision:
1:90313362ec11
Parent:
0:60a522ae2e35
Child:
3:247c750f9f3d
New SD card demo showing how to select 3.3V IO

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 1:90313362ec11 5 DigitalOut rLED(LED1);
switches 1:90313362ec11 6 DigitalOut gLED(LED2);
switches 0:60a522ae2e35 7
switches 1:90313362ec11 8 SDFileSystem sd(P0_5, P0_6, P0_4, P0_7, "sd"); // mosi, miso, sclk, cs
switches 0:60a522ae2e35 9
switches 0:60a522ae2e35 10 // main() runs in its own thread in the OS
switches 0:60a522ae2e35 11 // (note the calls to Thread::wait below for delays)
switches 0:60a522ae2e35 12 int main()
switches 0:60a522ae2e35 13 {
switches 1:90313362ec11 14 gLED = LED_OFF;
switches 1:90313362ec11 15 rLED = LED_ON;
switches 1:90313362ec11 16
switches 1:90313362ec11 17 max32630fthrInit();
switches 1:90313362ec11 18 vddioh(P0_4, TRUE);
switches 1:90313362ec11 19 vddioh(P0_5, TRUE);
switches 1:90313362ec11 20 vddioh(P0_6, TRUE);
switches 1:90313362ec11 21 vddioh(P0_7, TRUE);
switches 1:90313362ec11 22 gLED = LED_ON;
switches 1:90313362ec11 23
switches 1:90313362ec11 24 FILE *fp = fopen("/sd/myfile.txt", "w");
switches 1:90313362ec11 25 fprintf(fp, "Hello World!\n");
switches 1:90313362ec11 26 fclose(fp);
switches 1:90313362ec11 27 rLED = LED_OFF;
switches 0:60a522ae2e35 28
switches 0:60a522ae2e35 29 while (true) {
switches 1:90313362ec11 30 gLED = !gLED;
switches 0:60a522ae2e35 31 Thread::wait(500);
switches 0:60a522ae2e35 32 }
switches 0:60a522ae2e35 33 }
switches 0:60a522ae2e35 34