programma di test per vedere se funziona
Dependencies: SDFileSystem_conMOD mbed-rtos mbed
Fork of f4_sd_imu_4 by
lettoreSD.h
00001 #ifndef __LETTORESD__ 00002 #define __LETTORESD__ 00003 00004 #include "SDFileSystem.h" 00005 00006 int nFile = 1; 00007 00008 SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, "sd"); 00009 FILE *fp; 00010 char buffer[100]; //prima era 86100 00011 int nCounter = 0; 00012 00013 void initFile(){ 00014 mkdir("/sd/mydir", 0777); 00015 } 00016 00017 00018 FILE * aperturaFile(){ 00019 char destinazione[14]; 00020 char path[21]="/sd/mydir/"; 00021 sprintf(destinazione, "%d", nFile); 00022 strcat(destinazione, ".txt"); 00023 strcat(path, destinazione); 00024 fp = fopen(path, "a"); 00025 if(fp == NULL){ 00026 error("Could not open file for write\n"); 00027 } 00028 fprintf(fp, "###########FLAG MARCATORE RESET/ACCENSIONE-SPEGNIMENTO############\r\n"); 00029 return fp; 00030 } 00031 00032 void chiusuraFile(){ 00033 fclose(fp); 00034 nFile++; 00035 buffer[0] = 0; 00036 nCounter = 0; 00037 } 00038 00039 void stampaFile(char* stringa){ 00040 if(nCounter == 11){ 00041 fprintf(fp, "%s", buffer); 00042 nCounter = 0; 00043 buffer[0] = 0; 00044 } 00045 else{ 00046 nCounter++; 00047 strcat(buffer, stringa); 00048 } 00049 } 00050 00051 00052 #endif
Generated on Thu Jul 14 2022 13:03:23 by
1.7.2
