sfgb

Dependencies:   SDFileSystem mbed

Fork of nucleo_sdcard by emin demir

Committer:
core201608
Date:
Sun Oct 02 08:28:20 2016 +0000
Revision:
1:b8b1257a7769
Parent:
0:b0bc1d4fe0d4
??????;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
core201608 1:b8b1257a7769 1 /*
core201608 1:b8b1257a7769 2 説明
core201608 1:b8b1257a7769 3 Nucleo-F303K8とMicroSDを使ったデータ保存のサンプルプログラム
core201608 1:b8b1257a7769 4
core201608 1:b8b1257a7769 5 ライブラリ
core201608 1:b8b1257a7769 6 https://developer.mbed.org/teams/mbed/code/SDFileSystem/
core201608 1:b8b1257a7769 7
core201608 1:b8b1257a7769 8 以下ピン配置
core201608 1:b8b1257a7769 9 Nucleo SDモジュール
core201608 1:b8b1257a7769 10 GND-----VSS-----------0V
core201608 1:b8b1257a7769 11 +3V3----VDD
core201608 1:b8b1257a7769 12 D11-----CMD
core201608 1:b8b1257a7769 13 D12-----DAT0
core201608 1:b8b1257a7769 14 D13-----CLK
core201608 1:b8b1257a7769 15 D9------CD
core201608 1:b8b1257a7769 16 */
teknoarge 0:b0bc1d4fe0d4 17 #include "mbed.h"
teknoarge 0:b0bc1d4fe0d4 18 #include "SDFileSystem.h"
teknoarge 0:b0bc1d4fe0d4 19
core201608 1:b8b1257a7769 20 SDFileSystem sd(D11, D12, D13, D9, "sd"); // the pinout on the mbed Cool Components workshop board
teknoarge 0:b0bc1d4fe0d4 21
teknoarge 0:b0bc1d4fe0d4 22 int main() {
teknoarge 0:b0bc1d4fe0d4 23 printf("Hello World!\n");
teknoarge 0:b0bc1d4fe0d4 24
teknoarge 0:b0bc1d4fe0d4 25 mkdir("/sd/mydir", 0777);
teknoarge 0:b0bc1d4fe0d4 26
teknoarge 0:b0bc1d4fe0d4 27 FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
teknoarge 0:b0bc1d4fe0d4 28 if(fp == NULL) {
teknoarge 0:b0bc1d4fe0d4 29 error("Could not open file for write\n");
teknoarge 0:b0bc1d4fe0d4 30 }
teknoarge 0:b0bc1d4fe0d4 31 fprintf(fp, "Hello fun SD Card World!");
teknoarge 0:b0bc1d4fe0d4 32 fclose(fp);
teknoarge 0:b0bc1d4fe0d4 33
teknoarge 0:b0bc1d4fe0d4 34 printf("Goodbye World!\n");
teknoarge 0:b0bc1d4fe0d4 35 }