SDFileSystem for STM32F746NG Discovery with 4bit SDMMC interface on fixed pins in DMA mode
Dependencies: BSP_DISCO_F746NG SDFileSystem mbed
main.cpp
- Committer:
- DieterGraef
- Date:
- 2016-04-13
- Revision:
- 3:f93fcb3e2650
- Parent:
- 1:7f463f6f904e
File content as of revision 3:f93fcb3e2650:
#include "mbed.h" #include "SDFileSystem.h" #include <stdio.h> DigitalOut myled(LED1); SDFileSystem sd("sd"); // trim '\n' void ntrim(char *str) { int i; for (i = 0; str[i] != 0; ++i); if (i > 0 && str[i - 1] == '\n') str[i - 1] = 0; } int main() { printf("Starting Filetest"); sd.mount(); FILE * fp; fp = fopen("/sd/test.txt", "w"); if (fp == NULL) { printf("open error!!\r\n"); while(1); } fprintf(fp,"Writing to SD Card"); fclose (fp); fp = fopen("/sd/test.txt", "r"); if (fp == NULL) { printf("open error!!\r\n"); while(1); } // read text file char buf[1024]; while (fgets(buf, sizeof(buf), fp) != NULL) { ntrim(buf); printf("%s\r\n", buf); } // file close fclose(fp); while(1) { myled = 1; // LED is ON wait(0.2); // 200 ms myled = 0; // LED is OFF wait(1.0); // 1 sec } }