Checking SD

Dependencies:   mbed SDFileSystem

main.cpp

Committer:
umezawa
Date:
2020-12-29
Revision:
2:cc13d5354037
Parent:
0:bdbd3d6fc5d5

File content as of revision 2:cc13d5354037:

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

Serial pc(USBTX, USBRX);
SDFileSystem sd(D11, D12, D13, D9, "sd");

int main()
{
    pc.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);

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