ENSMM / Mbed 2 deprecated I2C_SensorsTMP117

Dependencies:   mbed USBDevice

Files at this revision

API Documentation at this revision

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

Changed in this revision

LIS3DH_spi.lib 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 ec201f39892f 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 ec201f39892f 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 ec201f39892f USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Tue Jan 28 11:09:13 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/USBDevice/#53949e6131f6
diff -r f9cd29526673 -r ec201f39892f 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 ec201f39892f main.cpp
--- a/main.cpp	Tue Dec 17 14:25:24 2019 +0000
+++ b/main.cpp	Tue Jan 28 11:09:13 2020 +0000
@@ -1,95 +1,65 @@
-//Includes
-
+ //Includes
 #include "mbed.h"
-#include "SimpleBLE.h"
-#include "LIS3DH.h"
-
-//Accelerometer
+Timer timer;
+#include "USBSerial.h"
 
-#define MOSI PC_12
-#define MISO PC_11
-#define CS PC_5
-#define SCLK PC_10
-
-//Init simpleBLE
-
-SimpleBLE ble("ObCP_CROC_ENSMM");
+#define I2C_SDA                  PB_9           // The µcontrolleur SDA 
+#define I2C_SCL                  PB_8           // The µcontrolleur SCL
 
 
-// GPIO set
+int Intervalle_Mesures = 300;      //Choix de l'intervalle de mesure en sec
 
 //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
+InterruptIn button(PC_13); //User1
 
-//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);
+//USART
+USBSerial pc(0x1f00, 0x2012, 0x0001, false);
 
 
-// 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)
-{
+//Voie I2C du F411
+I2C i2c(I2C_SDA, I2C_SCL);
 
-    // 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()
-{
+//Variables
 
-    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;
-
-}
-
-// 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);
-
+float tmp;
+char cmd[2];
 
 //Main program
-
-int main(int, char**)
-{
-
-    ble.start();
-    Ticker t;
-    t.attach(&Accupdate, 5.0f);
-
-    while (1) {
-        ble.waitForEvent();
-
+int main(){
+    
+    timer.start();
+    float time, time1;
+    
+    time = timer.read_ms()/1000;
+    
+    pc.printf("Initialiation...\t");
+    cmd[0] = 0x01;
+    cmd[1] = 0x00;
+        
+    i2c.write(0x91, cmd, 2);
+    cmd[0] = 0x00;
+    i2c.write(0x91, cmd, 1);
+    
+    pc.printf("Initialiation OK\t");
+    
+    cmd[0] = 0;
+    cmd[1] = 0;
+    while (button == 1) {
+        time1 = timer.read_ms()/1000;
+        
+        if (time1-time>Intervalle_Mesures){
+            i2c.read(0x90, cmd, 2);
+        
+            float x = float(cmd[0])*2;
+            float y = float(cmd[1])*0.0078125;
+            tmp = x + y;
+            pc.printf("%0.2f", tmp);
+            
+            time=timer.read_ms()/1000;
+            time1=timer.read_ms()/1000;
+        }
     }
 }
+        
+        
+    
diff -r f9cd29526673 -r ec201f39892f mbed.bld
--- a/mbed.bld	Tue Dec 17 14:25:24 2019 +0000
+++ b/mbed.bld	Tue Jan 28 11:09:13 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