Calcul de valeur moyenne par bloc, programme de base, cours ELE118.

Dependencies:   mbed USBHost

Files at this revision

API Documentation at this revision

Comitter:
pierreprovent
Date:
Thu Oct 15 13:06:29 2020 +0000
Parent:
0:707098b8e1b8
Commit message:
Modif mineure

Changed in this revision

Save_USB.cpp Show annotated file Show diff for this revision Revisions of this file
USBHost.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Save_USB.cpp	Thu Oct 15 13:06:29 2020 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+#include "USBHostMSD.h"
+
+Serial pc(USBTX,USBRX) ;
+
+void Sauve_USB(float *tab,int taille)  
+{
+  USBHostMSD msd("usb");
+
+   pc.printf("Connectez la clef USB sur le connecteur prevu a cet effet\n"); // Waiting for USB connection 
+   while(!msd.connect())  // try to connect a MSD device
+   {
+   }
+    pc.printf("Clef USB connectee ne pas debrancher\n");
+    pc.printf("Ecriture des donnes sur la clef USB dans le fichier data.txt\n");
+    FILE *fp = fopen("/usb/data.txt","w"); 
+    if (fp != NULL) 
+    {
+        // Ecriture en format texte éditable sous Notepad
+        /* for (int i = 0 ; i < taille_tab; i++) 
+            fprintf(fp,"%f\n", tab[i]);
+        fclose(fp);     */
+        
+        // Ecriture en binaire pour lecture avec Octave ou Matlab
+        fwrite(tab,sizeof(tab[0]),taille,fp);
+        fclose(fp); 
+        pc.printf("Ecriture terminee, vous pouvez debrancher la clef USB\n");
+    }
+    else 
+        pc.printf("Impossible d'ouvrir le fichier data.txt\n");
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHost.lib	Thu Oct 15 13:06:29 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/USBHost/#7c3b59bb364e
--- a/main.cpp	Thu Oct 15 12:57:38 2020 +0000
+++ b/main.cpp	Thu Oct 15 13:06:29 2020 +0000
@@ -3,7 +3,8 @@
 #define fech 40000 // Fréquence d'échantillonnage souhaitée
 #define TAILLE_BUFFER_SIG (fech/20) // Pour acquisition de 2000 echantillons
 
-Serial pc(USBTX, USBRX);
+extern void Sauve_USB(float *,int ) ;
+extern Serial pc ;
 
 /* Entrées sorties */
 AnalogIn entree(PF_10); // A5 connecteur Arduino