Dimas Nugroho / Mbed OS Trisula_Data_Logger

Dependencies:   RTC_Reader SDFileSystem DS3231

Committer:
DimasFN
Date:
Fri Nov 16 23:06:22 2018 +0000
Revision:
0:eb4606c99ae9
Child:
1:cd725fbbcbc2
Getting Started with SPI Communications to the SD Card module to write strings into a .txt file and store it into Micro SD card;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DimasFN 0:eb4606c99ae9 1
DimasFN 0:eb4606c99ae9 2 //https://os.mbed.com/users/neilt6/code/SDFileSystem_HelloWorld/
DimasFN 0:eb4606c99ae9 3
DimasFN 0:eb4606c99ae9 4 #include "mbed.h"
DimasFN 0:eb4606c99ae9 5 #include "SDFileSystem.h"
DimasFN 0:eb4606c99ae9 6
DimasFN 0:eb4606c99ae9 7 //SDFileSystem::SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name) :
DimasFN 0:eb4606c99ae9 8 SDFileSystem sd(D11, D12, D13, D10, "G"); // the pinout on the mbed Cool Components workshop board
DimasFN 0:eb4606c99ae9 9
DimasFN 0:eb4606c99ae9 10 int main() {
DimasFN 0:eb4606c99ae9 11 printf("SD card test!\r\n");
DimasFN 0:eb4606c99ae9 12
DimasFN 0:eb4606c99ae9 13 mkdir("/G/mydir", 0777);
DimasFN 0:eb4606c99ae9 14
DimasFN 0:eb4606c99ae9 15 FILE *fp = fopen("/G/mydir/TEST.txt", "w");
DimasFN 0:eb4606c99ae9 16 if(fp == NULL) {
DimasFN 0:eb4606c99ae9 17 error("Could not open file for write\r\n");
DimasFN 0:eb4606c99ae9 18 }
DimasFN 0:eb4606c99ae9 19 fprintf(fp, "Hello fun SD Card World!\r\n");
DimasFN 0:eb4606c99ae9 20 fclose(fp);
DimasFN 0:eb4606c99ae9 21
DimasFN 0:eb4606c99ae9 22 printf("File successfully written and closed!\r\n");
DimasFN 0:eb4606c99ae9 23 }