Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q SDFileSystem mbed
Fork of SDCardTest by
main.cpp
00001 #include "mbed.h" 00002 #include "SDFileSystem.h" 00003 #include "MMA8451Q.h" 00004 00005 SDFileSystem sd(PTD2, PTD3, PTD1, PTD0, "sd"); 00006 MMA8451Q acc(PTE25,PTE24); 00007 00008 int main() { 00009 int16_t data[3]; 00010 00011 FILE *fp = fopen("/sd/sdtest.txt", "w"); 00012 if(fp == NULL) { 00013 error("Could not open file for write\n"); 00014 } 00015 // Enable the below line and disable the next line for testing 00016 // for(int i=0;i<10;i++) 00017 while(1) 00018 { 00019 acc.getAccAllAxis(data); 00020 fprintf(fp, "%d",data[0]); 00021 printf("%d",data[0]); 00022 fprintf(fp, ", %d",data[1]); 00023 printf(", %d",data[1]); 00024 fprintf(fp, ", %d\n",data[2]); 00025 printf(", %d\n",data[2]); 00026 } 00027 fclose(fp); 00028 printf("Done Writing! Now Reading... \n"); 00029 00030 fp = fopen("/sd/sdtest.txt", "r"); 00031 if(fp == NULL) { 00032 error("Could not open file for read\n"); 00033 } 00034 int ch; 00035 00036 while((ch = fgetc(fp)) != EOF) 00037 { 00038 printf("%c", ch); 00039 } 00040 printf("DONE Reading!\n"); 00041 fclose(fp); 00042 }
Generated on Mon Jul 18 2022 20:08:18 by
1.7.2
