Enregistrement des données sur SD

Dependencies:   mbed SDFileSystem USBDevice

Files at this revision

API Documentation at this revision

Comitter:
adrevong
Date:
Tue Jan 28 11:15:54 2020 +0000
Parent:
8:f9cd29526673
Commit message:

Changed in this revision

LIS3DH_spi.lib Show diff for this revision Revisions of this file
SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
SimpleBLE.lib Show diff for this revision Revisions of this file
USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
X_NUCLEO_IDB0XA1.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r f9cd29526673 -r 07ba592deb08 LIS3DH_spi.lib
--- a/LIS3DH_spi.lib	Tue Dec 17 14:25:24 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/users/franzle/code/LIS3DH_spi/#ce2396b1c9a1
diff -r f9cd29526673 -r 07ba592deb08 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Tue Jan 28 11:15:54 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/ENSMM/code/SDFileSystem/#c9f6f3f0cd78
diff -r f9cd29526673 -r 07ba592deb08 SimpleBLE.lib
--- a/SimpleBLE.lib	Tue Dec 17 14:25:24 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/teams/ENSMM/code/SimpleBLE/#e26d79727dfa
diff -r f9cd29526673 -r 07ba592deb08 USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Tue Jan 28 11:15:54 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/USBDevice/#53949e6131f6
diff -r f9cd29526673 -r 07ba592deb08 X_NUCLEO_IDB0XA1.lib
--- a/X_NUCLEO_IDB0XA1.lib	Tue Dec 17 14:25:24 2019 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://os.mbed.com/teams/ENSMM/code/X_NUCLEO_IDB0XA1/#8886c0252544
diff -r f9cd29526673 -r 07ba592deb08 main.cpp
--- a/main.cpp	Tue Dec 17 14:25:24 2019 +0000
+++ b/main.cpp	Tue Jan 28 11:15:54 2020 +0000
@@ -1,95 +1,49 @@
-//Includes
 
+ //Includes
 #include "mbed.h"
-#include "SimpleBLE.h"
-#include "LIS3DH.h"
-
-//Accelerometer
-
-#define MOSI PC_12
-#define MISO PC_11
-#define CS PC_5
-#define SCLK PC_10
-
-//Init simpleBLE
-
-SimpleBLE ble("ObCP_CROC_ENSMM");
+#include "SDFileSystem.h"                       // Sd-Card Libray
+#include "USBSerial.h"
 
 
-// GPIO set
-
-//Interrupt input
-
-InterruptIn user1(PC_13);  //User1
-
-//PWM output
-
-PwmOut PWMoutput(PB_1);          //Main PWM output
-PwmOut Green(PC_8);              //PWM Red LED
-PwmOut Red(PC_6);                //PWM Green LED
-PwmOut Blue(PC_9);               //PWM Blue LED
-
-//Init accelerometer
-
-LIS3DH      acc(MOSI, MISO, SCLK, CS, LIS3DH_DR_NR_LP_50HZ, LIS3DH_FS_2G);
-
-// Characteristics Accelerometer input
-
-SimpleChar<float> accX = ble.readOnly_float(0xA000, 0xA002);
-SimpleChar<float> accY = ble.readOnly_float(0xA000, 0xA003);
-SimpleChar<float> accZ = ble.readOnly_float(0xA000, 0xA004);
+//SD Card
+#define MOSI        PA_7
+#define MISO        PA_6
+#define sclk        PA_5
+#define cs          PB_6
 
 
-// When characteristic LED RGB changing
-
-void LEDupdate(uint32_t newColor)
-{
-    // read individual bytes
-    uint8_t* channels = (uint8_t*)&newColor;
-
-    // cast to float, as PwmOut expects a value between 0.0f and 1.0f
-    Red   = static_cast<float>(channels[0]) / 255.0f;
-    Green = static_cast<float>(channels[1]) / 255.0f;
-    Blue  = static_cast<float>(channels[2]) / 255.0f;
-}
-
-// When characteristic PWM output changing
-
-void PWMupdate(uint8_t pwmvalue)
-{
+//USART
+USBSerial pc(0x1f00, 0x2012, 0x0001, false);
 
-    // cast to float, as PwmOut expects a value between 0.0f and 1.0f
-    PWMoutput   = static_cast<float>(pwmvalue) / 255.0f;
-}
-
-// When characteristic input changing
-void Accupdate()
-{
+//SD Pinout
+SDFileSystem sd(MOSI, MISO, sclk, cs, "sd");
 
-    accX = float(short((acc.read_reg(LIS3DH_OUT_X_H) << 8) | acc.read_reg(LIS3DH_OUT_X_L))) * 0.001F / 15;
-    accY = float(short((acc.read_reg(LIS3DH_OUT_Y_H) << 8) | acc.read_reg(LIS3DH_OUT_Y_L))) * 0.001F / 15;
-    accZ = float(short((acc.read_reg(LIS3DH_OUT_Z_H) << 8) | acc.read_reg(LIS3DH_OUT_Z_L))) * 0.001F / 15;
-
-}
+//Variables
+FILE *SDsave;
 
-// Characteritic PWM LED RGB
-SimpleChar<uint32_t> color = ble.writeOnly_u32(0x6200, 0x6201, &LEDupdate);
 
-// Characteristic PWM output
-SimpleChar<uint8_t> pwmout = ble.writeOnly_u8(0xA000, 0xA001, &PWMupdate);
 
 
 //Main program
-
-int main(int, char**)
-{
-
-    ble.start();
-    Ticker t;
-    t.attach(&Accupdate, 5.0f);
-
-    while (1) {
-        ble.waitForEvent();
-
-    }
+int main(){
+    //Ouverture du fichier SD
+    SDsave= fopen("/sd/SBraTests.txt", "w");        // Open the .txt file
+    pc.printf(" initialisation SD OK\t");
+    
+    //Sauvegarde des données
+    pc.printf(" %0.2f", 30.4152);            //Affichage pour validation
+    fprintf(SDsave, "%0.3f\t", 30.4152);     // Savegarde sur carte SD
+            
+    if(SDsave == NULL) { error("Could not open file for write\n");} 
+    
+    //Retours à la ligne
+    fprintf(SDsave, "\n");
+    pc.printf(" \n\r");
+        
+    //Fermeture du fichier
+    fclose(SDsave);
+    pc.printf("Finish\n");
 }
+        
+        
+    
diff -r f9cd29526673 -r 07ba592deb08 mbed.bld
--- a/mbed.bld	Tue Dec 17 14:25:24 2019 +0000
+++ b/mbed.bld	Tue Jan 28 11:15:54 2020 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file