An example using the SDFileSystem library to create a directory and write a fiel to an SD card, using its SPI interface

Dependencies:   mbed SDFileSystem

main.cpp

Committer:
simon
Date:
2010-09-06
Revision:
1:27aaaa9f462b
Parent:
0:aee5cf626b88

File content as of revision 1:27aaaa9f462b:

// example writing to SD card, sford

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

SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board

int main() {
    printf("Hello World!\n");   

    mkdir("/sd/mydir", 0777);
    
    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
    if(fp == NULL) {
        error("Could not open file for write\n");
    }
    fprintf(fp, "Hello fun SD Card World!");
    fclose(fp); 

    printf("Goodbye World!\n");
}