智也 大野 / Mbed 2 deprecated SDFilesystem

Dependencies:   mbed PowerControl SDFileSystem

Fork of SDFilesystem by 智也 大野

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "SDFileSystem.h"
00003 
00004 Serial pc(USBTX,USBRX);
00005 SDFileSystem sd(p11, p12, p13, p15, "sd");
00006 
00007 int main() {
00008     pc.baud(9600);
00009     pc.printf("Hello world!\r\n");
00010     char str[100];
00011     mkdir("/sd/mydir", 0777);
00012     printf("helloworld\r\n");
00013     FILE *fp = fopen("/sd/mydir/sdtest.txt","w");
00014     if(fp == NULL) {
00015         error("Could not open file for write\r\n");
00016     }
00017     for(int i=0;i<10;i++)fprintf(fp,"Hello my name is HEPTA!\r\n");
00018     fclose(fp); 
00019     fp = fopen("/sd/mydir/sdtest.txt","r");
00020     fgets(str,100,fp);
00021     puts(str);
00022     fclose(fp);
00023     printf("Goodbye!!\r\n");
00024 }