sfgb

Dependencies:   SDFileSystem mbed

Fork of nucleo_sdcard by emin demir

main.cpp

Committer:
core201608
Date:
2016-10-02
Revision:
1:b8b1257a7769
Parent:
0:b0bc1d4fe0d4

File content as of revision 1:b8b1257a7769:

/*
説明
Nucleo-F303K8とMicroSDを使ったデータ保存のサンプルプログラム

ライブラリ
https://developer.mbed.org/teams/mbed/code/SDFileSystem/

以下ピン配置
Nucleo  SDモジュール
GND-----VSS-----------0V
+3V3----VDD
D11-----CMD
D12-----DAT0
D13-----CLK
D9------CD
*/
#include "mbed.h"
#include "SDFileSystem.h"
 
SDFileSystem sd(D11, D12, D13, D9, "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");
}