SDFileSystem

Dependencies:   mbed PowerControl SDFileSystem

Fork of SDFilesystem by 智也 大野

main.cpp

Committer:
tomoya123
Date:
2016-12-13
Revision:
1:47daa1a922c4
Parent:
0:8d235efb1150
Child:
2:d8e8144373cc

File content as of revision 1:47daa1a922c4:

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

Serial pc(USBTX,USBRX);
SDFileSystem sd(p11, p12, p13, p15, "sd");

int main() {
    pc.baud(9600);
    pc.printf("Hello world!\r\n");
    char str[100];
    mkdir("/sd/mydir", 0777);
    printf("helloworld\r\n");
    FILE *fp = fopen("/sd/mydir/sdtest.txt","w");
    if(fp == NULL) {
        error("Could not open file for write\r\n");
    }
    for(int i=0;i<10;i++)fprintf(fp,"Hello my name is HEPTA!\r\n");
    fclose(fp); 
    fp = fopen("/sd/mydir/sdtest.txt","r");
    fgets(str,100,fp);
    puts(str);
    fclose(fp);
    printf("Goodbye!!\r\n");
}