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: SDFileSystem1 mbed
Fork of SDFileSystem_HelloWorld by
Revision 2:f59bd5312559, committed 2017-11-20
- Comitter:
- NdA994
- Date:
- Mon Nov 20 22:18:10 2017 +0000
- Parent:
- 1:e4d7342be507
- Commit message:
- Libreria per scrittura su Sd completa. Ho eseguito dei test per vedere se l'accelerometro reggeva la scrittura ed hanno dato esiti positivi.
Changed in this revision
--- a/SDFileSystem.lib Tue May 16 05:18:55 2017 +0000 +++ b/SDFileSystem.lib Mon Nov 20 22:18:10 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/SDFileSystem/#8db0d3b02cec +https://os.mbed.com/teams/Unina_corse/code/SDFileSystem1/#cfed551cc1a2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lettoreSD.h Mon Nov 20 22:18:10 2017 +0000
@@ -0,0 +1,52 @@
+#ifndef __LETTORESD__
+#define __LETTORESD__
+
+#include "SDFileSystem.h"
+
+int nFile = 1;
+
+SDFileSystem sd(SPI_MOSI, SPI_MISO, SPI_SCK, A2, "sd");
+FILE *fp;
+char buffer[4100];
+int nCounter = 0;
+
+void initFile(){
+ mkdir("/sd/mydir", 0777);
+}
+
+
+FILE * aperturaFile(){
+ char destinazione[14];
+ char path[21]="/sd/mydir/";
+ sprintf(destinazione, "%d", nFile);
+ strcat(destinazione, ".txt");
+ strcat(path, destinazione);
+ fp = fopen(path, "w");
+ if(fp == NULL){
+ error("Could not open file for write\n");
+ }
+ return fp;
+}
+
+void chiusuraFile(){
+ fclose(fp);
+ nFile++;
+ buffer[0] = 0;
+ nCounter = 0;
+}
+
+void stampaFile(char* stringa){
+ if(nCounter == 99){
+ fprintf(fp, "%s", buffer);
+ nCounter = 0;
+ buffer[0] = 0;
+ printf("sono qua <---------\n\r");
+ }
+ else{
+ printf("sono qua\n\r");
+ nCounter++;
+ strcat(buffer, stringa);
+ }
+}
+
+#endif
\ No newline at end of file
--- a/main.cpp Tue May 16 05:18:55 2017 +0000
+++ b/main.cpp Mon Nov 20 22:18:10 2017 +0000
@@ -1,19 +1,22 @@
#include "mbed.h"
-#include "SDFileSystem.h"
-
-SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
-
+#include "setting.h"
+#include "lettoreSD.h"
+
+
int main() {
- printf("Hello World!\n");
-
- mkdir("/sd/mydir", 0777);
+ init();
+ printf("Hello World!\n\r");
+ initFile();
+ aperturaFile();
+ for(int i=0; i<1000; i++){
+ stampaFile("A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n");
+ }
+ chiusuraFile();
+ aperturaFile();
+ for(int i=0; i<1000; i++){
+ stampaFile("A1xxxxoooooggggggeeeeeeerrrryyyyynhgrgr#2\r\n");
+ }
+ chiusuraFile();
+ printf("Goodbye World!\n\r");
- FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
- if(fp == NULL) {
- error("Could not open file for write\n");
- }
- fprintf(fp, "Hello fun SD Card World!");
- fclose(fp);
-
- printf("Goodbye World!\n");
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/setting.h Mon Nov 20 22:18:10 2017 +0000
@@ -0,0 +1,18 @@
+#ifndef __SETTING__
+#define __SETTING__
+
+#include "mbed.h"
+
+#include "lettoreSD.h"
+
+Serial pc(USBTX, USBRX);
+
+void init(){
+ pc.baud(921600);
+}
+
+
+
+
+
+#endif
\ No newline at end of file
